Spaces:
Sleeping
Sleeping
update
Browse files
app.py
CHANGED
@@ -35,6 +35,7 @@ if text:
|
|
35 |
|
36 |
# Convert the bracket parse tree into an NLTK Tree
|
37 |
mod_tree = str(parse_tree).replace("$(", "$LRB").replace("$)", "$RRB")
|
|
|
38 |
# t = Tree.fromstring(re.sub(r'(-\w+)+', '', mod_tree))
|
39 |
# t = Tree.fromstring(mod_tree)
|
40 |
|
|
|
35 |
|
36 |
# Convert the bracket parse tree into an NLTK Tree
|
37 |
mod_tree = str(parse_tree).replace("$(", "$LRB").replace("$)", "$RRB")
|
38 |
+
print(mod_tree)
|
39 |
# t = Tree.fromstring(re.sub(r'(-\w+)+', '', mod_tree))
|
40 |
# t = Tree.fromstring(mod_tree)
|
41 |
|
parse.py
CHANGED
@@ -10,9 +10,9 @@ def parse(words):
|
|
10 |
input_sentence = benepar.InputSentence(words=words)
|
11 |
tree = parser.parse(input_sentence)
|
12 |
tree = str(tree).replace('-LRB-','\\(').replace('-RRB-','\\)').replace('-LSB-','\\[').replace('-RSB-','\\]').replace('($(-','($\\(-')
|
13 |
-
tree = tree.replace("$(", "$LRB").replace("$)", "$RRB")
|
14 |
# put the whole parse tree on a single line
|
15 |
tree = re.sub(r'\s+', ' ', tree.strip())
|
16 |
tree = re.sub(r' \(', '(', tree)
|
|
|
17 |
return tree
|
18 |
|
|
|
10 |
input_sentence = benepar.InputSentence(words=words)
|
11 |
tree = parser.parse(input_sentence)
|
12 |
tree = str(tree).replace('-LRB-','\\(').replace('-RRB-','\\)').replace('-LSB-','\\[').replace('-RSB-','\\]').replace('($(-','($\\(-')
|
|
|
13 |
# put the whole parse tree on a single line
|
14 |
tree = re.sub(r'\s+', ' ', tree.strip())
|
15 |
tree = re.sub(r' \(', '(', tree)
|
16 |
+
tree = tree.replace("$(", "$LRB").replace("$)", "$RRB")
|
17 |
return tree
|
18 |
|