As part of my Masters dissertation I looked at using Machine Learning to generate IIIF collections.

The aim of this project was to create an end-to-end Natural Language Processing (NLP) workflow that allows annotating of names, training of a machine learning model and inference of a corpus of historical data in order to disambiguate names found within a International Image Interoperability Framework (IIIF) document by linking each name to an entity within a knowledge base (Wikidata), through Named Entity Recognition (NER) and Named Entity Linking (NEL).

The workflow allows researchers to query a database for a specific person or group of people based on a linked-data query, which will generate a collection level IIIF manifest of all articles within the National Library of Wales online Newspaper and Journals which mention that person.

Researchers should be able to query for a single person, such as Robert Owen https://en.wikipedia.org/wiki/Robert_Owen (https://www.wikidata.org/wiki/Q179374)

Which will link to articles, such as:

It should also be possible to generate collections based on multiple Wikidata QIDs, eg finding articles that mention female scientists (https://w.wiki/4RdV)

Miriam Rothschild (https://www.wikidata.org/wiki/Q442167):

Mary Sheridan (https://www.wikidata.org/wiki/Q41791981):

Mary Gillham (https://www.wikidata.org/wiki/Q6779635)

Each named entity is saved to a database where the entity will be recorded with a Wikidata QID reference, along with a reference to the article in which they are mentioned.

Origins of the research question

The origins of the research question came from Amanda Clare while attending a Hackathon at the National Library of Wales in 2017. Amanda suggested that the attendees look at the possibility of identifying Female Scientists within the National Library’s historical online Newspapers and Journals.

Although no one at the Hackathon undertook the challenge, the question does warrant further exploration: ‘Is there available data to identify Female Scientists?’

Looking at the data

The National Library of Wales has a number of online resources, including millions of Newspaper and Journal articles which are freely available. With such large sources of data, discoverability of content becomes challenging.

To understand the needs of consumers of these resources it's worth looking at the search queries to see what information users are looking for. Of the top 500 aggregate queries from a total of 472,725,825 queries performed on Welsh Newspapers, 40.4% of queries were for locations and 38.6% were for people.

Pie chart of Welsh Newspapers search queries: location 40.4%, person 38.6%, other 14.1%, event 4.0% and activity 2.8%

The question of finding Female Scientists within historical articles showed there was potential to expand on the question. Identifying all people within historical Newspaper and Journal articles and linking them to an entity within a knowledge base would allow researchers to ask broader questions of the data.

By querying a knowledge base, researchers would be able to identify all Female Scientists and filter the search results by people born within a period of time, nationality or a subset of Science, such as Botany.

Solution

The spaCy library was used alongside the EntityLinker pipeline to train a model that could identify a name within a corpus and attempt to disambiguate that name by linking it to an entity within Wikidata.

Disambiguation

The process of disambiguation is to correctly link a name within a document to an entity within a knowledge base. The knowledge base may contain one or more entities with the same name. Within Wikidata, Jane Seymour may refer to Jane Seymour the actress (https://www.wikidata.org/wiki/Q123849) or Jane Seymour the third wife of Henry VIII of England (https://www.wikidata.org/wiki/Q182637).

Jane Seymour the actress beside a portrait of Jane Seymour, wife of Henry VIII

Why not use existing NEL?

Training our own model allows the workflow to be more flexible by not depending on third party models that may not have the latest entities from Wikidata/Wikipedia. Data generated by this project, such as identifying new people not found within Wikidata; can be ingested back into Wikidata. This will benefit users of the Wikidata project and form part of the training dataset for future model training.

Cycle from Wikidata to training data, a trained model, inference and identifying a new person, which feeds back into Wikidata

Process

In order to successfully train a machine learning model that can accurately predict on unseen data the model must first be trained on annotated training data through a process of supervised learning.

To train a machine learning model to disambiguate every person within the Wikidata knowledge base would take a long time to train and be costly to run.

Therefore the only entities from Wikidata that form the annotated training data were initially people from Wales during the prototyping phase, and following successful testing people from the whole of the United Kingdom.

There are 4,272 entities within the Wikidata knowledge base for people from Wales and 177,084 entities for people from the United Kingdom.

Gathering entities from Wikidata

The project utilises two main sources of information to annotate training data, Wikidata and Wikipedia, along with historical Newspaper and Journal articles.

Table of Wikidata identifiers, names and descriptions for scientists and academics

Gathering training data

Once a list of people from Wikidata has been generated, additional training data for those people is required. For each person the first paragraph of their Wikipedia article is retrieved along with every Wikipedia page that links to that article.

Wikipedia article for Kyffin Williams with his name highlighted in the introductory text

Once data has been collected for each entity, the text within that data must be cleaned of misspellings and non-dictionary characters such as HTML tags.

The data for each entity is merged into a JSON document and saved to disk before being ingested into the annotation database.

The validation process includes checking that the name of the person exists in the text and that the string length text is greater than 40 characters and that the person has a Wikipedia page.

JSON data containing a Wikidata identifier and text about Kyffin Williams

Formatting training data

The information within each document must then be separated and transformed into training data through an automated process. This process loops through each source of information and generates a JSON document containing the training text, the start and end character position of the person’s name and their Wikidata QID.

Annotated JSON training data marking mentions of Kyffin Williams and their character positions

Results

Once a model has been trained it is run against each article in the Newspaper and Journal databases. The model generates a JSON document listing all the names within that article and the character position along with the QID, if the model was able to link it to an entity. The results are then saved to a Solr database.

Python code configuring the named-entity linking workflow

There were over 226 million names identified in Journal and Newspaper articles. On average 10% of names identified were linked to a Wikidata entity.

Names detected in journal and newspaper articles
Article typeTotal namesNames linked to a QIDNames not linked to a QID
All226,501,30323,240,248203,261,055
Journal5,685,514610,5115,075,003
Newspaper220,815,78922,629,737198,186,052

Generating IIIF Collections

Researches are able to create IIIF collections by submitting a SPARQL query to the search interface.

Search interface containing a SPARQL query for Welsh artists

The search interface sends the SPARQL query to Wikidata. Which response with a JSON document of QIDs. These QIDs are then searched within Solr and a IIIF manifest is generated.

IIIF Viewers

The IIIF manifest is viewable by all compatible IIIF viewers, such as the Universal Viewer.

Historic newspaper article displayed in the Universal Viewer IIIF interface

And mirador.

Historic newspaper page displayed in the Mirador IIIF viewer

Researches should be able to quickly view the results and annotate the articles from within these viewers.

Linking data

The manifests can be extended further by using linked data to pull in content for each entity. Given a search for Welsh Artists; the workflow should be able to generate a list of articles that mention that artist and include examples of their work.

IIIF viewer combining newspaper results about Kyffin Williams with examples of his artwork

Limitations

A potential limitation of the use of Wikidata and similar knowledge bases is that the response of a query may contain unexpected results.

For the query of ‘Female Scientists from the United Kingdom’ (https://wiki/4RdV) it will return Margaret Thatcher as an entity (Fig. 8.2.1).

Wikidata query results for female scientists including Margaret Thatcher

Margaret Thatcher is commonly known for being the Prime Minister of the United Kingdom from 1979 until 1990, but worked as a research Chemist prior to becoming a member of parliament. Therefore Wikidata lists one of her occupations as Chemist.

Official portrait of Margaret Thatcher
Wikidata statements listing Margaret Thatcher’s occupations, including research chemist

Discovering new people

One way to identify new people is by searching the entities database for each Wikidata QID and calculating how many have been mis-attributed by comparing the date of birth of the person to the published date of the article.

Kyffin Williams (https://www.wikidata.org/wiki/Q6450928) appears 167 times in the database. However, when searching for articles linked to QID Q6450928 before 1918 (Kyffin Williams date of birth) there are 133 articles incorrectly attributed to Q6450928. This is due to only a single instance of Kyffin Williams existing in the knowledge base

In order to correct the issue and to create a new Wikidata entry for Kyffin Williams, the articles published before the birth of Kyffin Williams the artist were validated, such as:

These articles mention the name Reverend O. Kyffin Williams. A number of articles mention the passing and funeral of this person in 1917 (https://newspapers.library.wales/view/4243951/4243953/23).

Two historic newspaper notices concerning Reverend O. Kyffin Williams

By looking at online resources such as Ancestry it was possible to narrow down this person as Owen Kyffin Williams, who passed away in 1917 and buried in Llangwyllog, Anglesey. Which matches the information in the Newspaper articles.

Genealogy record for Owen Kyffin Williams of Anglesey

Given this information a new Wikidata record was created for this person (https://www.wikidata.org/wiki/Q112080114). Which lists all available information such as Name, Description, date of birth, date of death and burial location.

Workflow

The image below shows the complete workflow that was created for this project.

Complete workflow from source data and Wikidata through training, inference and IIIF output

Research possibilities

It is possible to create a graph of relationships of names that appear most often together in articles. The NEL database produces 59,052 Nodes and 1,259,521 Edges.

One degree of separation for David Lloyd George and people named in the same article.

Dense network graph of people appearing in articles with David Lloyd George

The following names appear the most alongside David Lloyd George.

Names appearing most often alongside David Lloyd George
NameQIDOccurrences
Kenneth O. MorganQ93657718
Clement DaviesQ513130814
Tom EllisQ340352012
Herbert LewisQ573494712
T. E. EllisQ766822211
William GeorgeQ1943028610
A. J. P. TaylorQ7069319
Thomas GeeQ33998368
Henry RichardQ57275236
Basil BlackwellQ48671175
Anthony EdenQ1289954

Knowledge Graph

Given a topic, such as the Aberfan Disaster, researchers could query for all entities that appear within articles about that topic. Given the frequency names appear within those articles it will be possible to identify key people within a given topic.

Similar to how search engines, such as Bing.com, use knowledge graphs to identify people of interest.

Search-engine knowledge panel for the Aberfan disaster

Applying this idea to the Newspaper dataset and running a query for Gallipoli between February 1915 and January 1916 and counting the results in the NEL database returns the names most reported.

Fought during the First World War (1914-18) from 25 April 1915 to 9 January 1916, Gallipoli was the first major amphibious operation in modern warfare. British Empire and French troops landed on the Ottoman-held peninsula in the Dardanelles Straits with disastrous consequences for the Allies. National Army Museum (2019). Gallipoli campaign | National Army Museum. [Online] Nam.ac.uk. Available at: https://www.nam.ac.uk/explore/gallipoli [Accessed 16 May 2022].

Names most frequently found in Gallipoli newspaper articles
NameQIDOccurrencesNotes
Ian HamiltonQ69961788British Army officer. Ian Hamilton on Wikipedia.
John FrenchQ33505942Senior British Army officer. John French on Wikipedia.
Lloyd GeorgeQ13498242British politician and Prime Minister. David Lloyd George on Wikipedia.
Achi BabaN/A41Incorrectly labelled as a person. Achi Baba (Turkish: Alçıtepe) is a height dominating the Gallipoli Peninsula in Turkey, located in Çanakkale Province. Achi Baba on Wikipedia.
M.A.N/A19Incorrectly labelled as a person.
Gaba TepeN/A18Incorrectly labelled as a person.
Ari BurnuN/A16Incorrectly labelled as a person. Gaba Tepe is a headland overlooking the northern Aegean Sea. Kabatepe on Wikipedia.
Charles MonroQ95563715British Army general in the First World War. Charles Monro on Wikipedia.
Edward GreyQ33518714British Liberal statesman. Edward Grey on Wikipedia.
Ian HamiltonQ69961712British Army officer. Ian Hamilton on Wikipedia.