Find Country Entities in Texts
This example shows another application of TextCases, in this case to recognize countries in a given text.
Construct a list of three historical periods.
In[1]:=
periods = {Entity["HistoricalPeriod", "EuropeanRenaissance"],
Entity["HistoricalPeriod", "AgeEnlightenment"],
Entity["HistoricalPeriod", "IndustrialRevolution"]};
Extract their respective names.
In[2]:=
names = CommonName[periods]
Out[2]=
Use WikipediaData to retrieve the text on the page for each historical era.
In[3]:=
wikipages = WikipediaData /@ names;
Use TextCases to extract the countries mentioned on each of those pages, deleting duplicate mentions.
In[4]:=
countries =
DeleteDuplicates[TextCases[#, "Country" -> "Interpretation"]] & /@
wikipages;
For instance, these are the countries found on the page for the European Renaissance.
In[5]:=
First[countries]
Out[5]=
Plot on respective world maps the countries mentioned in each article.
show complete Wolfram Language input
Out[6]=