GithubHelp home page GithubHelp logo

python-extractcontent's Introduction

ExtractContent

ExtractContentはHTMLから本文を抽出するモジュールです。 このモジュールは同名のRubyモジュールをPython用に書き直したものです。

Usage

import extractcontent
extractor = extractcontent.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)


"""
オプションの種類:
名称 / デフォルト値

threshold / 100
本文と見なすスコアの閾値

min_length / 80
評価を行うブロック長の最小値

decay_factor / 0.73
減衰係数
小さいほど先頭に近いブロックのスコアが高くなります

continuous_factor / 1.62
連続ブロック係数
大きいほどブロックを連続と判定しにくくなる

punctuation_weight / 10
句読点に対するスコア 
大きいほど句読点が存在するブロックを本文と判定しやすくなる

punctuations / r"(?is)(\343\200[\201\202]|\357\274[\201\214\216\237]|\.[^A-Za-z0-9]|,[^0-9]|!|\?)"
句読点を抽出する正規表現

waste_expressions / r"(?i)Copyright|All Rights Reserved"
フッターに含まれる特徴的なキーワードを指定した正規表現

debug / False
Trueの場合、ブロック情報を出力
"""

Copyright of the original implementation:: (c)2007/2008/2009 Nakatani Shuyo / Cybozu labs Inc. All rights reserved

謝辞: 本モジュールは中谷氏が開発したRubyモジュール ExtractContent を基にさせていただいています。 ありがとうございます。 http://rubyforge.org/projects/extractcontent/ http://labs.cybozu.co.jp/blog/nakatani/2007/09/web_1.html

python-extractcontent's People

Contributors

yono avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.