1
2
3
4 from translate.lang import common
5
7 """Tests basic functionality of word segmentation."""
8 language = common.Common
9 words = language.words(u"Test sentence.")
10 assert words == [u"Test", u"sentence"]
11
12
13 words = language.words(u"ផ្ដល់យោបល់")
14 assert words == [u"ផ្ដល់", u"យោបល់"]
15
16 words = language.words(u"This is a weird test .")
17 assert words == [u"This", u"is", u"a", u"weird", u"test"]
18
19 words = language.words(u"Don't send e-mail!")
20 assert words == [u"Don't", u"send", u"e-mail"]
21
22 words = language.words(u"Don’t send e-mail!")
23 assert words == [u"Don’t", u"send", u"e-mail"]
24
26 """Tests basic functionality of sentence segmentation."""
27 language = common.Common
28 sentences = language.sentences(u"This is a sentence.")
29 assert sentences == [u"This is a sentence."]
30 sentences = language.sentences(u"This is a sentence")
31 assert sentences == [u"This is a sentence"]
32 sentences = language.sentences(u"This is a sentence. Another one.")
33 assert sentences == [u"This is a sentence.", u"Another one."]
34 sentences = language.sentences(u"This is a sentence. Another one. Bla.")
35 assert sentences == [u"This is a sentence.", u"Another one.", u"Bla."]
36 sentences = language.sentences(u"This is a sentence.Not another one.")
37 assert sentences == [u"This is a sentence.Not another one."]
38 sentences = language.sentences(u"Exclamation! Really? No...")
39 assert sentences == [u"Exclamation!", u"Really?", u"No..."]
40 sentences = language.sentences(u"Four i.e. 1+3. See?")
41 assert sentences == [u"Four i.e. 1+3.", u"See?"]
42 sentences = language.sentences(u"Apples, bananas, etc. are nice.")
43 assert sentences == [u"Apples, bananas, etc. are nice."]
44 sentences = language.sentences(u"Apples, bananas, etc.\nNext part")
45 assert sentences == [u"Apples, bananas, etc.", u"Next part"]
46 sentences = language.sentences(u"No font for displaying text in encoding '%s' found,\nbut an alternative encoding '%s' is available.\nDo you want to use this encoding (otherwise you will have to choose another one)?")
47 assert sentences == [u"No font for displaying text in encoding '%s' found,\nbut an alternative encoding '%s' is available.", u"Do you want to use this encoding (otherwise you will have to choose another one)?"]
48
49
50
52 """Tests that the indefinite article ('n) doesn't confuse startcaps()."""
53 language = common.Common
54 assert language.capsstart("Open cow file")
55 assert language.capsstart("'Open' cow file")
56 assert not language.capsstart("open cow file")
57 assert not language.capsstart(":")
58