Search a term in Japanese

我尝试了 tiny_segmenter(来自 Rubygems),至少它生成了我上一个评论中列出的词语。

# coding: utf-8
require 'tiny_segmenter'
require 'pp'

s = File.read('topic27.txt')

ts = TinySegmenter.new
sg = ts.segment(s, ignore_punctuation: true)
pp(sg)
bundle exec ruby test.rb | grep -e 北側 -e 真上 -e 一般
 "北側",
 "真上",
 "一般",
 "一般",
 "一般",
 "北側",
 "一般",

快速搜索 TinySegmenter 告诉我它使用的模型不是很好。有一个模型生成器。

不过我还没试过。

3 个赞