Skip to content

Commit

Permalink
Update processing.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean authored Nov 19, 2017
1 parent a88abef commit 1a4842c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions language_model/src/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def build_sentences(sentences):
out = []
for sentence in sentences:
words = [x.lower() for x in sentence]
words.insert(0, "<s>")
words.append("</s>")
words.insert(0, const.START_TOKEN)
words.append(const.END_TOKEN)
out.append(words)
return out

Expand Down Expand Up @@ -48,6 +48,7 @@ def build_bidict(sentences):
# 构建trigram词频词典,其中以三元组(u, v, w)作为词典的键
def build_tridict(sentences):
tridict = {}
sentences.insert(0, const.START_TOKEN)
for words in sentences:
for i in range(len(words) -2):
tup = (words[i], words[i+1], words[i+2])
Expand Down

0 comments on commit 1a4842c

Please sign in to comment.