ExtractContent for Python 3
Project description
ExtractContent3
===============
.. image:: https://img.shields.io/badge/License-BSD%202--Clause-orange.svg
:target: https://opensource.org/licenses/BSD-2-Clause
.. image:: https://img.shields.io/badge/python-3.6-blue.svg
.. image:: https://travis-ci.org/kanjirz50/python-extractcontent3.svg?branch=master
:target: https://travis-ci.org/kanjirz50/python-extractcontent3
ExtractContent3はPython3で動作する、HTMLから本文を抽出するモジュールです。
このモジュールは、ExtractContent RubyモジュールをPython用に書き直したpython-extracontentを改造したものです。
Usage
------------
.. code-block:: python
from extractcontent3 import ExtractContent
extractor = ExtractContent()
# オプション値を指定する
opt = {"threshold":50}
extractor.set_default(opt)
html = open("index.html").read() # 解析対象HTML
extractor.analyse(html)
text, title = extractor.as_text()
html, title = extractor.as_html()
title = extractor.extract_title(html)
Installation
------------
.. code-block:: bash
# pypi
$ pip install extractcontent3
# Githubからのインストール
$ pip install git+https://github.com/kanjirz50/python-extractcontent3
Option
-------------
.. code-block:: python
"""
オプションの種類:
名称 / デフォルト値
threshold / 100
本文と見なすスコアの閾値
min_length / 80
評価を行うブロック長の最小値
decay_factor / 0.73
減衰係数
小さいほど先頭に近いブロックのスコアが高くなります
continuous_factor / 1.62
連続ブロック係数
大きいほどブロックを連続と判定しにくくなる
punctuation_weight / 10
句読点に対するスコア
大きいほど句読点が存在するブロックを本文と判定しやすくなる
punctuations r"(?is)([\u3001\u3002\uff01\uff0c\uff0e\uff1f]|\.[^A-Za-z0-9]|,[^0-9]|!|\?)"
句読点を抽出する正規表現
waste_expressions / r"(?i)Copyright|All Rights Reserved"
フッターに含まれる特徴的なキーワードを指定した正規表現
debug / False
Trueの場合、ブロック情報を出力
"""
謝辞
----
オリジナル版の作成者やForkで改良を加えた方々に感謝します。
- Copyright of the original implementation:: (c)2007/2008/2009 Nakatani Shuyo / Cybozu labs Inc. All rights reserved
- http://rubyforge.org/projects/extractcontent/
- http://labs.cybozu.co.jp/blog/nakatani/2007/09/web_1.html
- https://github.com/petitviolet/python-extractcontent
- https://github.com/yono/python-extractcontent
===============
.. image:: https://img.shields.io/badge/License-BSD%202--Clause-orange.svg
:target: https://opensource.org/licenses/BSD-2-Clause
.. image:: https://img.shields.io/badge/python-3.6-blue.svg
.. image:: https://travis-ci.org/kanjirz50/python-extractcontent3.svg?branch=master
:target: https://travis-ci.org/kanjirz50/python-extractcontent3
ExtractContent3はPython3で動作する、HTMLから本文を抽出するモジュールです。
このモジュールは、ExtractContent RubyモジュールをPython用に書き直したpython-extracontentを改造したものです。
Usage
------------
.. code-block:: python
from extractcontent3 import ExtractContent
extractor = ExtractContent()
# オプション値を指定する
opt = {"threshold":50}
extractor.set_default(opt)
html = open("index.html").read() # 解析対象HTML
extractor.analyse(html)
text, title = extractor.as_text()
html, title = extractor.as_html()
title = extractor.extract_title(html)
Installation
------------
.. code-block:: bash
# pypi
$ pip install extractcontent3
# Githubからのインストール
$ pip install git+https://github.com/kanjirz50/python-extractcontent3
Option
-------------
.. code-block:: python
"""
オプションの種類:
名称 / デフォルト値
threshold / 100
本文と見なすスコアの閾値
min_length / 80
評価を行うブロック長の最小値
decay_factor / 0.73
減衰係数
小さいほど先頭に近いブロックのスコアが高くなります
continuous_factor / 1.62
連続ブロック係数
大きいほどブロックを連続と判定しにくくなる
punctuation_weight / 10
句読点に対するスコア
大きいほど句読点が存在するブロックを本文と判定しやすくなる
punctuations r"(?is)([\u3001\u3002\uff01\uff0c\uff0e\uff1f]|\.[^A-Za-z0-9]|,[^0-9]|!|\?)"
句読点を抽出する正規表現
waste_expressions / r"(?i)Copyright|All Rights Reserved"
フッターに含まれる特徴的なキーワードを指定した正規表現
debug / False
Trueの場合、ブロック情報を出力
"""
謝辞
----
オリジナル版の作成者やForkで改良を加えた方々に感謝します。
- Copyright of the original implementation:: (c)2007/2008/2009 Nakatani Shuyo / Cybozu labs Inc. All rights reserved
- http://rubyforge.org/projects/extractcontent/
- http://labs.cybozu.co.jp/blog/nakatani/2007/09/web_1.html
- https://github.com/petitviolet/python-extractcontent
- https://github.com/yono/python-extractcontent
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
extractcontent3-0.0.2.tar.gz
(5.6 kB
view hashes)
Built Distribution
Close
Hashes for extractcontent3-0.0.2-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 480f3cb7a9f41e75a0d07b6c942d2ba01167fbb0b3861b20e612cc4eeb7230e2 |
|
MD5 | 3aba9d9bd537410d46738f65756206c9 |
|
BLAKE2b-256 | 554673a84dc2652075a58e5eb34a541c7abcdb32b061116a488fd47c2920d490 |