Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,20 +12,20 @@ def postag(tk):
|
|
| 12 |
tag = ""
|
| 13 |
plural_tags = ["NNS", "NNPS"]
|
| 14 |
if tk.tag_ in plural_tags:
|
| 15 |
-
tag = "
|
| 16 |
else:
|
| 17 |
-
tag = "
|
| 18 |
return tag
|
| 19 |
|
| 20 |
def genFlatDepthTree(expr):
|
| 21 |
doc = nlp(expr)
|
| 22 |
root = next(doc.sents).root
|
| 23 |
-
node = Node(root.text+"
|
| 24 |
|
| 25 |
def tree(tk, last_node, depth):
|
| 26 |
if tk.n_lefts + tk.n_rights > 0:
|
| 27 |
for ch in tk.children:
|
| 28 |
-
tree(ch, Node(ch.text+"
|
| 29 |
|
| 30 |
tree(root, node, 0)
|
| 31 |
flat_tree = ""
|
|
|
|
| 12 |
tag = ""
|
| 13 |
plural_tags = ["NNS", "NNPS"]
|
| 14 |
if tk.tag_ in plural_tags:
|
| 15 |
+
tag = " (Plural)"
|
| 16 |
else:
|
| 17 |
+
tag = " ({})".format(tk.tag_)
|
| 18 |
return tag
|
| 19 |
|
| 20 |
def genFlatDepthTree(expr):
|
| 21 |
doc = nlp(expr)
|
| 22 |
root = next(doc.sents).root
|
| 23 |
+
node = Node("<b>"+root.text+"</b>: (Root)"+postag(root), parent=None)
|
| 24 |
|
| 25 |
def tree(tk, last_node, depth):
|
| 26 |
if tk.n_lefts + tk.n_rights > 0:
|
| 27 |
for ch in tk.children:
|
| 28 |
+
tree(ch, Node("<b>"+ch.text+"</b>: "+str(depth+1)+postag(ch), parent=last_node), depth+1)
|
| 29 |
|
| 30 |
tree(root, node, 0)
|
| 31 |
flat_tree = ""
|