Skip to content
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

Narrow deep paths mutation #4

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

nandikaK
Copy link
Contributor

@nandikaK nandikaK commented Feb 3, 2017

No description provided.

Copy link
Member

@joernhees joernhees left a 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
@@ -709,6 +711,90 @@ def to_count_var_over_values_query(self, var, vars_, values, limit):
res += 'LIMIT %d\n' % limit
return self._sparql_prefix(res)

def to_find_edge_var_for_narrow_path_query(self, edge_var, node_var,
vars_, filter_node_count,
filter_edge_count, limit_res):
Copy link
Member

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_]))
Copy link
Member

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')
Copy link
Member

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
requests==2.9.1
rdflib==4.2.1
scikit-learn==0.17.1
scipy==0.17.0
scipy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't...

])
filter_node_count = 10
filter_edge_count = 1
limit_res = 32
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to config...

filter_node_count = 10
filter_edge_count = 1
limit_res = 32
vars_ = {SOURCE_VAR,TARGET_VAR}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add values here...

# test_mutate_deep_narrow_path()
test_to_find_edge_var_for_narrow_path_query()
Copy link
Member

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)
Copy link
Member

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...

Copy link
Member

@joernhees joernhees left a 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...

# for import in helpers and __init__

Copy link
Member

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
@@ -41,7 +41,8 @@
from cluster import expected_precision_loss_by_query_reduction
from cluster import select_best_variant
import config
from gp_query import ask_multi_query
from gp_query import ask_multi_query, \
variable_substitution_deep_narrow_mut_query
Copy link
Member

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'
Copy link
Member

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'
Copy link
Member

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
@@ -420,7 +421,7 @@ def _mutate_expand_node_helper(node, pb_en_out_link=config.MUTPB_EN_OUT_LINK):
new_triple = (node, var_edge, var_node)
else:
new_triple = (var_node, var_edge, node)
return new_triple, var_node
return new_triple, var_node, var_edge
Copy link
Member

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'
Copy link
Member

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':
Copy link
Member

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
@@ -426,6 +426,21 @@ def variable_substitution_query(
)


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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants