|
@@ -1,3 +1,6 @@
|
|
|
+import itertools
|
|
|
+
|
|
|
+
|
|
|
def leaf_strategy(doc):
|
|
|
"""
|
|
|
Should return an arrays of variable names based on leaf strategy
|
|
@@ -6,4 +9,18 @@ def leaf_strategy(doc):
|
|
|
:return Array of strings
|
|
|
"""
|
|
|
|
|
|
- pass
|
|
|
+ for token in doc:
|
|
|
+ print(token.text, token.pos_, token.dep_)
|
|
|
+
|
|
|
+ suggestions = dfs(doc[0])
|
|
|
+ return suggestions
|
|
|
+
|
|
|
+
|
|
|
+def dfs(graph, result=[], output=[]):
|
|
|
+ flag = False
|
|
|
+ for u in graph.children:
|
|
|
+ flag = True
|
|
|
+ dfs(u, [*result, graph.text], output)
|
|
|
+ if flag is False:
|
|
|
+ output.append([*result, graph.text])
|
|
|
+ return output
|