Views
No views yet
1from transformers import pipeline
2#Feel free to play around with the generation parameters.
3#Reduce the beam width for faster inference
4#Note that the maximum length for the generated titles is 64
5gen_kwargs = {"length_penalty": 0.6, "num_beams":4, "num_return_sequences": 4,"num_beam_groups":4,"diversity_penalty":2.0}
6
7pipe = pipeline("summarization", model="RajSang/pegasus-sports-titles")
8
9#Change the article according to your wish
10article="""
11Coutinho was just about to be introduced by Villa boss Gerrard midway through the second half when Bruno Fernandes slammed home
12his second goal of the game off the underside of the bar. But the Brazilian proved the catalyst for a memorable response.
13First he drove at the United defence, helping to create the space which Jacob Ramsey exploited to halve the deficit. Then Ramsey slid over an excellent
14cross from the left which Raphael Varane was unable to intercept as he slid back, leaving Coutinho to finish into an empty net.
15The goal brought celebrations at both ends of the pitch as Emiliano Martinez also went into the crowd in relief - it was the Argentine's horrible sixth-minute error that had gifted Fernandes the visitors' opener.
16Given his background - with Liverpool, Barcelona and Bayern Munich - Coutinho is a bold loan signing by Villa, and underlines the pedigree of the man they appointed as manager in November.
17Gerrard is not at Villa to learn how to avoid relegation.
18His demands remain as high as they were as a player and Coutinho's arrival is an example of that.
19Villa are a better team since Gerrard's arrival and, after a sluggish start against opponents they dominated but lost to in the FA Cup five days ago, they grew into the game.
20The club's other newboy, Lucas Digne, was among those denied by United keeper David de Gea at the end of the first half - in unorthodox fashion, with his knees.
21Ollie Watkins did not really test the Spain keeper when Villa broke after Edinson Cavani lost possession in his own half. However, Emi Buendia certainly did with a near-post header. Rooted to his line, De Gea's reactions were up to the job as he beat Buendia's effort away.
22When De Gea produced more saves after half-time to deny Ramsey and Digne again, it appeared the image of the night for Villa would be midfielder Morgan Sanson kicking a drinks bottle in fury after his error in gifting Fred possession to set up Fernandes for the visitors' second had been followed immediately by his substitution.
23However, as it was the prelude to Coutinho's arrival, it was the moment that changed the course of the game - and the acclaim for the Brazilian at the final whistle indicated Villa's fans are already firmly behind him.
24"""
25
26result=pipe(article, **gen_kwargs)[0]["summary_text"]
27
28print(result)
29
30''' Output
31Title 1 :
32
33Coutinho's arrival sparks Villa comeback
34
35Title 2 :
36
37Philippe Coutinho marked his debut for Aston Villa with a goal and an assist as Steven Gerrard's side came from two goals down to draw with Manchester United.
38
39Title 3 :
40
41Steven Gerrard's first game in charge of Aston Villa ended in a dramatic draw against Manchester United - but it was the arrival of Philippe Coutinho that marked the night.
42
43Title 4 :
44
45Liverpool loanee Philippe Coutinho marked his first appearance for Aston Villa with two goals as Steven Gerrard's side came from two goals down to draw 2-2.'''
46