GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - hatena/extract-content-javascript

BranchesTags
Open more actions menu

Latest commit

 

History

24 Commits
24 Commits

Folders and files

NameName
Last commit message
Last commit date
lib
lib
 
 
sketch
sketch
 
 
.gitignore
.gitignore
 
 
Makefile
Makefile
 
 
README.rdoc
README.rdoc
 
 

Repository files navigation

ExtractContentJS

本文抽出 JavaScript ライブラリ

やれること

  • 本文抽出

  • タグおすすめ

ファイル

基本的には以下をこの順に読み込めば動く:

lib/lib.js

共通するもの

lib/extract-content.js

本文抽出

リポジトリのルートでmake packageするとこれらを連結した extract-content-all.js が生成される.

実際の使い方を詳しく見たくなったら:

sketch/extract-content.test.js

本文抽出テスト

lib/scoring-words.js

タグのスコアリング(サンプル)

使い方

本文抽出インタフェース

本文抽出だけしたい/ハンドラを指定したい場合に使う.

ExtractContentJS.LayeredExtractor

var ex = new ExtractContentJS.LayeredExtractor();
//ex.addHandler( ex.factory.getHandler('Description') );
//ex.addHandler( ex.factory.getHandler('Scraper'));
//ex.addHandler( ex.factory.getHandler('GoogleAdsence') );
ex.addHandler( ex.factory.getHandler('Heuristics') );
var res = ex.extract(document);

if (res.isSuccess) {
    res.url;   // URL string
    res.title; // title string
    res.engine; // 抽出に用いたハンドラそのもの
    res.content; // コンテンツクラスのインスタンス(後述)
}

ハンドラはいまのところHeuristicsのみ実装済み.

コンテンツクラス

content.asLeaves(); // 本文だと判定された葉ノードを含む葉クラスインスタンス(後述)の配列を返す
content.asNode(); // すべての葉ノードの共通の祖先のうち最深のものを返す
content.asTextFragment(); // asLeaves()に含まれるノードのテキストを連結したものを返す
content.toString(); // asNode()のtextContentを返す

葉クラス

leaf.node; // 葉ノード
leaf.depth; // ノードのbodyからの深さ

AUTHOR

INA Lintaro

Copryright

Copyright © 2009 INA Lintaro / Hatena. All rights reserved.

Copyright of the original implementation

Copyright © 2007/2008 Nakatani Shuyo / Cybozu Labs Inc. All rights reserved.

  • labs.cybozu.co.jp/blog/nakatani/2007/09/web_1.html

LICENCE

MIT License

About

No description, website, or topics provided.

Resources

Readme
Activity
Custom properties

Stars

173 stars

Watchers

36 watching

Forks

19 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.