Skip to content

Narrow deep paths mutation#4

Open
nandikaK wants to merge 9 commits intoRDFLib:masterfrom
nandikaK:narrow_deep_paths_mutation
Open

Narrow deep paths mutation#4
nandikaK wants to merge 9 commits intoRDFLib:masterfrom
nandikaK:narrow_deep_paths_mutation

Conversation

@nandikaK
Copy link
Copy Markdown
Contributor

@nandikaK nandikaK commented Feb 3, 2017

No description provided.

Copy link
Copy Markdown
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...

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

Choose a reason for hiding this comment

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

indent

Comment thread 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
Copy Markdown
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...

Comment thread 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
Copy Markdown
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)

Comment thread requirements.txt Outdated
rdflib==4.2.1
scikit-learn==0.17.1
scipy==0.17.0
scipy
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

don't...

Comment thread tests/test_gp_learner_offline.py Outdated
])
filter_node_count = 10
filter_edge_count = 1
limit_res = 32
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

move to config...

Comment thread tests/test_gp_learner_offline.py Outdated
filter_node_count = 10
filter_edge_count = 1
limit_res = 32
vars_ = {SOURCE_VAR,TARGET_VAR}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

add values here...

Comment thread tests/test_gp_learner_offline.py Outdated
if __name__ == '__main__':
test_mutate_deep_narrow_path() No newline at end of file
# test_mutate_deep_narrow_path()
test_to_find_edge_var_for_narrow_path_query() No newline at end of file
Copy link
Copy Markdown
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...

Comment thread 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
Copy Markdown
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
Copy Markdown
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...

Comment thread config/defaults.py
MUTPB_DN_FILTER_EDGE_COUNT = 1
MUTPB_DN_QUERY_LIMIT = 32
# for import in helpers and __init__

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

keep whitespace intact

Comment thread 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
Copy link
Copy Markdown
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

Comment thread gp_learner.py Outdated
'\n'.join([' %d: %s' % (c, v.n3())
for v, c in substitution_counts.most_common()]),
)
fixed = 'Y'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

fixed = True?

Comment thread 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
Copy Markdown
Member

Choose a reason for hiding this comment

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

fixed = False?

Comment thread gp_learner.py
else:
new_triple = (var_node, var_edge, node)
return new_triple, var_node
return new_triple, var_node, var_edge
Copy link
Copy Markdown
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...

Comment thread 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
Copy Markdown
Member

Choose a reason for hiding this comment

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

fixed = False?

Comment thread 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
Copy Markdown
Member

Choose a reason for hiding this comment

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

if fixed:?

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

Choose a reason for hiding this comment

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

PEP8

@nandikaK nandikaK force-pushed the narrow_deep_paths_mutation branch from 45dc6e5 to 94f9ee2 Compare February 16, 2017 16:02
@joernhees joernhees force-pushed the narrow_deep_paths_mutation branch from 94f9ee2 to 72fc46a Compare February 17, 2017 02:47
@nandikaK nandikaK force-pushed the narrow_deep_paths_mutation branch from 72fc46a to 1b74508 Compare February 27, 2017 17:03
@joernhees joernhees force-pushed the narrow_deep_paths_mutation branch from 1b74508 to 3e7b352 Compare March 3, 2017 16:36
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.

2 participants