Skip to content

Commit

Permalink
Fix bug where the top-trigram was not counted
Browse files Browse the repository at this point in the history
Closes GH-28.
  • Loading branch information
wooorm committed Jan 27, 2016
1 parent 68bae5d commit 0152d0a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dist/franc-all.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/franc-most.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/franc.js

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions lib/franc.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,16 @@ function filterLanguages(languages, whitelist, blacklist) {
*/
function getDistance(trigrams, model) {
var distance = 0;
var index = trigrams.length;
var index = -1;
var length = trigrams.length;
var trigram;
var difference;

while (index--) {
while (++index < length) {
trigram = trigrams[index];

if (trigram[0] in model) {
difference = trigram[1] - model[trigram[0]];
difference = trigram[1] - model[trigram[0]] - 1;

if (difference < 0) {
difference = -difference;
Expand Down

0 comments on commit 0152d0a

Please sign in to comment.