Giter VIP home page Giter VIP logo

sengiri's Introduction

sengiri

travis-ci.org coveralls.io pyversion latest version license

Yet another sentence-level tokenizer for the Japanese text

DEPENDENCIES

  • MeCab
  • emoji

INSTALLATION

$ pip install sengiri

USAGE

import sengiri

print(sengiri.tokenize('うーん🤔🤔🤔どうしよう'))
#=>['うーん🤔🤔🤔', 'どうしよう']
print(sengiri.tokenize('モー娘。のコンサートに行った。'))
#=>['モー娘。のコンサートに行った。']
print(sengiri.tokenize('ありがとう^^ 助かります。'))
#=>['ありがとう^^', '助かります。']
print(sengiri.tokenize('顔文字テスト(*´ω`*)うまくいくかな?'))
#=>['顔文字テスト(*´ω`*)うまくいくかな?']
# I recommend using the NEologd dictionary.
print(sengiri.tokenize('顔文字テスト(*´ω`*)うまくいくかな?', mecab_args='-d /usr/local/lib/mecab/dic/mecab-ipadic-neologd'))
#=>['顔文字テスト(*´ω`*)', 'うまくいくかな?']
print(sengiri.tokenize('子供が大変なことになった。'
                       '(後で聞いたのだが、脅されたらしい)'
                       '(脅迫はやめてほしいと言っているのに)'))
#=>['子供が大変なことになった。', '(後で聞いたのだが、脅されたらしい)', '(脅迫はやめてほしいと言っているのに)']
print(sengiri.tokenize('楽しかったw また遊ぼwww'))
#=>['楽しかったw', 'また遊ぼwww']
print(sengiri.tokenize('http://www.inpaku.go.jp/'))
#=>['http://www.inpaku.go.jp/']

sengiri's People

Contributors

hiroshi-manabe avatar ikegami-yukino avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

sengiri's Issues

Can't tokenize

Hi there! I can't tokenize the sentence, and raised error "ValueError: too many values to unpack (expected 2)"
Im just try this code :

print(sengiri.tokenize('遅刻したけど楽しかったし嬉しかった。すごく充実した!'))

and surface this error

AttributeError: module 'emoji' has no attribute 'UNICODE_EMOJI'

Problem Description

When I tried to use the sengiri, and tried to execute the code, The error came out.

Code

$ pip install sengiri
import sengiri
print(sengiri.tokenize('うーん🤔🤔🤔どうしよう'))

Error message:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In [31], line 1
----> 1 import sengiri
      2 print(sengiri.tokenize('うーん🤔🤔🤔どうしよう'))

File ~/anaconda3/lib/python3.9/site-packages/sengiri/__init__.py:2
      1 # -*- coding: utf-8 -*-
----> 2 from .sengiri import tokenize
      3 """sengiri
      4 
      5 This module provides the Japanese sentence-level tokenizer.
   (...)
     11     MIT License
     12 """
     14 VERSION = (0, 2, 1)

File ~/anaconda3/lib/python3.9/site-packages/sengiri/sengiri.py:6
      3 import emoji
      4 import MeCab
----> 6 EMOJIS = set(emoji.UNICODE_EMOJI.keys())
      7 DELIMITERS = set({'。', '.', '…', '・・・', '...', '!',
      8                   '!', '?', '?', '!?', '?!', '!?', '?!'})
      9 re_parenthesis = re.compile('([%s])([\((][^\))]{10,}[\))])' % ''.join(DELIMITERS))

AttributeError: module 'emoji' has no attribute 'UNICODE_EMOJI'

The error message was weird because when I looked at the sengiri.py line 6 the code had already updated to the EMOJI_DATA, not UNICODE_EMOJI.

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.