LoginSignup
0
1

More than 3 years have passed since last update.

SudachiPyでユーザ辞書をビルドするときに遭遇するかもしれないエラー一覧

Posted at

日本語形態素解析エンジンSudachiのPython実装であるSudachiPyでは、sudachipy ubuildコマンドを使って、ユーザ辞書をビルドすることができます。

$ sudachipy ubuild -h
usage: sudachipy ubuild [-h] [-d string] [-o file] [-s file] file [file ...]

Build User Dictionary

positional arguments:
  file        source files with CSV format (one or more)

optional arguments:
  -h, --help  show this help message and exit
  -d string   description comment to be embedded on dictionary
  -o file     output file (default: user.dic)
  -s file     system dictionary (default: linked system_dic, see link -h)

ビルド時に遭遇するかもしれないエラーをリスト化しておきます。

ValueError: invalid format

reading the source file...中に発生。

reading the source file...Traceback (most recent call last):
  (トレースバック省略)
ValueError: invalid format

列が足りていない

Sudachiのユーザ辞書は、各エントリ18列のフィールドがあるはずだが、列が足りていないエントリが存在するために発生。

余分な空行

ソースCSVファイルに余分な空行が存在したために発生。とくに、最後のエントリの行のあとは、改行させないか、改行しても1回までにさせておく。

ValueError: invalid literal for int() with base 10: 'なんちゃら'

reading the source file...中に発生。なんちゃらの部分は空文字の場合もある。

reading the source file...Traceback (most recent call last):
  (トレースバック省略)
ValueError: invalid literal for int() with base 10: 'なんちゃら'

左連接ID または 右連接ID の未指定

左連接ID(CSVの左から2列目)または右連接ID(CSVの左から3列目)が未指定、または文字列になっているエントリが存在するために発生。

余分な列

Sudachiのユーザ辞書は、各エントリ18列のフィールドがあるはずだが、余分な列が存在し、そこになにか文字列を入力しているエントリが存在するために発生。(ちなみに、余分な列が存在しても、その値が数値や*(アスタリスク)であればエラーとはなりませんでした。)

ValueError: headword is empty

reading the source file...中に発生。

reading the source file...Traceback (most recent call last):
  (トレースバック省略)
ValueError: headword is empty

見出し語が空

見出し語(CSVの左から1列目)の値が空であるエントリが存在するために発生。

OverflowError: int too big to convert

writing the word parameters...中に発生。

reading the source file...64 words
writing the POS table...24 bytes
writing the connection matrix...4 bytes
building the trie...done
writing the trie...3076 bytes
writing the word-ID table...324 bytes
writing the word parameters...Traceback (most recent call last):
  (トレースバック省略)
OverflowError: int too big to convert

左連接ID・右連接ID・コスト値の不正

左連接ID・右連接ID・コスト値(CSVの左から2~4列目の値)のいずれかの値が、「-32768または-3276732767」以外範囲の値を指定しているエントリが存在するために発生。私は、コスト値で-32768と指定しているつもりが、マイナスが取れて32768になっていることがありました。

ValueError: too few columns

writing the word_infos...中に発生。

reading the source file...64 words
writing the POS table...24 bytes
writing the connection matrix...4 bytes
building the trie...done
writing the trie...3076 bytes
writing the word-ID table...324 bytes
writing the word parameters...388 bytes
writing the word_infos...Traceback (most recent call last):
  (トレースバック省略)
ValueError: too few columns

不正な列

エントリの一番最後の列(未使用フィールド)には、*(アスタリスク)を入力しておかなければならないが、それ以外の値が入っているために発生。未使用だから、適当なメモ書きでも入れておこうと思ったのですが、許してくれませんでした。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1