Added Free structure column
This commit is contained in:
parent
53edc3b796
commit
41f87fc8bd
|
@ -37,14 +37,18 @@ class ResultTree(object):
|
|||
def set_children(self, children):
|
||||
self.children = children
|
||||
|
||||
def get_key(self):
|
||||
def get_key(self, get_free=False):
|
||||
# if self.key:
|
||||
# return self.key
|
||||
key = ''
|
||||
write_self_node_to_result = False
|
||||
if self.children:
|
||||
for child in self.children:
|
||||
if child.node.location < self.node.location:
|
||||
if get_free:
|
||||
children = sorted(self.children, key=lambda x: x.node.name)
|
||||
else:
|
||||
children = self.children
|
||||
for child in children:
|
||||
if self.filters['node_order'] and child.node.location < self.node.location and not get_free:
|
||||
if self.filters['dependency_type']:
|
||||
# separator = ' <' + deprel[i_child][i_answer] + ' '
|
||||
separator = ' <' + child.node.deprel + ' '
|
||||
|
@ -75,7 +79,7 @@ class ResultTree(object):
|
|||
write_self_node_to_result = False
|
||||
if self.children:
|
||||
for child in self.children:
|
||||
if child.node.location < self.node.location:
|
||||
if self.filters['node_order'] and child.node.location < self.node.location:
|
||||
if self.filters['dependency_type']:
|
||||
# separator = ' <' + deprel[i_child][i_answer] + ' '
|
||||
separator = ' <' + child.node.deprel + ' '
|
||||
|
@ -105,7 +109,7 @@ class ResultTree(object):
|
|||
write_self_node_to_result = False
|
||||
if self.children:
|
||||
for child in self.children:
|
||||
if child.node.location < self.node.location:
|
||||
if self.filters['node_order'] and child.node.location < self.node.location:
|
||||
order += child.get_order()
|
||||
else:
|
||||
if not write_self_node_to_result:
|
||||
|
@ -127,7 +131,7 @@ class ResultTree(object):
|
|||
write_self_node_to_result = False
|
||||
if self.children:
|
||||
for child in self.children:
|
||||
if child.node.location < self.node.location:
|
||||
if self.filters['node_order'] and child.node.location < self.node.location:
|
||||
array += child.get_array()
|
||||
else:
|
||||
if not write_self_node_to_result:
|
||||
|
|
10
Tree.py
10
Tree.py
|
@ -595,8 +595,8 @@ class Tree(object):
|
|||
# def create_merged_results(self, new_child, new_answers, i_child, indices, deprel, filters):
|
||||
|
||||
def merge_results3(self, child, new_results, filters):
|
||||
if create_output_string_form(self) == 'Dogodek':
|
||||
print('HERE!@@!')
|
||||
# if create_output_string_form(self) == 'Dogodek':
|
||||
# print('HERE!@@!')
|
||||
# if create_output_string_form(self) == 'začelo':
|
||||
# print('HERE!@@!')
|
||||
# if create_output_string_form(self) == 'utišal':
|
||||
|
@ -627,8 +627,8 @@ class Tree(object):
|
|||
# for children in children_groups_sorted:
|
||||
# new_result = copy(result)
|
||||
# new_result.set_children(children)
|
||||
# order = sorted(new_result.get_order())
|
||||
# results_sorted.append(new_result)
|
||||
# order = tuple(sorted(new_result.get_order()))
|
||||
# results_sorted[order] = new_result
|
||||
|
||||
|
||||
results = []
|
||||
|
@ -636,7 +636,7 @@ class Tree(object):
|
|||
for children in children_groups:
|
||||
new_result = copy(result)
|
||||
new_result.set_children(children)
|
||||
order = new_result.get_order()
|
||||
order = tuple(sorted(new_result.get_order()))
|
||||
results.append(new_result)
|
||||
|
||||
return results
|
||||
|
|
|
@ -503,7 +503,7 @@ def main():
|
|||
for tree_i, tree in enumerate(all_trees):
|
||||
# for tree_i, tree in enumerate(all_trees[852:]):
|
||||
# for tree_i, tree in enumerate(all_trees[1689:]):
|
||||
# for tree_i, tree in enumerate(all_trees[2:]):
|
||||
# for tree_i, tree in enumerate(all_trees[1:3]):
|
||||
input_data = (tree, query_tree, create_output_string_functs, filters)
|
||||
if filters['association_measures']:
|
||||
unigrams = get_unigrams(input_data)
|
||||
|
@ -565,6 +565,7 @@ def main():
|
|||
header += ['Relative frequency']
|
||||
if filters['node_order']:
|
||||
header += ['Order']
|
||||
header += ['Free structure']
|
||||
if filters['nodes_number']:
|
||||
header += ['Number of nodes']
|
||||
if filters['print_root']:
|
||||
|
@ -589,6 +590,7 @@ def main():
|
|||
row += ['%.4f' % absolute_frequency]
|
||||
if filters['node_order']:
|
||||
row += [v['object'].order]
|
||||
row += [v['object'].get_key(get_free=True)[1:-1]]
|
||||
if filters['nodes_number']:
|
||||
row += ['%d' % len(v['object'].array)]
|
||||
if filters['print_root']:
|
||||
|
|
Loading…
Reference in New Issue
Block a user