Beispiel #1
0
    def __init__(self, source, algorithm, length):
        self.bullets = None
        self.error = None
        self.highlighted_text = None

        text = parse_input(source, extractor='goose')

        if not text:
            text = parse_input(source, extractor='newspaper')

        if algorithm == 'Latent Semantic Analysis':
            summarizer = LsaSummarizer()
        elif algorithm == 'Relevance Score':
            summarizer = RelevanceSummarizer()
        elif algorithm == 'TextRank':
            summarizer = TextRankSummarizer()
        else:
            self.error = 'The summarization algorithm "{0}" does not exist'.format(algorithm)

        if not self.error:
            self.bullets = summarizer.summarize(text, length=length)

            self.highlighted_text = self.get_highlighted_text(text)

            if not self.bullets:
                self.error = "The input text is too short or could not be extracted. If you're submitting a link " \
                             "make sure that it starts with 'http://'. Otherwise, we recommend you copy and paste " \
                             "the text directly below."
def pytldr_lsa(text):
    # summarizer = LsaOzsoy()
    # summarizer = LsaSteinberger()
    summarizer = LsaSummarizer()  # This is identical to the LsaOzsoy object

    summary = summarizer.summarize(text,
                                   topics=4,
                                   length=5,
                                   binary_matrix=True,
                                   topic_sigma_threshold=0.5)
    return summary


# 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.'
# pytldr_lsa(text)