Git Product home page Git Product logo

ikku's Introduction

Ikku

Discover haiku from text.

Requirements

  • Ruby 2.0.0+
  • MeCab with IPADIC (e.g. brew install mecab mecab-ipadic)

Example

Ikku::Reviewer

Ikku::Reviewer class is the main interface for this library.

require "ikku"
reviewer = Ikku::Reviewer.new

Ikku::Reviewer#judge

Judge if given text is valid song or not.

reviewer.judge("古池や蛙飛び込む水の音") #=> true
reviewer.judge("ああ古池や蛙飛び込む水の音ああ") #=> false

Ikku::Reviewer#find

Find one valid song from given text.

reviewer.find("ああ古池や蛙飛び込む水の音ああ")
#=> #<Ikku::Song>

Ikku::Reviewer#search

Search all valid songs from given text.

reviewer.search("ああ古池や蛙飛び込む水の音ああ天秤や京江戸かけて千代の春ああ")
#=> [
#     #<Ikku::Song>,
#     #<Ikku::Song>,
#   ]

Ikku::Song#phrases

Return an Array of phrases of Ikku::Node.

song.phrases #=> [["古池", "や"], ["蛙", "飛び込む"], ["水", "の", "音"]]

Rule option

Pass :rule option to change the measure rule (default: [5, 7, 5]).

reviewer = Ikku::Reviewer.new(rule: [4, 3, 5])
reviewer.judge("古池や蛙飛び込む水の音") #=> false
reviewer.judge("すもももももももものうち") #=> true

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.