・相談したい事
pythonでn-gramを使用しようと思い、pythonにn-gramをインストールしました。
n-gramがちゃんと動作するかの確認を兼ねて、パソコンで調べたサンプルコードを実行しようとしたのですが、
何故かエラーを起こしてしまいます。
import ngram text = u'あいうえお' index = ngram.NGram(N=2) for term in index.ngrams(index.pad(text)): print term <実行結果> Traceback (most recent call last): File "C:\Users\神龍\decision_table\ngram.py", line 1, in <module> import ngram File "C:\Users\神龍\decision_table\ngram.py", line 4, in <module> index = ngram.NGram(N=2) AttributeError: module 'ngram' has no attribute 'NGram'
うまく実行できると下記のように出力されます。
<理想の実行結果>
$ python sample.py
$あ
あい
いう
うえ
えお
お$
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/06/19 05:46