In [1]:
from grafeno import pipeline
In [2]:
import yaml
config = yaml.load('''
%YAML 1.2
---
# Summarizes a text by extracting the most relevant sentences.
transformers:
- pos_extract
- sim_link
- extend
- unique
- sentences
transformer_args:
sempos: { noun: n }
unique_gram: { hyper: [ True ] }
extended_sentence_edges: [ HYP ]
operations:
- op: cluster
hubratio: 0.2
# - op: markov_cluster
# expand_factor: 10
# inflate_factor: 2
# max_loop: 10
# mult_factor: 1
# - op: louvain_cluster
linearizers:
- cluster_extract
linearizer_args:
summary_length: 50
summary_margin: 10
normalize_sentence_scores: True
''')
In [3]:
document = '''
Hurricane Gilbert swept toward the Dominican Republic Sunday, and the Civil Defense alerted its heavily populated south coast to prepare for high winds, heavy rains and high seas. The storm was approaching from the southeast with sustained winds of 75 mph gusting to 92 mph. There is no need for alarm, Civil Defense Director Eugenio Cabral said in a television alert shortly before midnight Saturday. Cabral said residents of the province of Barahona should closely follow Gilbert's movement. An estimated 100,000 people live in the province, including 70,000 in the city of Barahona, about 125 miles west of Santo Domingo. Tropical Storm Gilbert formed in the eastern Caribbean and strengthened into a hurricane Saturday night. The National Hurricane Center in Miami reported its position at 2 a.m Sunday at latitude 16.1 north, longitude 67.5 west, about 140 miles south of Ponce, Puerto Rico, and 200 miles southeast of Santo Domingo. The National Weather Service in San Juan, Puerto Rico, said Gilbert was moving westward at 15 mph with a broad area of cloudiness and heavy weather rotating around the center of the storm. The weather service issued a flash flood watch for Puerto Rico and the Virgin Islands until at least 6 p.m Sunday. Strong winds associated with the Gilbert brought coastal flooding, strong southeast winds and up to 12 feet feet to Puerto Rico's south coast. There were no reports of casualties. San Juan, on the north coast, had heavy rains and gusts Saturday, but they subsided during the night. On Saturday, Hurricane Florence was downgraded to a tropical storm and its remnants pushed inland from the U.S. Gulf Coast. Residents returned home, happy to find little damage from 80 mph winds and sheets of rain. Florence, the sixth named storm of the 1988 Atlantic storm season, was the second hurricane. The first, Debby, reached minimal hurricane strength briefly before hitting the Mexican coast last month.
'''
In [4]:
res = pipeline.run({ **config, 'text': document })
print(res)