You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.2 KiB
Python

from jinja2 import Template
from markdown import markdown
import sys
# appending a path
sys.path.append('../')
# importing customised module
import summa.edits
from summa.edits import scored_sentences, similarity_graph
import wikipage
from wikipage.page import get_wikipage
wikipedia_page = "mushroom"
# main
# ------------------------------------------------------------------------
if __name__ == '__main__':
# --- WIKI REQUEST ---
# get text from wikipedia
print('--- WIKI ---')
page = get_wikipage(wikipedia_page)
if not page:
sys.exit("--- STOP ---")
title = '<h1>'+page.title+'</h1>'
text = page.content
# print text in terminal
print('--- TXT ---')
print(text)
# --- APPLY TEXTRANK ---
# apply textrank
graph = similarity_graph(text)
# print ranked sentences in terminal
print('--- GRAPH ---')
# for i in len(graph.nodes()):
# for j in len(graph.nodes()):
# s1 = graph.nodes()[i]
# s2 = graph.nodes()[j]
# weight = graph.edge_weight((i, j))
# print('---')
# print('1. ' + s1)
# print('2. ' + s1)
# print('similarity: ' + weight)