Skip to content

Commit

Permalink
Merge branch 'master' into feedparser
Browse files Browse the repository at this point in the history
  • Loading branch information
adbar authored Feb 26, 2024
2 parents 96c0dd2 + 20d291f commit f15670d
Show file tree
Hide file tree
Showing 21 changed files with 189 additions and 143 deletions.
39 changes: 19 additions & 20 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,34 +46,33 @@ Introduction
------------


Trafilatura is a cutting-edge **Python package and command-line tool** designed to **gather text on the Web and simplify the process of turning raw HTML into structured, meaningful data**. It includes all necessary discovery and text processing components to perform **web crawling, downloads, scraping, and extraction** of main texts, metadata and comments. It aims at staying **handy and modular**: no database is required, the output can be converted to multiple commonly used formats.
Trafilatura is a cutting-edge **Python package and command-line tool** designed to **gather text on the Web and simplify the process of turning raw HTML into structured, meaningful data**. It includes all necessary discovery and text processing components to perform **web crawling, downloads, scraping, and extraction** of main texts, metadata and comments. It aims at staying **handy and modular**: no database is required, the output can be converted to commonly used formats.

Smart navigation and going from HTML bulk to essential parts can alleviate many problems related to text quality, by **focusing on the actual content**, **avoiding the noise** caused by recurring elements (headers, footers etc.), **making sense of the data** with selected information. The extractor is designed to be **robust and reasonably fast**, it runs in production on millions of documents.
Going from HTML bulk to essential parts can alleviate many problems related to text quality, by **focusing on the actual content**, **avoiding the noise** caused by recurring elements (headers, footers etc.), and **making sense of the data** with selected information. The extractor is designed to be **robust and reasonably fast**, it runs in production on millions of documents.

The tool's versatility makes it **useful for quantitative and data-driven approaches**. It is used in the academic domain and beyond (e.g. in natural language processing, computational social science, search engine optimization, and information security).

The tool's versatility makes it useful for a wide range of applications leveraging web content for knowledge discovery such as **quantitative and data-driven approaches**. Trafilatura is used in the academic domain and beyond (e.g. in NLP, SEO, business analytics).

Features
~~~~~~~~

- Advanced web crawling and text discovery:
- Focused crawling adhering to politeness rules
- Support for sitemaps (TXT, XML) and feeds (ATOM, JSON, RSS)
- Smart navigation and URL management (blacklists, filtering and deduplication)
- Smart crawling and URL management (filtering and deduplication)
- Parallel processing of online and offline input:
- Live URLs, efficient and polite processing of download queues
- Previously downloaded HTML files and parsed HTML trees
- Robust and customizable extraction of key elements:
- Robust and configurable extraction of key elements:
- Main text (common patterns and generic algorithms like jusText and readability)
- Metadata (title, author, date, site name, categories and tags)
- Formatting and structure: paragraphs, titles, lists, quotes, code, line breaks, in-line text formatting
- Optional elements: comments, links, images, tables
- Extensive configuration options
- Multiple output formats:
- Text (minimal formatting or Markdown)
- CSV (with metadata, tab-separated values)
- CSV (with metadata)
- JSON (with metadata)
- XML (with metadata, text formatting and page structure) and `TEI-XML <https://tei-c.org/>`_
- Add-ons:
- XML or `XML-TEI <https://tei-c.org/>`_ (with metadata, text formatting and page structure)
- Optional add-ons:
- Language detection on extracted content
- Graphical user interface (GUI)
- Speed optimizations
Expand All @@ -87,7 +86,8 @@ Evaluation and alternatives

Trafilatura consistently outperforms other open-source libraries in text extraction benchmarks, showcasing its efficiency and accuracy in extracting web content. The extractor tries to strike a balance between limiting noise and including all valid parts.

For more detailed results see the `benchmark <https://trafilatura.readthedocs.io/en/latest/evaluation.html>`_. The results can be reproduced, see the `evaluation readme <https://github.com/adbar/trafilatura/blob/master/tests/README.rst>`_ for instructions.
For more information see the `benchmark section <https://trafilatura.readthedocs.io/en/latest/evaluation.html>`_ and the `evaluation readme <https://github.com/adbar/trafilatura/blob/master/tests/README.rst>`_ to reproduce the results.


=============================== ========= ========== ========= ========= ======
750 documents, 2236 text & 2250 boilerplate segments (2022-05-18), Python 3.8
Expand All @@ -107,6 +107,7 @@ readabilipy 0.2.0 0.877 0.870 0.874 0.874 248x
trafilatura 1.2.2 (standard) 0.914 0.904 **0.910** **0.909** 7.1x
=============================== ========= ========== ========= ========= ======


Other evaluations:
^^^^^^^^^^^^^^^^^^

Expand All @@ -125,11 +126,9 @@ Usage and documentation
- `Core Python functions <https://trafilatura.readthedocs.io/en/latest/corefunctions.html>`_
- Interactive Python Notebook: `Trafilatura Overview <docs/Trafilatura_Overview.ipynb>`_
- `Tutorials and use cases <https://trafilatura.readthedocs.io/en/latest/tutorials.html>`_
- `Text embedding for vector search <https://trafilatura.readthedocs.io/en/latest/tutorial-epsilla.html>`_
- `Custom web corpus <https://trafilatura.readthedocs.io/en/latest/tutorial0.html>`_
- `Word frequency list <https://trafilatura.readthedocs.io/en/latest/tutorial1.html>`_

For video tutorials see this Youtube playlist:

Youtube playlist with video tutorials in several languages:

