Ejemplo n.º 1
0
    def summarize4(self, df):
        #http://ai.intelligentonlinetools.com/ml/text-summarization/
        LANGUAGE = "english"
        SENTENCES_COUNT = 10
        stopwords = nltk.corpus.stopwords.words('english')
        for row in df['conclusion']:
            if row == '0' or row == '':
                continue
            parser = PlaintextParser(row, Tokenizer(LANGUAGE))
            print("--LsaSummarizer--")
            summarizer = LsaSummarizer()
            summarizer = LsaSummarizer(Stemmer(LANGUAGE))
            summarizer.stop_words = get_stop_words(LANGUAGE)
            for sentence in summarizer(parser.document, SENTENCES_COUNT):
                print(sentence)

            print("--LuhnSummarizer--")
            summarizer = LuhnSummarizer()

            summarizer.stop_words = stopwords
            for sentence in summarizer(parser.document, SENTENCES_COUNT):
                print(sentence)

            print("--EdmundsonSummarizer--")
            summarizer = EdmundsonSummarizer()
            words = ("deep", "learning", "neural")
            summarizer.bonus_words = words

            words = (
                "another",
                "and",
                "some",
                "next",
            )
            summarizer.stigma_words = words

            words = (
                "another",
                "and",
                "some",
                "next",
            )
            summarizer.null_words = words
            for sentence in summarizer(parser.document, SENTENCES_COUNT):
                print(sentence)
Ejemplo n.º 2
0
    summary2+=str(sentence)
    summary2+=" "

with open("summarised_text.txt", "a", encoding="utf8") as myfile:
    myfile.write("\n\nLuhn:\n")
    myfile.write(summary2)

summary3 = ""
print("\n\n")
print ("--EdmundsonSummarizer--")     
summarizer = EdmundsonSummarizer() 
words = ("deep", "learning", "neural" )
summarizer.bonus_words = words
    
words = ("another", "and", "some", "next",)
summarizer.stigma_words = words
    
words = ("another", "and", "some", "next",)
summarizer.null_words = words

for sentence in summarizer(parser.document, SENTENCES_COUNT):
    summary3+=str(sentence)
    summary3+=" "

with open("summarised_text.txt", "a", encoding="utf8") as myfile:
    myfile.write("\n\nEdmundson:\n")
    myfile.write(summary3)

summary4 = ""
print("\n\n")
print ("--LexRankSummarizer--")