-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
29 lines (21 loc) · 953 Bytes
/
test.py
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
import json
import sys
import PinyinSplitter
def testSplitter(splitter: PinyinSplitter, testCases: list):
for testCase in testCases:
print("{input}:".format(input = testCase))
for output in splitter.split(testCase):
print("\t{output}".format(output = output))
print()
def main(argv: list):
consonants = json.load(open("Consonants.json"))
vowels = json.load(open("Vowels.json"))
syllables = json.load(open("Syllables.json"))
splitter = PinyinSplitter.PinyinSplitter(consonants, vowels, syllables)
testCasesLegal = ["nihaoshijie", "chiputaobutuputaopi", 'buchiputaodaotuputaopi',
'zhehenangzang', "shuangliujichang", "xianganwushi",
"biangbiangmian"]
testCasesIllegal = ['tsinghua', 'bokchoy', "xxxxxxxxxx", "wwwwwwww", "wxx9248"]
testSplitter(splitter, testCasesLegal + testCasesIllegal)
if __name__ == "__main__":
main(sys.argv)