Logo Lanfrica

maiha/chawan

Domain:

natural language processing

Record type:

software
Creator:
mai
Host:
A cup for chasen that provides an easy to use for extracting Japanese chawan ====== A cup for chasen that provides an easy to use for extracting Japanese Methods ======= * Chawan.parse(text) parse the given text by analyzer, where default analyzer is :mecab * Chawan.analyzer(xxx) (same as Chawan[xxx], Chawan.xxx) specify analyzer Class ===== * Chawan::Nodes (Chawan.parse returns a Chawan::Nodes) #noun : scope category with noun #verb : scope category with verb #grep : scope category with given pattern #compact : mix the category-consecutive nodes * Chawan::Node (Chawan::Nodes has many Chawan::Node(s)) #category : part of speech #word : text #attributes : keys and vals hash Example ======= text = '登録された利用者' # 'parse' returns a Chawan::Nodes Chawan.parse(text) => [ , , , , , ] # Chawan::Nodes is enumerable Chawan.parse(text).select{|node| node.category == '名詞'} => [ , , ] # gateway interface: noun Chawan.parse(text).noun => [ , , ] # gateway interface: verb Chawan.parse(text).verb => [ , , ] # gateway interface: grep Chawan.parse(text).grep(/動詞/) => [ , , ] Chawan.parse(text).grep('動詞') => [ , ] # gateway interface: compact Chawan.parse(text).compact => [ , , , ] Chawan.parse(text).compact(/動詞/) => [ , , , ] # gateway interface is chainable Chawan.parse(text).noun.verb => [] # chainable is fun! Chawan.parse(text).noun => [ , , ] Chawan.parse(text).compact.noun => [ , ] Chawan.parse(text).noun.compact => [ ] Analyzer ======== Parser engine is defined as 'analyzer'. Available analyzers are: * mecab : (default) * chasen Chawan[:mecab].parse('test') => [ ] # same as # Chawan.mecab.parse('test') # Chawan.analyzer(:mecab).parse('test') # Chawan.parse('test') # default analyzer is :mecab Chawan[:chasen].parse('test') => [ , , , ] Required ======== * UTF-8 * 'mecab' unix command (and its path) Todo ==== * use open3 rather than backquote for executing unix commands Author ====== maiha@wota.jp