Spaces:
Running
Running
Adding pos tag clasification in flat tree
Browse files
app.py
CHANGED
@@ -12,7 +12,10 @@ def markTk(tk):
|
|
12 |
if tk.tag_ in noun_tags:
|
13 |
return " (Plural)"
|
14 |
return ""
|
15 |
-
|
|
|
|
|
|
|
16 |
def genFlatDepthTree(expr):
|
17 |
doc = nlp(expr)
|
18 |
root = next(doc.sents).root
|
@@ -21,7 +24,7 @@ def genFlatDepthTree(expr):
|
|
21 |
def tree(tk, last_node, depth):
|
22 |
if tk.n_lefts + tk.n_rights > 0:
|
23 |
for ch in tk.children:
|
24 |
-
tree(ch, Node(ch.text+" :"+str(depth+1)+markTk(ch), parent=last_node), depth+1)
|
25 |
|
26 |
tree(root, node, 0)
|
27 |
flat_tree = ""
|
|
|
12 |
if tk.tag_ in noun_tags:
|
13 |
return " (Plural)"
|
14 |
return ""
|
15 |
+
|
16 |
+
def postag(tk):
|
17 |
+
return f" ({tk.tag_})"
|
18 |
+
|
19 |
def genFlatDepthTree(expr):
|
20 |
doc = nlp(expr)
|
21 |
root = next(doc.sents).root
|
|
|
24 |
def tree(tk, last_node, depth):
|
25 |
if tk.n_lefts + tk.n_rights > 0:
|
26 |
for ch in tk.children:
|
27 |
+
tree(ch, Node(ch.text+" :"+str(depth+1)+markTk(ch)+postag(ch), parent=last_node), depth+1)
|
28 |
|
29 |
tree(root, node, 0)
|
30 |
flat_tree = ""
|