smoothing
This commit is contained in:
parent
d71b99be29
commit
2b253e5c4f
1462
dev-0/out.tsv
1462
dev-0/out.tsv
File diff suppressed because it is too large
Load Diff
9
run.py
9
run.py
@ -41,15 +41,14 @@ class Model:
|
||||
|
||||
for w1 in self.model:
|
||||
total_count = float(sum(self.model[w1].values()))
|
||||
denominator = total_count + self.alpha * len(self.vocab)
|
||||
for w2 in self.model[w1]:
|
||||
self.model[w1][w2] /= total_count
|
||||
self.model[w1][w2] = (self.model[w1][w2] + self.alpha) / (
|
||||
total_count + self.alpha * len(self.vocab)
|
||||
)
|
||||
nominator = self.model[w1][w2] + self.alpha
|
||||
self.model[w1][w2] = nominator / denominator
|
||||
|
||||
def _predict(self, word):
|
||||
predictions = dict(self.model[word])
|
||||
most_common = dict(Counter(predictions).most_common(5))
|
||||
most_common = dict(Counter(predictions).most_common(6))
|
||||
|
||||
total_prob = 0.0
|
||||
str_prediction = ""
|
||||
|
1124
test-A/out.tsv
1124
test-A/out.tsv
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user