Giter VIP home page Giter VIP logo

Comments (9)

zirkelc avatar zirkelc commented on June 20, 2024 1

Yes, of course!

from trafilatura.

adbar avatar adbar commented on June 20, 2024

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.

zirkelc avatar zirkelc commented on June 20, 2024

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.

adbar avatar adbar commented on June 20, 2024

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.

zirkelc avatar zirkelc commented on June 20, 2024

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.

adbar avatar adbar commented on June 20, 2024

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.

zirkelc avatar zirkelc commented on June 20, 2024

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.

adbar avatar adbar commented on June 20, 2024

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.

adbar avatar adbar commented on June 20, 2024

@zirkelc I guess I can close this thread now that you've added the is_probably_readarable function?

from trafilatura.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.