Giter Site home page Giter Site logo

igo-ruby's People

Contributors

bellbind avatar kyow avatar masuidrive avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

igo-ruby's Issues

Unicode が 65536 以上の文字を Igo::Tagger#parse に渡すと TypeError になる

igo-ruby を開発してくださりありがとうございます。お世話になっております。

🐘 などが含まれている文字列を Igo::Tagger#parse に渡すと、 TypeError になります。以下再現コードです。

igo_tagger = Igo::Tagger.new(dict)
igo_tagger.parse('🐘')

エラーメッセージ

TypeError: no implicit conversion from nil to integer

stacktrace

"/opt/asdf-data/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/igo-ruby-0.1.5/lib/igo/dictionary.rb:36:in `category'",
 "/opt/asdf-data/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/igo-ruby-0.1.5/lib/igo/dictionary.rb:115:in `search'",
 "/opt/asdf-data/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/igo-ruby-0.1.5/lib/igo/tagger.rb:90:in `block in impl'",
 "/opt/asdf-data/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/activesupport-6.1.6.1/lib/active_support/core_ext/range/each.rb:9:in `each'",
 "/opt/asdf-data/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/activesupport-6.1.6.1/lib/active_support/core_ext/range/each.rb:9:in `each'",
 "/opt/asdf-data/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/igo-ruby-0.1.5/lib/igo/tagger.rb:85:in `impl'",
 "/opt/asdf-data/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/igo-ruby-0.1.5/lib/igo/tagger.rb:44:in `parse'",

原因

return @categories[@char2id[code]]

この部分で TypeError になっています。
@char2id は、length が 65536 しか無いが、🐘 のコードは 128024 であり、@char2id[code] が nil になることが原因です。

解決方針

@char2id を辞書上で拡張するのが良いと思うのですが、@char2id が nil の場合はどうやっても発生しうると思うので、 nilの場合の category を定義するといいと考えています。 id=0 の category にすることを提案します。この方針で問題なければPRも作成します。

何卒よろしくお願いいたします。

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.