Comments (9)
Yes, of course!
from trafilatura.
Hi @zirkelc, it makes perfect sense to give back a confidence score to the user. I used a binary criterion at some point and then removed it. The feature would need to be implemented before adding such a function.
from trafilatura.
Hi @adbar thanks for the quick response! Are you planning to add this feature? I could help you out if you have some more details implementation-wise.
from trafilatura.
Trafilatura actually uses a combination of several extractors so the different scores wouldn't be commensurable.
The best we could do would be to mimick a score and/or try to give back useful information about extraction quality to the user. Feel free to suggest something if you have an idea.
from trafilatura.
I thought about some options, but as you said, the combination of different extractors makes it difficult to calculate a real score.
One idea that might be feasible: Let's say you run 3 different extractors (baseline, justext, readability) and html2text for one page. Then remove all special characters such as #( ) [ ] | - _ *
, which are normally used for formatting, images, links and tables, so that only the plain text remains. The entire text is then lowercased, split into individual words and all line breaks and spaces are removed. This gives you a kind of corpus for each extractor. Then you compare the word count for each extractor with the word count of the raw text in html2text and use the difference or ratio to calculate some sort of confidence score.
You might even convert the word list of each extractor and html2text into a set to get a unique word list. This makes the comparison between extractor and html2text even more meaningful. My assumption here is that the main content of a page consists of words with a high variance. The other elements such as header, footer and navigation only have a few unique words. This means that if the number of unique words in an extractor is within a certain range of the number of unique words in the html2text extraction (e.g. 50%, 75%, etc.), the result will be more meaningful. For pages without main content, the number of words in the header, footer, navigation etc. would probably be much higher than the result of the extractor and would therefore lead to a low score.
This is of course just a naive assumption without knowing the internals of trafilatura, so please feel free to let me know if this idea is complete nonsense :-D
from trafilatura.
Interesting idea, your "words among html2text" metric probably works well if you have several webpages from the same source. Then the variance will indeed be among the main text. This is what Trafilatura's deduplication option does to some extent, it filters out recurring text segments.
I'm not sure how it would work for a single webpage (which is what the extractor is evaluated on). Postal addresses in footers add a lot of variance for example, so does a "latest articles" column.
from trafilatura.
Yes, you might be right. Even though, some pre-filtering on the raw html, like removing semantic elements (<header>
, <nav>
, <footer>
) should maybe decrease the variance a bit.
I will try to implement a small PoC the next few days/weeks, just to try out how good or bad it is. I could then use your evaluation dataset to compare the eval scores with the calculated confidence score. I assume a high eval score should correlate with a high confidence score. What do you think?
from trafilatura.
By all means, please go ahead. If everything works you'd have another extraction method and the confidence score would be a useful by-product, I'm curious to see how that goes.
from trafilatura.
@zirkelc I guess I can close this thread now that you've added the is_probably_readarable
function?
from trafilatura.
Related Issues (20)
- Regroup deduplication functions in same submodule
- Update XML-TEI reference data
- Removing related links at end of article/sidebar on news websites? HOT 2
- Wrong links position in text from telegram post HOT 2
- Extracting content from an URl is getting none HOT 1
- <main> Content gets missed out HOT 1
- focused_crawl returns nothing HOT 6
- `utils.decode_file()`: add switch for full detection or GZip only
- Add option to provide XPaths for content extraction HOT 2
- <li> tag output in TXT HOT 1
- Table markdown syntax incorrect in some cases HOT 2
- Unordered list markdown syntax is incorrect HOT 2
- Enhancement using LLM based approach HOT 1
- New port of readability.js? HOT 4
- Remove HTML doc pages from package and add instructions to build them
- It's set include_images=True, but there is no picture HOT 4
- Image/Video caption and credits removal HOT 1
- Footer removal
- trafilatura.fetch_url Timeout is set but does not work HOT 2
- Parts of article block are sometimes not being extracted HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from trafilatura.