QNLP  v1.0
test_tagging.py
Go to the documentation of this file.
1 from tagging import *
2 import nltk
3 
4 n1 = Noun(False)
5 n2 = Noun(True,1)
6 v1 = Verb(False)
7 s1 = Sentence([n1,v1,n2])
8 
9 v2 = Verb(True,-2)
10 
11 print(v2)
12 print(n1)
13 print(n2)
14 print(v1)
15 print(s1)
16 
17 jnj="""
18 Jack and Jill went up the hill
19 To fetch a pail of water.
20 Jack fell down and broke his crown,
21 And Jill came tumbling after.
22 """
23 tokens = nltk.word_tokenize(jnj)
24 
25 print("################################")
26 print("Matching nouns")
27 print("################################")
28 for ii in nltk.pos_tag(tokens):
29  print(ii[0],":",matchables(n1, ii[1]))
30 
31 print()
32 print("################################")
33 print("Matching verbs")
34 print("################################")
35 for ii in nltk.pos_tag(tokens):
36  print(ii[0],":",matchables(v1, ii[1]))
def matchables(classType, tag)
Definition: __init__.py:20