-
Notifications
You must be signed in to change notification settings - Fork 0
/
views.py
79 lines (54 loc) · 1.88 KB
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from __future__ import absolute_import
from __future__ import division, print_function, unicode_literals
from sumy.parsers.html import HtmlParser
from sumy.nlp.tokenizers import Tokenizer
from sumy.summarizers.lsa import LsaSummarizer as Summarizer
from sumy.nlp.stemmers import Stemmer
from sumy.utils import get_stop_words
from django.shortcuts import render
import requests
def button(request):
return render(request, 'home.html')
def output(request):
data = requests.get("https://www.google.com/")
print(data.text)
data = data.text
return render(request, 'home.html', {' data ': data})
def summarizer(request):
inp=request.POST['geturl']
LANGUAGE = "english"
SENTENCES_COUNT = 10
url = str(inp)
f = open("denemedosyasiU3.txt", "w")
f.write(url)
f.close()
parser = HtmlParser.from_url(url, Tokenizer(LANGUAGE))
stemmer = Stemmer(LANGUAGE)
summarizer = Summarizer(stemmer)
summarizer.stop_words = get_stop_words(LANGUAGE)
for sentence in summarizer(parser.document, SENTENCES_COUNT):
print(sentence)
return render(request, 'home.html', {'data1': sentence})
'''
cmd="python C://Users//elmas.gonen//PycharmProjects//denemeB//deneme11.py "+str(inp)
out=os.popen(cmd).read()
p=subprocess.Popen(cmd,stdout=subprocess.PIPE,shell=True)
out, err =p.communicate()
result = out.split('\n')
print(result)
f = open("external.txt", "w")
# time=datetime.datetime.now()
f.write(out)
f.close()
'''
'''
LANGUAGE = "english"
SENTENCES_COUNT = 10
url = data
parser = HtmlParser.from_url(url, Tokenizer(LANGUAGE))
stemmer = Stemmer(LANGUAGE)
summarizer = Summarizer(stemmer)
summarizer.stop_words = get_stop_words(LANGUAGE)
for sentence in summarizer(parser.document, SENTENCES_COUNT):
print(sentence)
'''