- `Web scraping tutorials and how-tos <https://www.youtube.com/watch?v=8GkiOM17t0Q&list=PL-pKWbySIRGMgxXQOtGIz1-nbfYLvqrci>`_

Expand All @@ -155,15 +154,15 @@ Many thanks to the `contributors <https://github.com/adbar/trafilatura/graphs/co
Context
-------

Developed with practical applications of academic research in mind, this software is part of a broader effort to derive information from web documents. Extracting and pre-processing web texts to the exacting standards of scientific research presents a substantial challenge. Web corpus construction involves numerous design decisions, this software package simplifies text data collection and enhances corpus quality. It is currently used to build `text databases for linguistic research <https://www.dwds.de/d/k-web>`_.
Developed with practical applications of academic research in mind, this software is part of a broader effort to derive information from web documents. Extracting and pre-processing web texts to the exacting standards of scientific research presents a substantial challenge. This software package simplifies text data collection and enhances corpus quality, it is currently used to build `text databases for linguistic research <https://www.dwds.de/d/k-web>`_.

*Trafilatura* is an Italian word for `wire drawing <https://en.wikipedia.org/wiki/Wire_drawing>`_ symbolizing the industrial-grade extraction, refinement and conversion process.
*Trafilatura* is an Italian word for `wire drawing <https://en.wikipedia.org/wiki/Wire_drawing>`_ symbolizing the refinement and conversion process. It is also the way shapes of pasta are formed.


Author
~~~~~~

Reach out via the `contact page <https://adrien.barbaresi.eu/>`_ for inquiries, collaborations, or feedback. See also `Twitter/X <https://x.com/adbarbaresi>`_ for the latest updates.
Reach out via ia the software repository or the `contact page <https://adrien.barbaresi.eu/>`_ for inquiries, collaborations, or feedback. See also X or LinkedIn for the latest updates.

This work started as a PhD project at the crossroads of linguistics and NLP, this expertise has been instrumental in shaping Trafilatura over the years. It has first been released under its current form in 2019, its development is referenced in the following publications:

Expand All @@ -175,7 +174,7 @@ This work started as a PhD project at the crossroads of linguistics and NLP, thi
Citing Trafilatura
~~~~~~~~~~~~~~~~~~

Trafilatura is used in the academic domain, chiefly for data acquisition in corpus linguistics, natural language processing, and computational social science. Here is how to cite it:
Trafilatura is widely used in the academic domain, chiefly for data acquisition. Here is how to cite it:

.. image:: https://img.shields.io/badge/DOI-10.18653%2Fv1%2F2021.acl--demo.15-blue
:target: https://aclanthology.org/2021.acl-demo.15/
Expand All @@ -201,7 +200,7 @@ Trafilatura is used in the academic domain, chiefly for data acquisition in corp
Software ecosystem
~~~~~~~~~~~~~~~~~~

This software is part of a larger ecosystem. It is employed in a variety of academic and development projects, demonstrating its versatility and effectiveness. Case studies and publications are listed on the `Used By documentation page <https://trafilatura.readthedocs.io/en/latest/used-by.html>`_.
Case studies and publications are listed on the `Used By documentation page <https://trafilatura.readthedocs.io/en/latest/used-by.html>`_.

Jointly developed plugins and additional packages also contribute to the field of web data extraction and analysis:

Expand Down
17 changes: 9 additions & 8 deletions docs/evaluation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ Although text is ubiquitous on the Web, extracting information from web pages ca
The extraction focuses on the main content, which is usually the part displayed centrally, without the left or right bars, the header or the footer, but including potential titles and (optionally) comments. This task is also known as web scraping, boilerplate removal, DOM-based content extraction, main content identification, or web page cleaning.


External evaluations
--------------------

- Most efficient open-source library in *ScrapingHub*'s `article extraction benchmark <https://github.com/scrapinghub/article-extraction-benchmark>`_
- Best overall tool according to `Bien choisir son outil d'extraction de contenu à partir du Web <https://hal.archives-ouvertes.fr/hal-02768510v3/document>`_ (Lejeune & Barbaresi 2020)
- Comparison on a small `sample of Polish news texts and forums <https://github.com/tsolewski/Text_extraction_comparison_PL>`_ (now integrated in the internal benchmark, Trafilatura has improved since)
- Best single tool by ROUGE-LSum Mean F1 Page Scores in `An Empirical Comparison of Web Content Extraction Algorithms <https://webis.de/downloads/publications/papers/bevendorff_2023b.pdf>`_ (Bevendorff et al. 2023)


Alternatives
------------

Expand Down Expand Up @@ -84,14 +93,6 @@ trafilatura 1.2.2 (standard) 0.914 0.904 **0.910** **0.909** 7.1x
=============================== ========= ========== ========= ========= ======


External evaluations
--------------------

- Most efficient open-source library in *ScrapingHub*'s `article extraction benchmark <https://github.com/scrapinghub/article-extraction-benchmark>`_
- Best overall tool according to `Bien choisir son outil d'extraction de contenu à partir du Web <https://hal.archives-ouvertes.fr/hal-02768510v3/document>`_ (Lejeune & Barbaresi 2020)
- Comparison on a small `sample of Polish news texts and forums <https://github.com/tsolewski/Text_extraction_comparison_PL>`_ (now integrated in the internal benchmark, Trafilatura has improved since)
- Best single tool by ROUGE-LSum Mean F1 Page Scores in `An Empirical Comparison of Web Content Extraction Algorithms <https://webis.de/downloads/publications/papers/bevendorff_2023b.pdf>`_ (Bevendorff et al. 2023)


Older results
-------------
Expand Down
Loading

0 comments on commit f15670d

Please sign in to comment.