Skip to content

Commit

Permalink
Fix incorrect indices returned by DetectMultipleLanguagesOf for singl…
Browse files Browse the repository at this point in the history
…e words (#43)
  • Loading branch information
pemistahl committed Sep 5, 2023
1 parent cba7764 commit 1684b52
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (detector languageDetector) DetectMultipleLanguagesOf(text string) []Detect
if len(languages) == 1 {
result := newDetectionResult(
0,
len([]rune(text)),
len(text),
len(tokenWithoutWhitespaceIndices),
languages[0],
)
Expand Down
4 changes: 4 additions & 0 deletions detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,10 @@ func TestDetectMultipleLanguages_OneLanguage(t *testing.T) {
"I'm really not sure whether multi-language detection is a good idea.",
English,
},
{
"français",
French,
},
}

for _, testCase := range testCases {
Expand Down

0 comments on commit 1684b52

Please sign in to comment.