jusText 3.0.2__tar.gz → 4.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. justext-4.0.0/CHANGELOG.md +66 -0
  2. justext-4.0.0/PKG-INFO +126 -0
  3. justext-4.0.0/README.md +91 -0
  4. {justext-3.0.2 → justext-4.0.0}/justext/__init__.py +1 -1
  5. {justext-3.0.2 → justext-4.0.0}/justext/__main__.py +12 -3
  6. {justext-3.0.2 → justext-4.0.0}/justext/_compat.py +7 -0
  7. {justext-3.0.2 → justext-4.0.0}/justext/core.py +121 -52
  8. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Arabic.txt +0 -9
  9. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Armenian.txt +0 -35
  10. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Belarusian.txt +0 -39
  11. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Belarusian_Taraskievica.txt +0 -39
  12. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Bengali.txt +0 -5
  13. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Bulgarian.txt +0 -22
  14. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Chuvash.txt +0 -32
  15. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Georgian.txt +0 -97
  16. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Greek.txt +0 -5
  17. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Gujarati.txt +0 -11
  18. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Hebrew.txt +0 -15
  19. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Hindi.txt +0 -8
  20. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Kannada.txt +0 -107
  21. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Kazakh.txt +0 -13
  22. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Korean.txt +0 -175
  23. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Kyrgyz.txt +0 -10
  24. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Macedonian.txt +0 -10
  25. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Malayalam.txt +0 -64
  26. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Marathi.txt +0 -364
  27. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Nepali.txt +0 -169
  28. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Newar.txt +0 -1
  29. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Russian.txt +0 -63
  30. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Slovak.txt +2238 -3444
  31. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Tamil.txt +0 -68
  32. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Telugu.txt +0 -143
  33. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Ukrainian.txt +0 -40
  34. {justext-3.0.2 → justext-4.0.0}/justext/utils.py +5 -2
  35. justext-4.0.0/pyproject.toml +83 -0
  36. justext-4.0.0/pyproject.toml.orig +77 -0
  37. justext-3.0.2/CHANGELOG.rst +0 -57
  38. justext-3.0.2/MANIFEST.in +0 -4
  39. justext-3.0.2/PKG-INFO +0 -212
  40. justext-3.0.2/README.rst +0 -109
  41. justext-3.0.2/jusText.egg-info/PKG-INFO +0 -212
  42. justext-3.0.2/jusText.egg-info/SOURCES.txt +0 -124
  43. justext-3.0.2/jusText.egg-info/dependency_links.txt +0 -1
  44. justext-3.0.2/jusText.egg-info/requires.txt +0 -4
  45. justext-3.0.2/jusText.egg-info/top_level.txt +0 -1
  46. justext-3.0.2/setup.cfg +0 -19
  47. justext-3.0.2/setup.py +0 -66
  48. justext-3.0.2/tests/test_classify_paragraphs.py +0 -88
  49. justext-3.0.2/tests/test_core.py +0 -7
  50. justext-3.0.2/tests/test_dom_utils.py +0 -163
  51. justext-3.0.2/tests/test_html_encoding.py +0 -134
  52. justext-3.0.2/tests/test_paths.py +0 -81
  53. justext-3.0.2/tests/test_sax.py +0 -214
  54. justext-3.0.2/tests/test_utils.py +0 -94
  55. {justext-3.0.2 → justext-4.0.0}/LICENSE.rst +0 -0
  56. {justext-3.0.2 → justext-4.0.0}/justext/paragraph.py +0 -0
  57. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Afrikaans.txt +0 -0
  58. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Albanian.txt +0 -0
  59. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Aragonese.txt +0 -0
  60. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Aromanian.txt +0 -0
  61. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Asturian.txt +0 -0
  62. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Azerbaijani.txt +0 -0
  63. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Basque.txt +0 -0
  64. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Bishnupriya_Manipuri.txt +0 -0
  65. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Bosnian.txt +0 -0
  66. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Breton.txt +0 -0
  67. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Catalan.txt +0 -0
  68. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Cebuano.txt +0 -0
  69. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Croatian.txt +0 -0
  70. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Czech.txt +0 -0
  71. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Danish.txt +0 -0
  72. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Dutch.txt +0 -0
  73. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/English.txt +0 -0
  74. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Esperanto.txt +0 -0
  75. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Estonian.txt +0 -0
  76. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Finnish.txt +0 -0
  77. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/French.txt +0 -0
  78. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Galician.txt +0 -0
  79. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/German.txt +0 -0
  80. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Haitian.txt +0 -0
  81. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Hungarian.txt +0 -0
  82. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Icelandic.txt +0 -0
  83. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Ido.txt +0 -0
  84. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Igbo.txt +0 -0
  85. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Indonesian.txt +0 -0
  86. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Irish.txt +0 -0
  87. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Italian.txt +0 -0
  88. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Javanese.txt +0 -0
  89. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Kurdish.txt +0 -0
  90. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Latin.txt +0 -0
  91. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Latvian.txt +0 -0
  92. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Lithuanian.txt +0 -0
  93. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Lombard.txt +0 -0
  94. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Low_Saxon.txt +0 -0
  95. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Luxembourgish.txt +0 -0
  96. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Malay.txt +0 -0
  97. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Maltese.txt +0 -0
  98. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Neapolitan.txt +0 -0
  99. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Norwegian_Bokmal.txt +0 -0
  100. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Norwegian_Nynorsk.txt +0 -0
  101. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Occitan.txt +0 -0
  102. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Persian.txt +0 -0
  103. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Piedmontese.txt +0 -0
  104. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Polish.txt +0 -0
  105. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Portuguese.txt +0 -0
  106. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Quechua.txt +0 -0
  107. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Romanian.txt +0 -0
  108. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Samogitian.txt +0 -0
  109. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Serbian.txt +0 -0
  110. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Serbo_Croatian.txt +0 -0
  111. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Sicilian.txt +0 -0
  112. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Simple_English.txt +0 -0
  113. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Slovenian.txt +0 -0
  114. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Spanish.txt +0 -0
  115. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Sundanese.txt +0 -0
  116. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Swahili.txt +0 -0
  117. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Swedish.txt +0 -0
  118. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Tagalog.txt +0 -0
  119. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Turkish.txt +0 -0
  120. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Turkmen.txt +0 -0
  121. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Urdu.txt +0 -0
  122. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Uzbek.txt +0 -0
  123. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Vietnamese.txt +0 -0
  124. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Volapuk.txt +0 -0
  125. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Walloon.txt +0 -0
  126. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Waray_Waray.txt +0 -0
  127. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Welsh.txt +0 -0
  128. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/West_Frisian.txt +0 -0
  129. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Western_Panjabi.txt +0 -0
  130. {justext-3.0.2 → justext-4.0.0}/justext/stoplists/Yoruba.txt +0 -0
