nanom commited on
Commit
3a6ed89
·
1 Parent(s): 6bd90ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
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 = " <b>(Plural)</b>"
16
  else:
17
- tag = " <b>({})</b>".format(tk.tag_)
18
  return tag
19
 
20
  def genFlatDepthTree(expr):
21
  doc = nlp(expr)
22
  root = next(doc.sents).root
23
- node = Node(root.text+":(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(ch.text+":"+str(depth+1)+postag(ch), parent=last_node), depth+1)
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 = ""