forked from suggest-go/suggest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduced a new entity ScorerNext instead of an array of WordCount f…
…or lm.Next method
- Loading branch information
Showing
8 changed files
with
143 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package lm | ||
|
||
// ScorerNext represents the entity that responses for scoring the word using the parent context | ||
type ScorerNext interface { | ||
// ScoreNext calculates the score for the given nGram built on the parent context | ||
ScoreNext(nGram WordID) float64 | ||
} | ||
|
||
type scorerNext struct { | ||
contextCounts []WordCount | ||
context ContextOffset | ||
nGramVector NGramVector | ||
} | ||
|
||
func (s *scorerNext) ScoreNext(nGram WordID) float64 { | ||
count, _ := s.nGramVector.GetCount(nGram, s.context) | ||
|
||
if count == 0 { | ||
return UnknownWordScore | ||
} | ||
|
||
return calcScore(append(s.contextCounts, count)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.