Using the Hugging Face BART model to summarise match reports from the 2019 All-Ireland Championship Finals

Published 2020-03-28

Table of Contents

In this short blog post I will demonstrate how we can easily implement the new BART model (from Hugging Face) to summarise the match reports from the 2019 All-Ireland Football and Hurling Championship Finals.

The two match reports we will be summarising can be found on the RTE website here (Dublin v Kerry) and here (Tipp v Kilkenny).

As always, the full code for this tutorial is available from my GitHub repository. Additionally if you would like to read more about the BART model, you can do so over at the Hugging Face repository.

Scraping match reports

Before we generate any summaries, we will need to download and parse the match reports from RTE’s website. To do this we will utilise Python’s requests and BeautifulSoup modules.

import requests
from bs4 import BeautifulSoup
 
response = requests.get(url)
soup = BeautifulSoup(response.text, "html.parser")
match_report = soup.findAll('p')
match_report_text = ' '.join([paragraph.text for paragraph in match_report])

As demonstrated above, we use the requests module to download the raw HTML (see snippet below) from the RTE website. We then use BeautifulSoup to extract each paragraph from the raw HTML, which is denoted by the <p> tag. Once we have each paragraph extracted into a list, we simply concatenate them together using pythons .join() function

HTML snippet from the Tipperary v Kilkenny match report:

<div class="clearfix"></div>
</div>
<div class="widget-container">
<p data-embed="rte-sport-results" data-id="https://www.rte.ie/sport/results/widgets/gaa-match/1011228/?matches=1" data-matches="1"><iframe allowfullscreen="true" frameborder="0" height="85" src="https://www.rte.ie/sport/results/widgets/gaa-match/1011228/?iframe=true&amp;matches=1" width="640"> </iframe></p>
</div>
<section class="medium-10 medium-offset-1 columns article-body" data-epic-field="content" itemprop="articleBody">
<p>What started as a dogfight of a final turned into a mauling as Tipperary cut loose in the second half to crush 14-man Kilkenny and win their third All-Ireland title of the decade.</p>
<p>Brian Cody's men had the better of a scrappy opening period, leading by five points after 21 minutes, but a goal from Niall O’Meara kickstarted Tipp’s revival and just before half-time former Hurler of the Year Richie Hogan was dismissed for a high challenge on Tipperary’s corner-back Cathal Barrett.</p>
<p>

Summarising match report data

Now that we have the have the data parsed, generating a summarised match report is extremely straightforward (and I mean extremely). We simply use the transformers module to create a summariser object which we can pass our parsed text into and generate a summary.

from transformers import pipeline
from bs4 import BeautifulSoup
 
summariser = pipeline('summarization')
 
match_summary = summariser(match_report_text, min_length=100, max_length=500)
print(match_summary[0]['summary_text'])

When we run this on our parsed HTML from the two match reports we can generate the following two summaries:

"Dublin have now won five perfect seasons in a row. The Kingdom are definitely the next best team in the country. They are young though and when the toughest of questions were posed at Croke Park here they hadn’t the answers. They’re not at the peak of their powers, but they are still an awesome outfit. Eoin Murchan nets his first ever Championship score from the kick-out. Kerry tried route one early on, bombing ball after ball into David Clifford and getting absolutely zero return. Con O’Callaghan and Ciarán Kilkenny got the same for the Boys in Blue and, in fact, all of their team’s scores before the break came from play. They weren’t awarded a single scoreable free by referee Conor Lane, which was controversial on occasion."

"Tipperary win their third All-Ireland title of the decade. Brian Cody’s men had the better of a scrappy opening period, leading by five points after 21 minutes. Former Hurler of the Year Richie Hogan was dismissed for a high challenge on Tipperary’s corner-back Cathal Barrett. Tipp led by a point at the interval, 1-09 to 0-11 but, like their old rivals have so often done to them, they came storming out in the third quarter."