-
Notifications
You must be signed in to change notification settings - Fork 15
Narrow deep paths mutation #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
joernhees
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please rebase on master and cleanup...
graph_pattern.py
Outdated
|
|
||
| def to_find_edge_var_for_narrow_path_query(self, edge_var, node_var, | ||
| vars_, filter_node_count, | ||
| filter_edge_count, limit_res): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
graph_pattern.py
Outdated
| '(dbr:Adult dbr:Child)' \ | ||
| '(dbr:Angel dbr:Heaven)' \ | ||
| '(dbr:Arithmetic dbr:Mathematics)' \ | ||
| '}\n' % (' '.join([v.n3() for v in vars_])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that should be replaced by the values part... also dbr:<SPACE>Anything won't work...
graph_pattern.py
Outdated
| EDGE_VAR_COUNT = Variable('edge_count_var') | ||
| NODE_VAR_COUNT = Variable('node_count_var') | ||
| MAX_NODE_COUNT = Variable('maximum node count') | ||
| PRIO_VAR = Variable('priority') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PEP8 (2 newlines above functions)
requirements.txt
Outdated
| rdflib==4.2.1 | ||
| scikit-learn==0.17.1 | ||
| scipy==0.17.0 | ||
| scipy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't...
tests/test_gp_learner_offline.py
Outdated
| ]) | ||
| filter_node_count = 10 | ||
| filter_edge_count = 1 | ||
| limit_res = 32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to config...
tests/test_gp_learner_offline.py
Outdated
| filter_node_count = 10 | ||
| filter_edge_count = 1 | ||
| limit_res = 32 | ||
| vars_ = {SOURCE_VAR,TARGET_VAR} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add values here...
tests/test_gp_learner_offline.py
Outdated
| if __name__ == '__main__': | ||
| test_mutate_deep_narrow_path() | ||
| # test_mutate_deep_narrow_path() | ||
| test_to_find_edge_var_for_narrow_path_query() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
always have a newline at end of file...
graph_pattern.py
Outdated
| res += ' SELECT DISTINCT %s %s (COUNT(%s) AS %s) WHERE {\n' % ( | ||
| ' '.join([v.n3() for v in vars_]), | ||
| edge_var.n3(), node_var.n3(), NODE_VAR_COUNT.n3()) | ||
| # res += self._sparql_values_part(values) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use that? set indent accordingly...
joernhees
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor style and bugs...
| MUTPB_DN_FILTER_EDGE_COUNT = 1 | ||
| MUTPB_DN_QUERY_LIMIT = 32 | ||
| # for import in helpers and __init__ | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep whitespace intact
gp_learner.py
Outdated
| import config | ||
| from gp_query import ask_multi_query | ||
| from gp_query import ask_multi_query, \ | ||
| variable_substitution_deep_narrow_mut_query |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use same style as surrounding code please
gp_learner.py
Outdated
| '\n'.join([' %d: %s' % (c, v.n3()) | ||
| for v, c in substitution_counts.most_common()]), | ||
| ) | ||
| fixed = 'Y' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed = True?
gp_learner.py
Outdated
| mutate_fix_var_filter(substitution_counts) | ||
| if not substitution_counts: | ||
| # could have happened that we removed the only possible substitution | ||
| fixed = 'N' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed = False?
| else: | ||
| new_triple = (var_node, var_edge, node) | ||
| return new_triple, var_node | ||
| return new_triple, var_node, var_edge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changing this needs adaptation of all users of this function...
gp_learner.py
Outdated
| logger.debug("tried to fix a var %s without result:\n%s" | ||
| "seems as if the pattern can't be fulfilled!", | ||
| edge_var, child.to_sparql_select_query()) | ||
| fixed = 'N' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed = False?
gp_learner.py
Outdated
| test_gp = gp + [new_triple] | ||
| test_gp, fixed = _mutate_deep_narrow_path_helper( | ||
| sparql, timeout, gtp_scores, test_gp, var_edge, var_node) | ||
| if fixed == 'Y': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if fixed:?
gp_query.py
Outdated
|
|
||
| def variable_substitution_deep_narrow_mut_query( | ||
| sparql, timeout, graph_pattern, edge_var, node_var, | ||
| source_target_pairs, limit_res, batch_size=config.BATCH_SIZE): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PEP8
45dc6e5 to
94f9ee2
Compare
…nd args passing, also tons of minor things
…oc string example
94f9ee2 to
72fc46a
Compare
72fc46a to
1b74508
Compare
1b74508 to
3e7b352
Compare
No description provided.