候補を保存しておく

This commit is contained in:
Tokuhiro Matsuno
2020-09-08 23:44:00 +09:00
parent 6909ec6300
commit d43a68cfff
4 changed files with 33 additions and 6 deletions

1
.gitignore vendored
View File

@@ -2,3 +2,4 @@
__pycache__ __pycache__
/comb.xml /comb.xml
/hello.* /hello.*
/test_graph2.py

26
TODO.md
View File

@@ -1,10 +1,28 @@
- 共起的なスコアをいれたい # TODO
- support 3gram
- make dictionary more bigger. ## Priority high
- 絵文字辞書(`beer` で絵文字いれたい。)
- 前向きDP後ろ向きA* で候補を得る
- 単語 2 gram を学習データとして記録できるようにする
- 連文節変換用の UI を実装する
## Priority mid
- 共起的なスコアをいれたい?
- support 3gram(必要?)
- 青空文庫をコーパスとして使う?
- 絵文字辞書(`ビール``beer` で絵文字いれたい。)
- 変な変換 - 変な変換
- "げすとだけ" が "げストだけ" になる。 - "げすとだけ" が "げストだけ" になる。
- "bきゅう" が "B級" にならない - "bきゅう" が "B級" にならない
## Priority low
- 設定画面の実装
- 単語登録機能
# DONE
- 「きょう」を %Y-%m-%d 等に変換できるようにしたい。 - 「きょう」を %Y-%m-%d 等に変換できるようにしたい。
- カタカナ語辞書の作成 - カタカナ語辞書の作成

View File

@@ -17,6 +17,11 @@ import marisa_trie
from datetime import date from datetime import date
class Candidate:
def __init__(self, word: str):
self.word = word
class Comb: class Comb:
logger: Logger logger: Logger
dictionaries: List[Any] dictionaries: List[Any]

View File

@@ -24,7 +24,7 @@ class Node:
def __repr__(self): def __repr__(self):
return f"<Node: start_pos={self.start_pos}, word={self.word}," \ return f"<Node: start_pos={self.start_pos}, word={self.word}," \
f" cost={self.cost}, prev={self.prev.word if self.prev else '-'}>" f" cost={self.cost}, prev={self.prev.word if self.prev else '-'} yomi={self.yomi}>"
def calc_node_cost(self) -> float: def calc_node_cost(self) -> float:
if self.is_bos(): if self.is_bos():
@@ -176,6 +176,9 @@ def viterbi(graph: Graph):
result.append(node) result.append(node)
if node == node.prev: if node == node.prev:
raise AssertionError(f"node==node.prev: {node}") raise AssertionError(f"node==node.prev: {node}")
if not node.is_eos():
# 他の候補を追加する。
node.others = [n for n in graph[node.start_pos + len(node.yomi)] if node.yomi == n.yomi]
node = node.prev node = node.prev
return list(reversed(result)) return list(reversed(result))