text_plain_output_5.png text_plain_output_4.png text_plain_output_6.png application_vnd.jupyter.stderr_output_3.png text_plain_output_2.png text_plain_output_1.png
from gensim.summarization.summarizer import summarize

from pysummarization.abstractabledoc.top_n_rank_abstractor import TopNRankAbstractor

from pysummarization.nlpbase.auto_abstractor import AutoAbstractor

from pysummarization.tokenizabledoc.simple_tokenizer import SimpleTokenizer

body = '\n       Scientists say they have discovered a new species of orangutans on Indonesia’s island of Sumatra.\nThe population differs in several ways from the two existing orangutan species found in Sumatra and the neighboring island of Borneo.\nThe orangutans were found inside North Sumatra’s Batang Toru forest, the science publication Current Biology reported.\nResearchers named the new species the Tapanuli orangutan. They say the animals are considered a new species because of genetic, skeletal and tooth differences.\nMichael Kruetzen is a geneticist with the University of Zurich who has studied the orangutans for several years. He said he was excited to be part of the unusual discovery of a new great ape in the present day. He noted that most great apes are currently considered endangered or severely endangered.\nGorillas, chimpanzees and bonobos also belong to the great ape species.\nOrangutan – which means person of the forest in the Indonesian and Malay languages - is the world’s biggest tree-living mammal. The orange-haired animals can move easily among the trees because their arms are longer than their legs. They live more lonely lives than other great apes, spending a lot of time sleeping and eating fruit in the forest.\nThe new study said fewer than 800 of the newly-described orangutans exist. Their low numbers make the group the most endangered of all the great ape species.\nThey live within an area covering about 1,000 square kilometers. The population is considered highly vulnerable. That is because the environment which they depend on is greatly threatened by development.\nResearchers say if steps are not taken quickly to reduce the current and future threats, the new species could become extinct “within our lifetime.”\nResearch into the new species began in 2013, when an orangutan protection group in Sumatra found an injured orangutan in an area far away from the other species. The adult male orangutan had been beaten by local villagers and died of his injuries. The complete skull was examined by researchers.\nAmong the physical differences of the new species are a notably smaller head and frizzier hair. The Tapanuli orangutans also have a different diet and are found only in higher forest areas.\nThere is no unified international system for recognizing new species. But to be considered, discovery claims at least require publication in a major scientific publication.\nRussell Mittermeier is head of the primate specialist group at the International Union for the Conservation of Nature. He called the finding a “remarkable discovery.” He said it puts responsibility on the Indonesian government to help the species survive.\nMatthew Nowak is one of the writers of the study. He told the Associated Press that there are three groups of the Tapanuli orangutans that are separated by non-protected land.He said forest land needs to connect the separated groups.\nIn addition, the writers of the study are recommending that plans for a hydropower center in the area be stopped by the government.\nIt also recommended that remaining forest in the Sumatran area where the orangutans live be protected.\nI’m Bryan Lynn.\n\n        '

from gensim.summarization.summarizer import summarize
from gensim.summarization import keywords
def summarize_text(text):
    try:
        summarized_text = summarize(text, word_count=150)
        if summarized_text != '':
            if summarized_text != text:
                return summarized_text
            else:
                return ''
        else:
            return ''
    except Exception as e:
        return ''
if __name__ == '__main__':
    sentence = body

from pysummarization.nlpbase.auto_abstractor import AutoAbstractor
from pysummarization.tokenizabledoc.simple_tokenizer import SimpleTokenizer
from pysummarization.abstractabledoc.top_n_rank_abstractor import TopNRankAbstractor
auto_abstractor = AutoAbstractor()
auto_abstractor.tokenizable_doc = SimpleTokenizer()
auto_abstractor.delimiter_list = ['.', '\n']
abstractable_doc = TopNRankAbstractor()
result_dict = auto_abstractor.summarize(body, abstractable_doc)
for sentence in result_dict['summarize_result']:
    print(sentence)