Added some fixes
This commit is contained in:
parent
c59f96d006
commit
9dc71b58c2
18
Tree.py
18
Tree.py
|
@ -39,11 +39,11 @@ class Tree(object):
|
|||
self.parent = parent
|
||||
|
||||
def fits_static_requirements(self, query_tree):
|
||||
return ('form' not in query_tree or query_tree['form'] == self.form.get_value) and \
|
||||
('lemma' not in query_tree or query_tree['lemma'] == self.lemma.get_value) and \
|
||||
('upos' not in query_tree or query_tree['upos'] == self.upos.get_value) and \
|
||||
('xpos' not in query_tree or query_tree['xpos'] == self.xpos.get_value) and \
|
||||
('deprel' not in query_tree or query_tree['deprel'] == self.deprel.get_value)
|
||||
return ('form' not in query_tree or query_tree['form'] == self.form.get_value()) and \
|
||||
('lemma' not in query_tree or query_tree['lemma'] == self.lemma.get_value()) and \
|
||||
('upos' not in query_tree or query_tree['upos'] == self.upos.get_value()) and \
|
||||
('xpos' not in query_tree or query_tree['xpos'] == self.xpos.get_value()) and \
|
||||
('deprel' not in query_tree or query_tree['deprel'] == self.deprel.get_value())
|
||||
|
||||
def generate_children_queries(self, all_query_indices, children):
|
||||
partial_results = {}
|
||||
|
@ -220,10 +220,14 @@ class Tree(object):
|
|||
i += 1
|
||||
|
||||
completed_subtrees = l_completed_subtrees
|
||||
for i in range(len(permanent_query_trees)):
|
||||
# for i in range(len(permanent_query_trees)):
|
||||
# for i in range(max(len(completed_subtrees), len(r_completed_subtrees), len(active_permanent_query_trees))):
|
||||
for i in range(len(active_permanent_query_trees)):
|
||||
# if 0 < len(active_permanent_query_trees):
|
||||
completed_subtrees[i].extend(merged_partial_subtrees[i])
|
||||
for i in range(len(r_completed_subtrees)):
|
||||
completed_subtrees[i].extend(r_completed_subtrees[i])
|
||||
return merged_partial_subtrees[len(permanent_query_trees):], completed_subtrees
|
||||
return merged_partial_subtrees[len(active_permanent_query_trees):], completed_subtrees
|
||||
|
||||
@staticmethod
|
||||
def merge_results(old_results, new_results):
|
||||
|
|
|
@ -18,11 +18,25 @@ def decode_query(orig_query):
|
|||
new_query = True
|
||||
orig_query = orig_query[1:-1]
|
||||
|
||||
orig_query_split = orig_query.split(' ')[0].split('=')
|
||||
# if orig_query is '_' return {}
|
||||
if orig_query == '_':
|
||||
return {}
|
||||
# if no spaces in query then this is query node and do this otherwise further split query
|
||||
elif len(orig_query.split(' ')) == 1:
|
||||
if len(orig_query_split) > 1:
|
||||
if orig_query_split[0] == 'L':
|
||||
return {'lemma': orig_query_split[1]}
|
||||
elif orig_query_split[0] == 'upos':
|
||||
return {'upos': orig_query_split[1]}
|
||||
elif orig_query_split[0] == 'xpos':
|
||||
return {'xpos': orig_query_split[1]}
|
||||
elif orig_query_split[0] == 'form':
|
||||
return {'form': orig_query_split[1]}
|
||||
elif not new_query:
|
||||
raise Exception('Not supported yet!')
|
||||
elif not new_query:
|
||||
return {'form': orig_query}
|
||||
|
||||
# split over spaces if not inside braces
|
||||
PATTERN = re.compile(r'''((?:[^ ()]|\([^(]*\))+)''')
|
||||
|
@ -128,7 +142,7 @@ def main():
|
|||
|
||||
|
||||
# set filters
|
||||
assert config.get('settings', 'analyze_type') in ['deprel', 'lemma', 'upos', 'upos', 'xpos', 'form'], '"analyze_type" is not set up correctly'
|
||||
assert config.get('settings', 'analyze_type') in ['deprel', 'lemma', 'upos', 'xpos', 'form'], '"analyze_type" is not set up correctly'
|
||||
if config.get('settings', 'analyze_type') == 'deprel':
|
||||
create_output_string_funct = create_output_string_deprel
|
||||
elif config.get('settings', 'analyze_type') == 'lemma':
|
||||
|
@ -143,6 +157,7 @@ def main():
|
|||
result_dict = {}
|
||||
|
||||
# for tree in all_trees[2:]:
|
||||
# for tree in all_trees[1205:]:
|
||||
for tree in all_trees:
|
||||
# original
|
||||
# r_children = tree.r_children[:1] + tree.r_children[3:4]
|
||||
|
|
Loading…
Reference in New Issue
Block a user