@@ -0,0 +1,66 @@
1
+ # Changelog
2
+
3
+ ## Unreleased
4
+
5
+ ## 4.0.0 (2026-12-01)
6
+ - **INCOMPATIBLE CHANGE:** Requires Python 3.8 or newer. pip on older Pythons keeps installing 3.0.2.
7
+ - **FEATURE:** Officially support Python 3.10 to 3.15. Python 3.9 and below still work but are no longer tested in CI.
8
+ - **BUG FIX:** Respect UTF-8 and UTF-16 byte order marks when decoding HTML [#55](https://github.com/miso-belica/jusText/pull/55).
9
+ - **BUG FIX:** BOM characters (U+FEFF, U+FFFE) inside the text are treated as white-space.
10
+ - **BUG FIX:** Respect UTF-32 byte order marks when decoding HTML [#63](https://github.com/miso-belica/jusText/pull/63). A UTF-16 LE document whose first character after the BOM is U+0000 starts with the same bytes, so it is now decoded as UTF-32.
11
+ - **BUG FIX:** `decode_html()` with `errors="strict"` raises `JustextDecodeError` (both `JustextError` and `UnicodeDecodeError`) in every branch, not only in the fallback [#56](https://github.com/miso-belica/jusText/issues/56).
12
+ - **BUG FIX:** `<footer>` elements are removed before paragraph extraction, except a `<footer>` inside `<blockquote>` holding a quote attribution.
13
+ - **BUG FIX:** `<nav>` elements are removed before paragraph extraction.
14
+ - **BUG FIX:** `<figcaption>` starts a new paragraph, so a caption is no longer glued to the text following the `<figure>` element.
15
+ - **BUG FIX:** A paragraph containing the copyright symbol is demoted by one class instead of being rejected outright.
16
+ - **FEATURE:** New parameter `max_good_distance` (CLI `--max-good-distance`) can limit how far, in paragraphs, the context-sensitive classification looks for a good neighbouring paragraph. There is no limit by default, so the whole document is searched as before.
17
+ - **BUG FIX:** Context-sensitive classification takes linear time, pages with tens of thousands of short paragraphs no longer take minutes [#43](https://github.com/miso-belica/jusText/issues/43).
18
+ - **INCOMPATIBLE CHANGE:** Removed `get_prev_neighbour()` and `get_next_neighbour()` from `justext.core`. They were internal helpers of `revise_paragraph_classification()`.
19
+ - **BUG FIX:** Removed Latin-script words (English words, Roman numerals, wiki markup) from the stop-lists of non-Latin-script languages. Serbian is left as is, since it is written in both scripts.
20
+ - **BUG FIX:** Decode `<meta charset>` like browsers do, e.g. `iso-8859-1` as `windows-1252`, and bytes undefined in `windows-125x` as C1 controls [#58](https://github.com/miso-belica/jusText/issues/58).
21
+ - **BUG FIX:** Respect the encoding from the XML declaration of XHTML pages, e.g. `<?xml version="1.0" encoding="iso-8859-2"?>` [#26](https://github.com/miso-belica/jusText/issues/26).
22
+ - **BUG FIX:** A *short* heading close before *good* text is *near-good* again during context-sensitive classification, so *short* blocks around it are kept as documented. Broken since 3.0.0.
23
+
24
+ ## 3.0.2 (2025-02-25)
25
+ - **BUG FIX:** Handle urllib imports in Python 2 and 3 correctly [#51](https://github.com/miso-belica/jusText/pull/51).
26
+
27
+ ## 3.0.1 (2024-05-09)
28
+ - **BUG FIX:** Fix issue with new version of lxml [#48](https://github.com/miso-belica/jusText/pull/48).
29
+
30
+ ## 3.0.0 (2021-10-21)
31
+ - **INCOMPATIBLE CHANGE:** Dropped support for Python 3.4 and below.
32
+ - **BUG FIX:** Don't join words separated only by `<br>` tag.
33
+ - **BUG FIX:** List available stop-lists alphabetically.
34
+
35
+ ## 2.2.0 (2016-03-06)
36
+ - **INCOMPATIBLE CHANGE:** Stop words are case insensitive.
37
+ - **INCOMPATIBLE CHANGE:** Dropped support for Python 3.2
38
+ - **BUG FIX:** Preserve new lines from original text in paragraphs.
39
+
40
+ ## 2.1.1 (2014-05-27)
41
+ - **BUG FIX:** Function `decode_html` now respects parameter `errors` when falling to `default_encoding` [#9](https://github.com/miso-belica/jusText/issues/9).
42
+
43
+ ## 2.1.0 (2014-01-25)
44
+ - **FEATURE:** Added XPath selector to the paragrahs. XPath selector is also available in detailed output as `xpath` attribute of `<p>` tag [#5](https://github.com/miso-belica/jusText/pull/5).
45
+
46
+ ## 2.0.0 (2013-08-26)
47
+ - **FEATURE:** Added pluggable DOM preprocessor.
48
+ - **FEATURE:** Added support for Python 3.2+.
49
+ - **INCOMPATIBLE CHANGE:** Paragraphs are instances of
50
+ `justext.paragraph.Paragraph`.
51
+ - **INCOMPATIBLE CHANGE:** Script 'justext' removed in favour of
52
+ command `python -m justext`.
53
+ - **FEATURE:** It's possible to enter an URI as input document in CLI.
54
+ - **FEATURE:** It is possible to pass unicode string directly.
55
+
56
+ ## 1.2.0 (2011-08-08)
57
+ - **FEATURE:** Character counts used instead of word counts where possible in
58
+ order to make the algorithm work well in the language independent
59
+ mode (without a stoplist) for languages where counting words is
60
+ not easy (Japanese, Chinese, Thai, etc).
61
+ - **BUG FIX:** More robust parsing of meta tags containing the information about
62
+ used charset.
63
+ - **BUG FIX:** Corrected decoding of HTML entities &#128; to &#159;
64
+
65
+ ## 1.1.0 (2011-03-09)
66
+ - First public release.
justext-4.0.0/PKG-INFO ADDED
@@ -0,0 +1,126 @@
1
+ Metadata-Version: 2.4
2
+ Name: jusText
3
+ Version: 4.0.0
4
+ Summary: Heuristic based boilerplate removal tool
5
+ Author: Jan Pomikálek
6
+ Author-email: Jan Pomikálek <jan.pomikalek@gmail.com>
7
+ License-Expression: BSD-2-Clause
8
+ License-File: LICENSE.rst
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Natural Language :: English
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Programming Language :: Python :: 3.15
23
+ Classifier: Programming Language :: Python :: Implementation :: CPython
24
+ Classifier: Topic :: Internet :: WWW/HTTP
25
+ Classifier: Topic :: Software Development :: Pre-processors
26
+ Classifier: Topic :: Text Processing :: Filters
27
+ Classifier: Topic :: Text Processing :: Markup :: HTML
28
+ Requires-Dist: lxml[html-clean]>=4.4.2
29
+ Maintainer: Michal Belica
30
+ Maintainer-email: Michal Belica <miso.belica@gmail.com>
31
+ Requires-Python: >=3.8
32
+ Project-URL: Homepage, https://github.com/miso-belica/jusText
33
+ Project-URL: Repository, https://github.com/miso-belica/jusText
34
+ Description-Content-Type: text/markdown
35
+
36
+ # jusText
37
+
38
+ [![Run tests](https://github.com/miso-belica/jusText/actions/workflows/run-tests.yml/badge.svg)](https://github.com/miso-belica/jusText/actions/workflows/run-tests.yml)
39
+
40
+ Program jusText is a tool for removing boilerplate content, such as navigation
41
+ links, headers, and footers from HTML pages. It is
42
+ [designed](doc/algorithm.rst) to preserve
43
+ mainly text containing full sentences and it is therefore well suited for
44
+ creating linguistic resources such as Web corpora. You can
45
+ [try it online](http://nlp.fi.muni.cz/projects/justext/).
46
+
47
+ This is a fork of original (currently unmaintained) code of [jusText](http://code.google.com/p/justext/) hosted
48
+ on Google Code.
49
+
50
+ Adaptations of the algorithm to other languages:
51
+
52
+ - [C++](https://github.com/endredy/jusText)
53
+ - [Go](https://github.com/JalfResi/justext)
54
+ - [Java](https://github.com/wizenoze/justext-java)
55
+ - [Javascript](https://github.com/smodin-io/justext)
56
+
57
+ Some libraries using jusText:
58
+
59
+ - [chirp](https://github.com/9b/chirp)
60
+ - [lazynlp](https://github.com/chiphuyen/lazynlp)
61
+ - [off-topic-memento-toolkit](https://github.com/oduwsdl/off-topic-memento-toolkit)
62
+ - [pears](https://github.com/PeARSearch/PeARS-orchard)
63
+ - [readability calculator](https://github.com/joaopalotti/readability_calculator)
64
+ - [sky](https://github.com/kootenpv/sky)
65
+
66
+ Some currently (Jan 2020) maintained alternatives:
67
+
68
+ - [dragnet](https://github.com/dragnet-org/dragnet)
69
+ - [html2text](https://github.com/Alir3z4/html2text)
70
+ - [inscriptis](https://github.com/weblyzard/inscriptis)
71
+ - [newspaper](https://github.com/codelucas/newspaper)
72
+ - [python-readability](https://github.com/buriy/python-readability)
73
+ - [trafilatura](https://github.com/adbar/trafilatura)
74
+
75
+ ## Installation
76
+
77
+ Make sure you have [Python](http://www.python.org/) 3.8+ and [pip](https://pip.pypa.io/en/stable/)
78
+ ([Windows](http://docs.python-guide.org/en/latest/starting/install/win/),
79
+ [Linux](http://docs.python-guide.org/en/latest/starting/install/linux/)) installed.
80
+ Run simply:
81
+
82
+ ```bash
83
+ $ pip install justext
84
+ ```
85
+
86
+ ## Dependencies
87
+
88
+ ```
89
+ lxml (version depends on your Python version)
90
+ ```
91
+
92
+ ## Usage
93
+
94
+ ```bash
95
+ $ python -m justext -s Czech -o text.txt http://www.zdrojak.cz/clanky/automaticke-zabezpeceni/
96
+ $ python -m justext -s English -o plain_text.txt english_page.html
97
+ $ python -m justext --help # for more info
98
+ ```
99
+
100
+ ## Python API
101
+
102
+ ```python
103
+ import requests
104
+ import justext
105
+
106
+ response = requests.get("http://planet.python.org/")
107
+ paragraphs = justext.justext(response.content, justext.get_stoplist("English"))
108
+ for paragraph in paragraphs:
109
+ if not paragraph.is_boilerplate:
110
+ print(paragraph.text)
111
+ ```
112
+
113
+ ## Development
114
+
115
+ Install [uv](https://docs.astral.sh/uv/) and run tests and the linter via
116
+
117
+ ```bash
118
+ $ uv run pytest
119
+ $ uv run ruff check
120
+ ```
121
+
122
+ ## Acknowledgements
123
+
124
+ This software has been developed at the [Natural Language Processing Centre](http://nlp.fi.muni.cz/en/nlpc) of
125
+ [Masaryk University in Brno](http://nlp.fi.muni.cz/en) with a financial support from [PRESEMT](http://presemt.eu/) and
126
+ [Lexical Computing Ltd.](http://lexicalcomputing.com/) It also relates to [PhD research](http://is.muni.cz/th/45523/fi_d/phdthesis.pdf) of Jan Pomikálek.
@@ -0,0 +1,91 @@
1
+ # jusText
2
+
3
+ [![Run tests](https://github.com/miso-belica/jusText/actions/workflows/run-tests.yml/badge.svg)](https://github.com/miso-belica/jusText/actions/workflows/run-tests.yml)
4
+
5
+ Program jusText is a tool for removing boilerplate content, such as navigation
6
+ links, headers, and footers from HTML pages. It is
7
+ [designed](doc/algorithm.rst) to preserve
8
+ mainly text containing full sentences and it is therefore well suited for
9
+ creating linguistic resources such as Web corpora. You can
10
+ [try it online](http://nlp.fi.muni.cz/projects/justext/).
11
+
12
+ This is a fork of original (currently unmaintained) code of [jusText](http://code.google.com/p/justext/) hosted
13
+ on Google Code.
14
+
15
+ Adaptations of the algorithm to other languages:
16
+
17
+ - [C++](https://github.com/endredy/jusText)
18
+ - [Go](https://github.com/JalfResi/justext)
19
+ - [Java](https://github.com/wizenoze/justext-java)
20
+ - [Javascript](https://github.com/smodin-io/justext)
21
+
22
+ Some libraries using jusText:
23
+
24
+ - [chirp](https://github.com/9b/chirp)
25
+ - [lazynlp](https://github.com/chiphuyen/lazynlp)
26
+ - [off-topic-memento-toolkit](https://github.com/oduwsdl/off-topic-memento-toolkit)
27
+ - [pears](https://github.com/PeARSearch/PeARS-orchard)
28
+ - [readability calculator](https://github.com/joaopalotti/readability_calculator)
29
+ - [sky](https://github.com/kootenpv/sky)
30
+
31
+ Some currently (Jan 2020) maintained alternatives:
32
+
33
+ - [dragnet](https://github.com/dragnet-org/dragnet)
34
+ - [html2text](https://github.com/Alir3z4/html2text)
35
+ - [inscriptis](https://github.com/weblyzard/inscriptis)
36
+ - [newspaper](https://github.com/codelucas/newspaper)
37
+ - [python-readability](https://github.com/buriy/python-readability)
38
+ - [trafilatura](https://github.com/adbar/trafilatura)
39
+
40
+ ## Installation
41
+
42
+ Make sure you have [Python](http://www.python.org/) 3.8+ and [pip](https://pip.pypa.io/en/stable/)
43
+ ([Windows](http://docs.python-guide.org/en/latest/starting/install/win/),
44
+ [Linux](http://docs.python-guide.org/en/latest/starting/install/linux/)) installed.
45
+ Run simply:
46
+
47
+ ```bash
48
+ $ pip install justext
49
+ ```
50
+
51
+ ## Dependencies
52
+
53
+ ```
54
+ lxml (version depends on your Python version)
55
+ ```
56
+
57
+ ## Usage
58
+
59
+ ```bash
60
+ $ python -m justext -s Czech -o text.txt http://www.zdrojak.cz/clanky/automaticke-zabezpeceni/
61
+ $ python -m justext -s English -o plain_text.txt english_page.html
62
+ $ python -m justext --help # for more info
63
+ ```
64
+
65
+ ## Python API
66
+
67
+ ```python
68
+ import requests
69
+ import justext
70
+
71
+ response = requests.get("http://planet.python.org/")
72
+ paragraphs = justext.justext(response.content, justext.get_stoplist("English"))
73
+ for paragraph in paragraphs:
74
+ if not paragraph.is_boilerplate:
75
+ print(paragraph.text)
76
+ ```
77
+
78
+ ## Development
79
+
80
+ Install [uv](https://docs.astral.sh/uv/) and run tests and the linter via
81
+
82
+ ```bash
83
+ $ uv run pytest
84
+ $ uv run ruff check
85
+ ```
86
+
87
+ ## Acknowledgements
88
+
89
+ This software has been developed at the [Natural Language Processing Centre](http://nlp.fi.muni.cz/en/nlpc) of
90
+ [Masaryk University in Brno](http://nlp.fi.muni.cz/en) with a financial support from [PRESEMT](http://presemt.eu/) and
91
+ [Lexical Computing Ltd.](http://lexicalcomputing.com/) It also relates to [PhD research](http://is.muni.cz/th/45523/fi_d/phdthesis.pdf) of Jan Pomikálek.
@@ -12,4 +12,4 @@ from .utils import get_stoplists, get_stoplist
12
12
  from .core import justext
13
13
 
14
14
 
15
- __version__ = "3.0.2"
15
+ __version__ = "4.0.0"
@@ -58,6 +58,7 @@ Advanced options:
58
58
  --stopwords-high=FLOAT (default %(stopwords_high)f)
59
59
  --max-link-density=FLOAT (default %(max_link_density)f)
60
60
  --max-heading-distance=INT (default %(max_heading_distance)i)
61
+ --max-good-distance=INT (default no limit)
61
62
  """ % {
62
63
  'progname': os.path.basename(os.path.basename(sys.argv[0])),
63
64
  'length_low': LENGTH_LOW_DEFAULT,
@@ -142,7 +143,7 @@ def main():
142
143
  "enc-force", "enc-errors=", "format=",
143
144
  "no-headings", "help", "version", "length-low=", "length-high=",
144
145
  "stopwords-low=", "stopwords-high=", "max-link-density=",
145
- "max-heading-distance=", "list-stoplists"])
146
+ "max-heading-distance=", "max-good-distance=", "list-stoplists"])
146
147
  except getopt.GetoptError as e:
147
148
  print(e, file=sys.stderr)
148
149
  print(usage(), file=sys.stderr)
@@ -163,6 +164,7 @@ def main():
163
164
  stopwords_high = STOPWORDS_HIGH_DEFAULT
164
165
  max_link_density = MAX_LINK_DENSITY_DEFAULT
165
166
  max_heading_distance = MAX_HEADING_DISTANCE_DEFAULT
167
+ max_good_distance = MAX_GOOD_DISTANCE_DEFAULT
166
168
  encoding = None
167
169
  default_encoding = DEFAULT_ENCODING
168
170
  force_default_encoding = False
@@ -193,7 +195,7 @@ def main():
193
195
  if os.path.isfile(a):
194
196
  try:
195
197
  fp_stoplist = codecs.open(a, 'r', 'utf8')
196
- stoplist = set([l.strip() for l in fp_stoplist])
198
+ stoplist = set([line.strip() for line in fp_stoplist])
197
199
  fp_stoplist.close()
198
200
  except IOError as e:
199
201
  raise JustextInvalidOptions(
@@ -270,6 +272,12 @@ def main():
270
272
  except ValueError:
271
273
  raise JustextInvalidOptions(
272
274
  "Invalid value for %s: '%s'. Integer expected." % (o, a))
275
+ elif o == "--max-good-distance":
276
+ try:
277
+ max_good_distance = int(a)
278
+ except ValueError:
279
+ raise JustextInvalidOptions(
280
+ "Invalid value for %s: '%s'. Integer expected." % (o, a))
273
281
 
274
282
  if force_default_encoding:
275
283
  encoding = default_encoding
@@ -298,7 +306,8 @@ def main():
298
306
 
299
307
  paragraphs = justext(html_text, stoplist, length_low, length_high,
300
308
  stopwords_low, stopwords_high, max_link_density, max_heading_distance,
301
- no_headings, encoding, default_encoding, enc_errors)
309
+ no_headings, encoding, default_encoding, enc_errors,
310
+ max_good_distance=max_good_distance)
302
311
  if format == "default":
303
312
  output_default(paragraphs, fp_out)
304
313
  elif format == "boilerplate":
@@ -18,6 +18,13 @@ else:
18
18
  string_types = (bytes, unicode,)
19
19
 
20
20
 
21
+ # zip must be lazy, Python 2 zip builds the whole list
22
+ try:
23
+ from itertools import izip as zip
24
+ except ImportError:
25
+ zip = zip
26
+
27
+
21
28
  if PY3:
22
29
  import urllib.request as urllib
23
30
  from urllib.error import URLError