Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def execute_stage_two(path_stage1):
"""Execute the second stage of processing."""
graph, ranks = pytextrank.text_rank(os.path.join(PATH_PREFIX, path_stage1))
pytextrank.render_ranks(graph, ranks)
path_name_components = path_stage1.split('.')
path_name_components[path_name_components.index('stage1')] = 'stage2'
path_stage2 = '-'.join(path_name_components)
with open(os.path.join(PATH_PREFIX, path_stage2), 'w') as f:
for rl in pytextrank.normalize_key_phrases(os.path.join(PATH_PREFIX, path_stage1),
ranks, stopwords=stopwords):
f.write("%s\n" % pytextrank.pretty_print(rl._asdict()))
return path_stage2
def execute_stage_one(path_stage0):
"""Execute the first stage of processing."""
path_stage1 = path_stage0.split('::')[0] + ".stage1.output.dat"
with open(os.path.join(PATH_PREFIX, path_stage1), 'w') as f:
for graf in pytextrank.parse_doc(pytextrank.json_iter(
os.path.join(PATH_PREFIX, path_stage0))):
f.write("%s\n" % pytextrank.pretty_print(graf._asdict()))
return path_stage1
def execute_stage_one(path_stage0):
"""Execute the first stage of processing."""
path_stage1 = path_stage0.split('::')[0] + ".stage1.output.dat"
with open(os.path.join(PATH_PREFIX, path_stage1), 'w') as f:
for graf in pytextrank.parse_doc(pytextrank.json_iter(
os.path.join(PATH_PREFIX, path_stage0))):
f.write("%s\n" % pytextrank.pretty_print(graf._asdict()))
return path_stage1
def execute_stage_two(path_stage1):
"""Execute the second stage of processing."""
graph, ranks = pytextrank.text_rank(os.path.join(PATH_PREFIX, path_stage1))
pytextrank.render_ranks(graph, ranks)
path_name_components = path_stage1.split('.')
path_name_components[path_name_components.index('stage1')] = 'stage2'
path_stage2 = '-'.join(path_name_components)
with open(os.path.join(PATH_PREFIX, path_stage2), 'w') as f:
for rl in pytextrank.normalize_key_phrases(os.path.join(PATH_PREFIX, path_stage1),
ranks, stopwords=stopwords):
f.write("%s\n" % pytextrank.pretty_print(rl._asdict()))
return path_stage2
def execute_stage_two(path_stage1):
"""Execute the second stage of processing."""
graph, ranks = pytextrank.text_rank(os.path.join(PATH_PREFIX, path_stage1))
pytextrank.render_ranks(graph, ranks)
path_name_components = path_stage1.split('.')
path_name_components[path_name_components.index('stage1')] = 'stage2'
path_stage2 = '-'.join(path_name_components)
with open(os.path.join(PATH_PREFIX, path_stage2), 'w') as f:
for rl in pytextrank.normalize_key_phrases(os.path.join(PATH_PREFIX, path_stage1),
ranks, stopwords=stopwords):
f.write("%s\n" % pytextrank.pretty_print(rl._asdict()))
return path_stage2
def execute_stage_two(path_stage1):
"""Execute the second stage of processing."""
graph, ranks = pytextrank.text_rank(os.path.join(PATH_PREFIX, path_stage1))
pytextrank.render_ranks(graph, ranks)
path_name_components = path_stage1.split('.')
path_name_components[path_name_components.index('stage1')] = 'stage2'
path_stage2 = '-'.join(path_name_components)
with open(os.path.join(PATH_PREFIX, path_stage2), 'w') as f:
for rl in pytextrank.normalize_key_phrases(os.path.join(PATH_PREFIX, path_stage1),
ranks, stopwords=stopwords):
f.write("%s\n" % pytextrank.pretty_print(rl._asdict()))
return path_stage2
def get_key_phrases(path_stage2):
"""Get all found key phrases."""
phrases = set([p for p in pytextrank.limit_keyphrases(
os.path.join(PATH_PREFIX, path_stage2), phrase_limit=3)])
return phrases