-
Notifications
You must be signed in to change notification settings - Fork 0
/
scriptdet_test.go
87 lines (85 loc) · 1.98 KB
/
scriptdet_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package langdet
import (
"testing"
"unicode"
)
func TestDetectScript(t *testing.T) {
for _, testcase := range []struct {
Name string
Text string
Script *unicode.RangeTable
}{
{
Name: "Garbage",
Text: "123456789-=?",
Script: nil,
},
{
Name: "Latin",
Text: "Hello, world!",
Script: unicode.Latin,
},
{
Name: "Cyrillic",
Text: "Привет всем!",
Script: unicode.Cyrillic,
},
{
Name: "Georgian",
Text: "ქართული ენა მსოფლიო ",
Script: unicode.Georgian,
},
{
Name: "Han",
Text: "県見夜上温国阪題富販",
Script: unicode.Han,
},
{
Name: "Arabic",
Text: " ككل حوالي 1.6، ومعظم الناس ",
Script: unicode.Arabic,
},
{
Name: "Devanagari",
Text: "हिमालयी वन चिड़िया (जूथेरा सालिमअली) चिड़िया की एक प्रजाति है",
Script: unicode.Devanagari,
},
{
Name: "Hebrew",
Text: "היסטוריה והתפתחות של האלפבית העברי",
Script: unicode.Hebrew,
},
{
Name: "Ethiopic",
Text: "የኢትዮጵያ ፌዴራላዊ ዴሞክራሲያዊሪፐብሊክ",
Script: unicode.Ethiopic,
},
{
Name: "Cyrillic and English",
Text: "Привет! Текст на русском with some English.",
Script: unicode.Cyrillic,
},
{
Name: "Russian and English",
Text: "Russian word любовь means love.",
Script: unicode.Latin,
},
{
Name: "Bengali",
Text: "আমি ভালো আছি, ধন্যবাদ!",
Script: unicode.Bengali,
},
{
Name: "Japanese",
Text: "ハローワールド",
Script: HiraganaKatakana,
},
} {
t.Run(testcase.Name, func(t *testing.T) {
got := DetectScript(testcase.Text, DefaultOptions.Scripts)
if got != testcase.Script {
t.Error("got", got, "but expected", testcase.Script)
}
})
}
}