1from PyObjCTools.TestSupport import *
2from Foundation import *
3
4try:
5    unicode
6except NameError:
7    unicode = str
8
9class TestNSLinguisticTagger (TestCase):
10    @min_os_level('10.7')
11    def testConstants(self):
12        self.assertIsInstance(NSLinguisticTagSchemeTokenType, unicode)
13        self.assertIsInstance(NSLinguisticTagSchemeLexicalClass, unicode)
14        self.assertIsInstance(NSLinguisticTagSchemeNameType, unicode)
15        self.assertIsInstance(NSLinguisticTagSchemeNameTypeOrLexicalClass, unicode)
16        self.assertIsInstance(NSLinguisticTagSchemeLemma, unicode)
17        self.assertIsInstance(NSLinguisticTagSchemeLanguage, unicode)
18        self.assertIsInstance(NSLinguisticTagSchemeScript, unicode)
19        self.assertIsInstance(NSLinguisticTagWord, unicode)
20        self.assertIsInstance(NSLinguisticTagPunctuation, unicode)
21        self.assertIsInstance(NSLinguisticTagWhitespace, unicode)
22        self.assertIsInstance(NSLinguisticTagOther, unicode)
23        self.assertIsInstance(NSLinguisticTagNoun, unicode)
24        self.assertIsInstance(NSLinguisticTagVerb, unicode)
25        self.assertIsInstance(NSLinguisticTagAdjective, unicode)
26        self.assertIsInstance(NSLinguisticTagAdverb, unicode)
27        self.assertIsInstance(NSLinguisticTagPronoun, unicode)
28        self.assertIsInstance(NSLinguisticTagDeterminer, unicode)
29        self.assertIsInstance(NSLinguisticTagParticle, unicode)
30        self.assertIsInstance(NSLinguisticTagPreposition, unicode)
31        self.assertIsInstance(NSLinguisticTagNumber, unicode)
32        self.assertIsInstance(NSLinguisticTagConjunction, unicode)
33        self.assertIsInstance(NSLinguisticTagInterjection, unicode)
34        self.assertIsInstance(NSLinguisticTagClassifier, unicode)
35        self.assertIsInstance(NSLinguisticTagIdiom, unicode)
36        self.assertIsInstance(NSLinguisticTagOtherWord, unicode)
37        self.assertIsInstance(NSLinguisticTagSentenceTerminator, unicode)
38        self.assertIsInstance(NSLinguisticTagOpenQuote, unicode)
39        self.assertIsInstance(NSLinguisticTagCloseQuote, unicode)
40        self.assertIsInstance(NSLinguisticTagOpenParenthesis, unicode)
41        self.assertIsInstance(NSLinguisticTagCloseParenthesis, unicode)
42        self.assertIsInstance(NSLinguisticTagWordJoiner, unicode)
43        self.assertIsInstance(NSLinguisticTagDash, unicode)
44        self.assertIsInstance(NSLinguisticTagOtherPunctuation, unicode)
45        self.assertIsInstance(NSLinguisticTagParagraphBreak, unicode)
46        self.assertIsInstance(NSLinguisticTagOtherWhitespace, unicode)
47        self.assertIsInstance(NSLinguisticTagPersonalName, unicode)
48        self.assertIsInstance(NSLinguisticTagPlaceName, unicode)
49        self.assertIsInstance(NSLinguisticTagOrganizationName, unicode)
50
51        self.assertEqual(NSLinguisticTaggerOmitWords, 1 << 0)
52        self.assertEqual(NSLinguisticTaggerOmitPunctuation, 1 << 1)
53        self.assertEqual(NSLinguisticTaggerOmitWhitespace, 1 << 2)
54        self.assertEqual(NSLinguisticTaggerOmitOther, 1 << 3)
55        self.assertEqual(NSLinguisticTaggerJoinNames, 1 << 4)
56
57    @min_os_level('10.7')
58    def testMethods(self):
59        self.assertArgHasType(NSLinguisticTagger.orthographyAtIndex_effectiveRange_,
60                1, b'o^' + NSRange.__typestr__)
61
62        self.assertArgIsBlock(NSLinguisticTagger.enumerateTagsInRange_scheme_options_usingBlock_,
63                3, b'v@' + NSRange.__typestr__ + NSRange.__typestr__ + b'o^' + objc._C_NSBOOL)
64
65        self.assertArgHasType(NSLinguisticTagger.tagAtIndex_scheme_tokenRange_sentenceRange_,
66                2, b'o^' + NSRange.__typestr__)
67        self.assertArgHasType(NSLinguisticTagger.tagAtIndex_scheme_tokenRange_sentenceRange_,
68                3, b'o^' + NSRange.__typestr__)
69
70        self.assertArgHasType(NSLinguisticTagger.tagsInRange_scheme_options_tokenRanges_,
71                3, b'o^@')
72
73        self.assertArgHasType(NSLinguisticTagger.possibleTagsAtIndex_scheme_tokenRange_sentenceRange_scores_,
74                2, b'o^' + NSRange.__typestr__)
75        self.assertArgHasType(NSLinguisticTagger.possibleTagsAtIndex_scheme_tokenRange_sentenceRange_scores_,
76                3, b'o^' + NSRange.__typestr__)
77        self.assertArgHasType(NSLinguisticTagger.possibleTagsAtIndex_scheme_tokenRange_sentenceRange_scores_,
78                4, b'o^@')
79
80        self.assertArgIsOut(NSString.linguisticTagsInRange_scheme_options_orthography_tokenRanges_, 4)
81
82        self.assertArgIsBlock(NSString.enumerateLinguisticTagsInRange_scheme_options_orthography_usingBlock_,
83                4, b'v@' + NSRange.__typestr__ + NSRange.__typestr__ + b'o^' + objc._C_NSBOOL)
84
85if __name__ == "__main__":
86    main()
87