fucoidan

Version, currently master branch1 version
  • master branchlatestJun 23, 2016

github.com/lpm11/crystal-fucoidan

crystal-mecab wrapper

1 stars
0 dependents
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  fucoidan:
    github: lpm11/crystal-fucoidan
    branch: master

master is a branch, not a release, so this tracks it rather than pinning a version.

Then run:

shards install

shard.yml

Crystal
no constraint declared
License
MIT

Dependencies

Runtime Dependencies

  • mecab*github: lpm11/crystal-mecab, branch: master

README

crystal-fucoidan Build Status License

crystal-mecab wrapper.

Usage

Make Projectfile like this to tell crystal about dependencies.

deps do
  github "lpm11/crystal-mecab"
  github "lpm11/crystal-fucoidan"
end

Run crystal deps enables us to use basic functions of MeCab in crystal like this.

require "fucoidan"

# Segments sentence into words
f = Fucoidan::Fucoidan.new("-O wakati")
puts(f.parse("すもももももももものうち")) # => すもも も もも も もも の うち

# Segments sentence into nodes
f = Fucoidan::Fucoidan.new("")
f.parse("すもももももももものうち") { |node|
  puts("#{node.surface}\t#{node.feature}")
}

# Extract noun words
words = f.enum_parse("すもももももももものうち")
         .select { |node| node.feature.starts_with?("名詞") }
         .map { |node| node.surface }
puts(words.join(", ")) # => すもも, もも, もも, うち

License

MIT