def luhn_summarizer(text, stemmer, LANGUAGE, SENTENCES_COUNT):
    parser = PlaintextParser.from_string(text, sumytoken(LANGUAGE))
    summarizer_luhn = LuhnSummarizer(stemmer)
    summarizer_luhn.stop_words = get_stop_words(LANGUAGE)
    sentences = []
    for sentence in summarizer_luhn(parser.document, SENTENCES_COUNT):
        a = sentence
        sentences.append(str(a))
    return " ".join(sentences)
def lexrank_summarizer(text, stemmer, LANGUAGE, SENTENCES_COUNT):
    parser = PlaintextParser.from_string((text), sumytoken(LANGUAGE))
    summarizer_LexRank = LexRankSummarizer(stemmer)
    summarizer_LexRank.stop_words = get_stop_words(LANGUAGE)
    sentences = []
    for sentence in summarizer_LexRank(parser.document, SENTENCES_COUNT):
        a = sentence
        sentences.append(str(a))
    return " ".join(sentences)
Пример #3
0
def luhn_summarizer(data):
    text = data
    parser = PlaintextParser.from_string((text), sumytoken(LANGUAGE))
    stemmer = Stemmer(LANGUAGE)    
    print ("\n","*"*30, "LUHN SUMMARIZER", "*"*30)
    summarizer_luhn = LuhnSummarizer(stemmer)
    summarizer_luhn.stop_words = get_stop_words(LANGUAGE)
    result = ''
    for sentence in summarizer_luhn(parser.document, SENTENCES_COUNT):
        result += str(sentence)
    
    return result
Пример #4
0
	def summary(self, text, percentage):
		self.SENTENCES_COUNT = int(
			(text.count(".") + text.count("?") + text.count("!"))*(percentage/100))
		self.parser = PlaintextParser.from_string((text), sumytoken(self.LANGUAGE))
		self.res = []
		for sentence in self.summarizer_LexRank(self.parser.document, self.SENTENCES_COUNT):
			self.res.append(str(sentence))
			self.res.append(" ")

		self.final_summ = ''.join(self.res)

		with open(os.path.join('res', "summary.txt"), "w", encoding="utf-8") as f:
			f.write(self.final_summ)

		return self.final_summ
Пример #5
0
def summary(text, percentage):
    LANGUAGE = "english"
    SENTENCES_COUNT = int(
        (text.count(".") + text.count("?") + text.count("!")) *
        (percentage / 100))
    parser = PlaintextParser.from_string((text), sumytoken(LANGUAGE))
    stemmer = Stemmer(LANGUAGE)
    summarizer_LexRank = LexRankSummarizer(stemmer)
    summarizer_LexRank.stop_words = get_stop_words(LANGUAGE)
    res = []
    count = 0
    for sentence in summarizer_LexRank(parser.document, SENTENCES_COUNT):
        res.append(str(sentence))
        count += 1
        if (count == 4):
            res.append("\n")
            count = 0
    return '\n'.join(res)
Пример #6
0
def summary(text, percentage):
    LANGUAGE = "english"
    SENTENCES_COUNT = int(
        (text.count(".") + text.count("?") + text.count("!")) *
        (percentage / 100))
    parser = PlaintextParser.from_string((text), sumytoken(LANGUAGE))
    stemmer = Stemmer(LANGUAGE)
    summarizer_LexRank = LexRankSummarizer(stemmer)
    summarizer_LexRank.stop_words = get_stop_words(LANGUAGE)
    res = []
    for sentence in summarizer_LexRank(parser.document, SENTENCES_COUNT):
        res.append(str(sentence))
        res.append(" ")

    final_summ = ''.join(res)
    with open("summary.txt", "w", encoding="utf-8") as f:
        f.write(final_summ)

    return final_summ
Пример #7
0
from sumy.parsers.plaintext import PlaintextParser
from sumy.nlp.tokenizers import Tokenizer as sumytoken
from sumy.summarizers.lex_rank import LexRankSummarizer
from sumy.summarizers.lsa import LsaSummarizer as Summarizer

from pytldr.nlp.tokenizer import Tokenizer as pltdrtoken
from pytldr.summarize.textrank import TextRankSummarizer
from pytldr.summarize.relevance import RelevanceSummarizer
from pytldr.summarize.lsa import LsaSummarizer, LsaOzsoy, LsaSteinberger

LANGUAGE = "english"
SENTENCES_COUNT = 2

text = 'The contribution of cloud computing and mobile computing technologies lead to the newly emerging mobile cloud com- puting paradigm. Three major approaches have been pro- posed for mobile cloud applications: 1) extending the access to cloud services to mobile devices; 2) enabling mobile de- vices to work collaboratively as cloud resource providers; 3) augmenting the execution of mobile applications on portable devices using cloud resources. In this paper, we focus on the third approach in supporting mobile data stream applica- tions. More specifically, we study how to optimize the com- putation partitioning of a data stream application between mobile and cloud to achieve maximum speed/throughput in processing the streaming data. To the best of our knowledge, it is the first work to study the partitioning problem for mobile data stream applica- tions, where the optimization is placed on achieving high throughput of processing the streaming data rather than minimizing the makespan of executions as in other appli- cations. We first propose a framework to provide runtime support for the dynamic computation partitioning and exe- cution of the application. Different from existing works, the framework not only allows the dynamic partitioning for a single user but also supports the sharing of computation in- stances among multiple users in the cloud to achieve efficient utilization of the underlying cloud resources. Meanwhile, the framework has better scalability because it is designed on the elastic cloud fabrics. Based on the framework, we design a genetic algorithm for optimal computation parti- tion. Both numerical evaluation and real world experiment have been performed, and the results show that the par- titioned application can achieve at least two times better performance in terms of throughput than the application without partitioning.'

parser = PlaintextParser.from_string((text), sumytoken(LANGUAGE))
stemmer = Stemmer(LANGUAGE)


def lexrank_summarizer():
    print("\n", "*" * 30, "LEXRANK SUMARIZER", "*" * 30)
    summarizer_LexRank = LexRankSummarizer(stemmer)
    summarizer_LexRank.stop_words = get_stop_words(LANGUAGE)
    for sentence in summarizer_LexRank(parser.document, SENTENCES_COUNT):
        print(sentence)


def lsa_summarizer():
    print("\n", "*" * 30, "LSA SUMMARIZER", "*" * 30)
    summarizer_lsa = Summarizer(stemmer)
    summarizer_lsa.stop_words = get_stop_words(LANGUAGE)