Historical Information in Wolfram|Alpha and the Wolfram Language

Cesar Loli, WRSA

Join the Conversation #WolframTechConf

Computational History

A whole new area of knowledge for the Wolfram Language.

We have gathered historical information about military conflicts and historical countries, we hope to enlarge this scope and at the same time deepen our data on these fields.

It can be used for several purposes when used in conjunction with the functions in the Wolfram Language.

As a teaching tool for history in a more didactic way employing the use of maps and charts.

For complex calculations with the data available to draw conclusions about history.

Let’s see an example!

Second Punic War

Wolfram|Alpha provides the principal information regarding military conflicts, just like this one.

To further explore this event, we will use functions in the Wolfram Language.

Geopolitical Context

Something very useful we can do with the WL is to provide geographical context by showing the nations that existed around the years of the conflict

With[{colorFunction=Association@(Rule@@@Transpose@{#,ColorData[1]/@Range[Length[#]]}&@EntityList["HistoricalCountry"])},
Manipulate[Legended[GeoGraphics[Transpose@{colorFunction/@Keys[#],Tooltip@@@Transpose@{Values[#],Keys[#]}},GeoBackground->{"CountryBorders",date["Year"]},GeoRange->{(EntityClass["Western Europe", EntityClass["Country","WesternEurope"], "EntityClass[\"Country\", \"WesternEurope\"]", "countries"]),(EntityClass["North Africa", EntityClass["Country","NorthAfrica"], "EntityClass[\"Country\", \"NorthAfrica\"]", "countries"])}],SwatchLegend[colorFunction/@Keys[#],Keys[#]]]&@DeleteMissing[First/@Select[EntityValue[EntityClass["HistoricalCountry",{"ContemporaryCountriesForYearWithPolygon",date["Year"]}],{Dated["Polygon",date],"CurrentCountries"},"EntityAssociation"],IntersectingQ[#[[2]],Join[EntityList[(EntityClass["Western Europe", EntityClass["Country","WesternEurope"], "EntityClass[\"Country\", \"WesternEurope\"]", "countries"])],EntityList[(EntityClass["North Africa", EntityClass["Country","NorthAfrica"], "EntityClass[\"Country\", \"NorthAfrica\"]", "countries"])]]]&]],{{date,(Entity["Second Punic War", Entity["MilitaryConflict","SecondPunicWar"], "Entity[\"MilitaryConflict\", \"SecondPunicWar\"]", "military conflict"])["EndDate"],"Date"},Thread[(Entity["Second Punic War", Entity["MilitaryConflict","SecondPunicWar"], "Entity[\"MilitaryConflict\", \"SecondPunicWar\"]", "military conflict"])[{"StartDate","EndDate"}]->({"Start Date","End Date"})]}]]

The Roman Republic

Before analyzing the Second Punic War we can use the data we have to learn more about one of the key participants: the Roman Republic.

For example, when did the Roman Republic reached its peak, and how did it looked out back then.

GeoGraphics[Polygon[(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"])],GeoBackground->{"CountryBorders",First[DateObject/@(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"])["Polygon","Date"]]}]

DateObject/@(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"])["Polygon","Date"]

We can also determine which current nations are most similar in area to the Roman Republic at that time

nearestCountryArea=Nearest[EntityValue["Country","Area","EntityAssociation"],DistanceFunction->(QuantityMagnitude[Abs[#1-#2],"Kilometers"^2]&)];

nearestCountryArea[GeoArea[Polygon[(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"])]],3]

And even cross references to find out notable people born there.

romans=Keys[Select[GeoWithinQ@@@Select[MapAt[Dated[(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"]),#]["Polygon"]&,EntityValue[EntityClass["Person",{"BirthDate"->Interval[EntityValue[(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"]),{"StartDate","EndDate"}]]}],{"BirthDate","BirthPlace"},"EntityAssociation"],{All,1}],FreeQ[#,_Missing,∞]&],Identity]]

Military History of Rome

Using the information we have gathered from military conflicts we can show the major conflicts faced by them

TimelinePlot[Keys@Select[EntityValue[EntityClass["MilitaryConflict",{"StartDate"->Interval[(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"])[{"StartDate","EndDate"}]]}],{"MainActors","Battles"},"EntityAssociation"],MemberQ[#,(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"]),∞]&&!MemberQ[#,_Missing,∞]&]]

And also make a histogram showing the amount of conflicts Rome was involved through the years

DateHistogram[Select[EntityValue[EntityClass["MilitaryConflict",{"StartDate"->Interval[(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"])[{"StartDate","EndDate"}]]}],{"MainActors","Battles","EndDate"}],MemberQ[#,(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"]),∞]&&MemberQ[#,_Missing,∞]&][[All,-1]]]

Evolution of Rome

Not only that, but we can see how the Punic Wars were the beginning of the rise of Roman civilization

areas=Function[entity,{#[[1]],Quiet@GeoArea[#[[2]]]}&/@DeleteCases[{#,Polygon@Dated[entity,#]}&/@DateRange[entity["StartDate"],entity["EndDate"],Quantity[10,"Years"]],{_,_Missing}]]/@{(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"]),(Entity["Roman Empire", Entity["HistoricalCountry","RomanEmpire"], "Entity[\"HistoricalCountry\", \"RomanEmpire\"]", "historical country"]),(Entity["Western Roman Empire", Entity["HistoricalCountry","WesternRomanEmpire"], "Entity[\"HistoricalCountry\", \"WesternRomanEmpire\"]", "historical country"]),(Entity["Byzantine Empire", Entity["HistoricalCountry","ByzantineEmpire"], "Entity[\"HistoricalCountry\", \"ByzantineEmpire\"]", "historical country"]),(Entity["Latin Empire", Entity["HistoricalCountry","LatinEmpire"], "Entity[\"HistoricalCountry\", \"LatinEmpire\"]", historical country])};

StackedDateListPlot[Append[Prepend[#,{#[[1,1]]-Quantity[10,"Years"],0}],{#[[-1,1]]+Quantity[10,"Years"],0}]&/@(areas)/._Missing:>0,PlotLegends->{(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"]),(Entity["Roman Empire", Entity["HistoricalCountry","RomanEmpire"], "Entity[\"HistoricalCountry\", \"RomanEmpire\"]", "historical country"]),(Entity["Western Roman Empire", Entity["HistoricalCountry","WesternRomanEmpire"], "Entity[\"HistoricalCountry\", \"WesternRomanEmpire\"]", "historical country"]),(Entity["Byzantine Empire", Entity["HistoricalCountry","ByzantineEmpire"], "Entity[\"HistoricalCountry\", \"ByzantineEmpire\"]", "historical country"]),(Entity["Latin Empire", Entity["HistoricalCountry","LatinEmpire"], "Entity[\"HistoricalCountry\", \"LatinEmpire\"]", historical country])},GridLines->{{(Entity["Fourth Crusade", Entity["HistoricalEvent","FourthCrusade"], "Entity[\"HistoricalEvent\", \"FourthCrusade\"]", "historical event"])["EndDate"],DateObject@{117}},None},PlotLabels->(Callout[#,{#["EndDate"],Above}]&/@{(Entity["First Punic War", Entity["MilitaryConflict","FirstPunicWar"], "Entity[\"MilitaryConflict\", \"FirstPunicWar\"]", "military conflict"]),(Entity["Second Punic War", Entity["MilitaryConflict","SecondPunicWar"], "Entity[\"MilitaryConflict\", \"SecondPunicWar\"]", "military conflict"]),(Entity["Fourth Crusade", Entity["HistoricalEvent","FourthCrusade"], "Entity[\"HistoricalEvent\", \"FourthCrusade\"]", "historical event"])})]

Area Analysis

With the information we have about both nations we can plot the territorial area covered by both countries and review it in a time interval dating 50 years before the start of the war to 50 years after it ended

DateListPlot[With[{dateRange=DateRange[(Entity["Second Punic War", Entity["MilitaryConflict","SecondPunicWar"], "Entity[\"MilitaryConflict\", \"SecondPunicWar\"]", "military conflict"])["StartDate"]-Quantity[50,"Years"],(Entity["Second Punic War", Entity["MilitaryConflict","SecondPunicWar"], "Entity[\"MilitaryConflict\", \"SecondPunicWar\"]", "military conflict"])["EndDate"]+Quantity[50,"Years"]]},Transpose@{dateRange,#}&/@Map[GeoArea,EntityValue[{(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"]),(Entity["Carthage", Entity["HistoricalCountry","Carthage"], "Entity[\"HistoricalCountry\", \"Carthage\"]", "historical country"])},Dated["Polygon",#]&/@dateRange],{2}]],GridLines->{{(Entity["Second Punic War", Entity["MilitaryConflict","SecondPunicWar"], "Entity[\"MilitaryConflict\", \"SecondPunicWar\"]", "military conflict"])["StartDate"],(Entity["Second Punic War", Entity["MilitaryConflict","SecondPunicWar"], "Entity[\"MilitaryConflict\", \"SecondPunicWar\"]", "military conflict"])["EndDate"]},None},GridLinesStyle->Directive[Red,Thick, Dashed],PlotLegends->{(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"]),(Entity["Carthage", Entity["HistoricalCountry","Carthage"], "Entity[\"HistoricalCountry\", \"Carthage\"]", "historical country"])}]

We can check how the area covered by the Roman Republic at the beginning of the war compares against the area covered in its maximum expansion

UnitConvert[GeoArea[Polygon[Dated[(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"]),(Entity["Second Punic War", Entity["MilitaryConflict","SecondPunicWar"], "Entity[\"MilitaryConflict\", \"SecondPunicWar\"]", "military conflict"])["StartDate"]]]]/GeoArea[Polygon[(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"])]],"Percent"]

This might seem quite small compared with the maximum expansion of the Roman civilization as a whole

UnitConvert[GeoArea[Polygon[Dated[(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"]),(Entity["Second Punic War", Entity["MilitaryConflict","SecondPunicWar"], "Entity[\"MilitaryConflict\", \"SecondPunicWar\"]", "military conflict"])["StartDate"]]]]/Max[GeoArea[Polygon/@{(Entity["Roman Kingdom", Entity["HistoricalCountry","RomanKingdom"], "Entity[\"HistoricalCountry\", \"RomanKingdom\"]", "historical country"]),(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"]),(Entity["Roman Empire", Entity["HistoricalCountry","RomanEmpire"], "Entity[\"HistoricalCountry\", \"RomanEmpire\"]", "historical country"])}]],"Percent"]

At the start of the war, Rome was similar in size to Vietnam

nearestCountryArea[GeoArea[Polygon[Dated[(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"]),(Entity["Second Punic War", Entity["MilitaryConflict","SecondPunicWar"], "Entity[\"MilitaryConflict\", \"SecondPunicWar\"]", "military conflict"])["StartDate"]]]],3]

In the other hand,Carthage was left at little over 9% of its original size

UnitConvert[Divide@@(GeoArea/@Polygon/@(Dated[(Entity["Carthage", Entity["HistoricalCountry","Carthage"], "Entity[\"HistoricalCountry\", \"Carthage\"]", "historical country"]),#]&/@(Entity["Second Punic War", Entity["MilitaryConflict","SecondPunicWar"], "Entity[\"MilitaryConflict\", \"SecondPunicWar\"]", "military conflict"])[{"EndDate","StartDate"}])),"Percent"]

Comparing with current countries

nearestCountryArea[GeoArea[Polygon[Dated[(Entity["Carthage", Entity["HistoricalCountry","Carthage"], "Entity[\"HistoricalCountry\", \"Carthage\"]", "historical country"]),(Entity["Second Punic War", Entity["MilitaryConflict","SecondPunicWar"], "Entity[\"MilitaryConflict\", \"SecondPunicWar\"]", "military conflict"])["StartDate"]]]],3]

nearestCountryArea[GeoArea[Polygon[Dated[(Entity["Carthage", Entity["HistoricalCountry","Carthage"], "Entity[\"HistoricalCountry\", \"Carthage\"]", "historical country"]),(Entity["Second Punic War", Entity["MilitaryConflict","SecondPunicWar"], "Entity[\"MilitaryConflict\", \"SecondPunicWar\"]", "military conflict"])["EndDate"]]]],3]

And visually:

Row[{GeoListPlot[(Entity["Iraq", Entity["Country","Iraq"], "Entity[\"Country\", \"Iraq\"]", "country"]),GeoRange->Quantity[500,"Kilometers"],GeoCenter->(Entity["Iraq", Entity["Country","Iraq"], "Entity[\"Country\", \"Iraq\"]", "country"]),GeoProjection->{"Orthographic","Center"->(Entity["Iraq", Entity["Country","Iraq"], "Entity[\"Country\", \"Iraq\"]", "country"])},ImageSize->Scaled[.45]],"->" ,GeoListPlot[(Entity["Netherlands", Entity["Country","Netherlands"], "Entity[\"Country\", \"Netherlands\"]", "country"]),GeoRange->Quantity[500,"Kilometers"],GeoCenter->(Entity["Netherlands", Entity["Country","Netherlands"], "Entity[\"Country\", \"Netherlands\"]", "country"]),GeoProjection->{"Orthographic","Center"->(Entity["Netherlands", Entity["Country","Netherlands"], "Entity[\"Country\", \"Netherlands\"]", "country"])},ImageSize->Scaled[.45]]}]

Map of Carthage and Rome during the Second Punic War

We can see here a map showing the territories covered by each of the participants in the war changing through the course of the conflict

ListAnimate[Table[Legended[GeoGraphics[{Red,Polygon[Dated[(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"]),i]],Blue,Polygon[Dated[(Entity["Carthage", Entity["HistoricalCountry","Carthage"], "Entity[\"HistoricalCountry\", \"Carthage\"]", "historical country"]),i]]},GeoBackground->{"CountryBorders",i},GeoRange->{(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"]),(Entity["Carthage", Entity["HistoricalCountry","Carthage"], "Entity[\"HistoricalCountry\", \"Carthage\"]", "historical country"])},PlotLabel->Style[Row[{"Map of Rome and Carthage in year ",i}],16]],SwatchLegend[{Red,Blue},{(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"]),(Entity["Carthage", Entity["HistoricalCountry","Carthage"], "Entity[\"HistoricalCountry\", \"Carthage\"]", "historical country"])}]],{i,(Entity["Second Punic War", Entity["MilitaryConflict","SecondPunicWar"], "Entity[\"MilitaryConflict\", \"SecondPunicWar\"]", "military conflict"])["StartDate"]["Year"],(Entity["Second Punic War", Entity["MilitaryConflict","SecondPunicWar"], "Entity[\"MilitaryConflict\", \"SecondPunicWar\"]", "military conflict"])["EndDate"]["Year"],1}]]

Battle locations in Map

We can cross reference the data we have of each battle with the maps of the nations involved showing a map of the territories of both nations in the date the battle took place alongside a marker showing the battle exact location.

Manipulate[GeoGraphics[{GeoMarker[Event],Red,Polygon@Dated[(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"]),Event["StartDate"]],Blue,Polygon@Dated[(Entity["Carthage", Entity["HistoricalCountry","Carthage"], "Entity[\"HistoricalCountry\", \"Carthage\"]", "historical country"]),Event["StartDate"]]},PlotLabel->Style["Map of Rome and Carthage in year "<>DateString[Event["StartDate"],"Year"],16],GeoBackground->Dated["CountryBorders",Event["StartDate"]],GeoRange->{(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"]),(Entity["Carthage", Entity["HistoricalCountry","Carthage"], "Entity[\"HistoricalCountry\", \"Carthage\"]", "historical country"])}],{Event,SortBy[Select[(Entity["Second Punic War", Entity["MilitaryConflict","SecondPunicWar"], "Entity[\"MilitaryConflict\", \"SecondPunicWar\"]", "military conflict"])["Battles"],!MatchQ[#["Position"],_Missing]&],AbsoluteTime@#["StartDate"]&]}]

Analyzing the positions of the battles geographically

We can find clusters and classify the battles geographically

GeoListPlot@FindClusters[DeleteMissing[EntityValue[(Entity["Second Punic War", Entity["MilitaryConflict","SecondPunicWar"], "Entity[\"MilitaryConflict\", \"SecondPunicWar\"]", "military conflict"])["Battles"],"Position","EntityAssociation"]]]

Or use a combination of geographic distance with date difference to catalog and group the battles not only geographically but chronologically.

groupedBattles=SortBy[SortBy[#,AbsoluteTime[#["EndDate"]]&]&/@FindClusters[Select[EntityValue[(Entity["Second Punic War", Entity["MilitaryConflict","SecondPunicWar"], "Entity[\"MilitaryConflict\", \"SecondPunicWar\"]", "military conflict"])["Battles"],{"EndDate","Position"},"EntityAssociation"],!MemberQ[#,_Missing,∞]&],5,DistanceFunction->(QuantityMagnitude@GeoDistance[#2[[2]],#1[[2]]]3.9274190380221903`+ Abs[QuantityMagnitude@DateDifference[#2[[1]],#1[[1]],"Day"]]&)],AbsoluteTime[#[[1]]["EndDate"]]&];

GeoListPlot[groupedBattles]

TimelinePlot[groupedBattles,AxesOrigin->Top]

Progression of accumulated casualties

We can use the data of casualties per faction in each battle to make a chart showing the amount of casualties suffered by each faction during the war

battlesWithDatesAndCasualties=(SortBy[EntityValue[(Entity["Second Punic War", Entity["MilitaryConflict","SecondPunicWar"], "Entity[\"MilitaryConflict\", \"SecondPunicWar\"]", "military conflict"])[(EntityProperty["battles", EntityProperty["MilitaryConflict","Battles"], "EntityProperty[\"MilitaryConflict\", \"Battles\"]"])],{"EndDate",EntityProperty["MilitaryConflict","MilitaryCasualties",{"Faction"->"First"}],EntityProperty["MilitaryConflict","MilitaryCasualties",{"Faction"->"Second"}]},"EntityAssociation"],AbsoluteTime@First@#&]/.{_Missing:>0,a_Interval:>Mean[a[[1]]]});

DateListPlot[{MapThread[Callout[#1,#2]&,{Transpose@{Values[#][[All,1]],Accumulate[Values[#][[All,2]]]},Keys[#]}],MapThread[Callout[#1,#2]&,{Transpose@{Values[#][[All,1]],Accumulate[Values[#][[All,3]]]},Keys[#]}]}&@battlesWithDatesAndCasualties,ImageSize->Large]

Military Conflict Statistics

We can analyze the top 5 conflicts by the total amount of forces involved.

Dataset[<|"Rome"->#[[1]],"Carthage"->#[[2]]|>&/@EntityValue[EntityClass["MilitaryConflict",{Append[(EntityProperty["military forces", EntityProperty["MilitaryConflict","ForcesMilitaryForces"], "EntityProperty[\"MilitaryConflict\", \"ForcesMilitaryForces\"]"]),{"Faction"->"Total"}]->TakeLargest[5],(EntityProperty["parent conflict", EntityProperty["MilitaryConflict","ParentConflict"], "EntityProperty[\"MilitaryConflict\", \"ParentConflict\"]"])->(Entity["Second Punic War", Entity["MilitaryConflict","SecondPunicWar"], "Entity[\"MilitaryConflict\", \"SecondPunicWar\"]", "military conflict"])}],(EntityProperty["military forces", EntityProperty["MilitaryConflict","ForcesMilitaryForces"], "EntityProperty[\"MilitaryConflict\", \"ForcesMilitaryForces\"]"]),"EntityAssociation"]]

Or by the use of elephants

Dataset[<|"Rome"->#[[1]],"Carthage"->#[[2]]|>&/@EntityValue[EntityClass["MilitaryConflict",{Append[(EntityProperty["war elephants", EntityProperty["MilitaryConflict","ForcesWarElephants"], "EntityProperty[\"MilitaryConflict\", \"ForcesWarElephants\"]"]),{"Faction"->"Total"}]->TakeLargest[5],(EntityProperty["parent conflict", EntityProperty["MilitaryConflict","ParentConflict"], "EntityProperty[\"MilitaryConflict\", \"ParentConflict\"]"])->(Entity["Second Punic War", Entity["MilitaryConflict","SecondPunicWar"], "Entity[\"MilitaryConflict\", \"SecondPunicWar\"]", "military conflict"])}],(EntityProperty["war elephants", EntityProperty["MilitaryConflict","ForcesWarElephants"], "EntityProperty[\"MilitaryConflict\", \"ForcesWarElephants\"]"]),"EntityAssociation"]]

Comparing these with the largest battles in the history of the Roman Republic

Dataset[Association[Thread[Column/@#[[1]]->#[[2]]]]&/@SortBy[Select[EntityValue[EntityClass["MilitaryConflict",{"EndDate"->Interval[EntityValue[(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"]),{"StartDate","EndDate"}]]}],{"MainActors",(EntityProperty["military forces", EntityProperty["MilitaryConflict","ForcesMilitaryForces"], "EntityProperty[\"MilitaryConflict\", \"ForcesMilitaryForces\"]"]),"Battles"},"EntityAssociation"],MemberQ[#,(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"]),∞]&&MatchQ[#[[3]],_Missing]&],-Total[DeleteMissing[#[[2]]]]&][[;;5]]]

Examining forces in each individual battle

Forces comparison

We can also analyze each battle individually by comparing the forces of both participants

Manipulate[BarChart[battle/@{{(EntityProperty[(RowDefault["infantry", " | ", (RowWithSeparators[;, ";", "First"])]), EntityProperty["MilitaryConflict","ForcesInfantry",{"Faction"->"First"}], "EntityProperty[\"MilitaryConflict\", \"ForcesInfantry\", {\"Faction\" -> \"First\"}]"]),(EntityProperty[(RowDefault["cavalry", " | ", (RowWithSeparators[;, ";", "First"])]), EntityProperty["MilitaryConflict","ForcesCavalry",{"Faction"->"First"}], "EntityProperty[\"MilitaryConflict\", \"ForcesCavalry\", {\"Faction\" -> \"First\"}]"])},{(EntityProperty[(RowDefault["infantry", " | ", (RowWithSeparators[;, ";", "Second"])]), EntityProperty["MilitaryConflict","ForcesInfantry",{"Faction"->"Second"}], "EntityProperty[\"MilitaryConflict\", \"ForcesInfantry\", {\"Faction\" -> \"Second\"}]"]),(EntityProperty[(RowDefault["cavalry", " | ", (RowWithSeparators[;, ";", "Second"])]), EntityProperty["MilitaryConflict","ForcesCavalry",{"Faction"->"Second"}], "EntityProperty[\"MilitaryConflict\", \"ForcesCavalry\", {\"Faction\" -> \"Second\"}]"])}},ChartLayout->"Stacked",ChartLegends->{(EntityProperty["infantry", EntityProperty["MilitaryConflict","ForcesInfantry",{}], "EntityProperty[\"MilitaryConflict\", \"ForcesInfantry\", {}]"]),(EntityProperty["cavalry", EntityProperty["MilitaryConflict","ForcesCavalry",{}], "EntityProperty[\"MilitaryConflict\", \"ForcesCavalry\", {}]"])},ChartLabels->{{"Rome","Carthage"},None}],{battle,{(Entity["Battle of Cannae", Entity["MilitaryConflict","BattleOfCannae"], "Entity[\"MilitaryConflict\", \"BattleOfCannae\"]", "military conflict"]),(Entity["Battle of Zama", Entity["MilitaryConflict","BattleOfZama"], "Entity[\"MilitaryConflict\", \"BattleOfZama\"]", "military conflict"])}}]

It is interesting to note that both battles were won by the faction with inferior infantry but superior cavalry

We can also examine the conflict by analyzing its most important commanders in each side

Timeline of Hannibal

This shows a timeline of Hannibal, leader of the Carthaginian forces during the Second Punic War

TimelinePlot[{{Interval[(Entity["Hannibal", Entity["Person","Hannibal::776n3"], "Entity[\"Person\", \"Hannibal::776n3\"]", "person"])[{"BirthDate","DeathDate"}]]->(Entity["Hannibal", Entity["Person","Hannibal::776n3"], "Entity[\"Person\", \"Hannibal::776n3\"]", "person"])},Keys@Select[EntityValue[EntityClass["MilitaryConflict",{"EndDate"->Interval[(Entity["Hannibal", Entity["Person","Hannibal::776n3"], "Entity[\"Person\", \"Hannibal::776n3\"]", "person"])[{"BirthDate","DeathDate"}]]}],"Commanders","EntityAssociation"],MemberQ[#,(Entity["Hannibal", Entity["Person","Hannibal::776n3"], "Entity[\"Person\", \"Hannibal::776n3\"]", "person"]),∞]&]}]

And the odds he faced in each battle

<|"Roman Forces"->#[[2,1]],"Carthaginian Forces"->#[[2,2]],"Odds Faced"->N[#[[2,1]]/#[[2,2]],2],"Outcome"->Column@#[[-1]]|>&/@SortBy[Select[EntityValue[(Entity["Second Punic War", Entity["MilitaryConflict","SecondPunicWar"], "Entity[\"MilitaryConflict\", \"SecondPunicWar\"]", "military conflict"])["Battles"],{"Commanders","ForcesMilitaryForces","EndDate","OutcomeNotes"},"EntityAssociation"],MemberQ[#,(Entity["Hannibal", Entity["Person","Hannibal::776n3"], "Entity[\"Person\", \"Hannibal::776n3\"]", "person"]),∞]&&FreeQ[#[[2]],_Missing]&],AbsoluteTime@#[[-2]]&]//Dataset

Scipio Africanus

We can now take a closer look to Hannibal' s rival, Scipio Africanus. We can create a timeline of the battles which he commanded.

TimelinePlot[{{Interval[(Entity["Scipio Africanus", Entity["Person","ScipioAfricanus::s4b3r"], "Entity[\"Person\", \"ScipioAfricanus::s4b3r\"]", "person"])[{"BirthDate","DeathDate"}]]->(Entity["Scipio Africanus", Entity["Person","ScipioAfricanus::s4b3r"], "Entity[\"Person\", \"ScipioAfricanus::s4b3r\"]", "person"])},Keys@Select[EntityValue[EntityClass["MilitaryConflict",{"EndDate"->Interval[(Entity["Scipio Africanus", Entity["Person","ScipioAfricanus::s4b3r"], "Entity[\"Person\", \"ScipioAfricanus::s4b3r\"]", "person"])[{"BirthDate","DeathDate"}]]}],"Commanders","EntityAssociation"],MemberQ[#,(Entity["Scipio Africanus", Entity["Person","ScipioAfricanus::s4b3r"], "Entity[\"Person\", \"ScipioAfricanus::s4b3r\"]", "person"]),∞]&]}]

When did they meet?

It’s interesting that these two famous commanders of the Second Punic war only met once at the Battle of Zama

TimelinePlot[{{Interval[(Entity["Scipio Africanus", Entity["Person","ScipioAfricanus::s4b3r"], "Entity[\"Person\", \"ScipioAfricanus::s4b3r\"]", "person"])[{"BirthDate","DeathDate"}]]->(Entity["Scipio Africanus", Entity["Person","ScipioAfricanus::s4b3r"], "Entity[\"Person\", \"ScipioAfricanus::s4b3r\"]", "person"]),Interval[(Entity["Hannibal", Entity["Person","Hannibal::776n3"], "Entity[\"Person\", \"Hannibal::776n3\"]", "person"])[{"BirthDate","DeathDate"}]]->(Entity["Hannibal", Entity["Person","Hannibal::776n3"], "Entity[\"Person\", \"Hannibal::776n3\"]", "person"])},Keys@Select[EntityValue[EntityClass["MilitaryConflict",{"EndDate"->Interval[(Entity["Scipio Africanus", Entity["Person","ScipioAfricanus::s4b3r"], "Entity[\"Person\", \"ScipioAfricanus::s4b3r\"]", "person"])[{"BirthDate","DeathDate"}]]}],"Commanders","EntityAssociation"],MemberQ[#,(Entity["Scipio Africanus", Entity["Person","ScipioAfricanus::s4b3r"], "Entity[\"Person\", \"ScipioAfricanus::s4b3r\"]", "person"]),∞]&&MemberQ[#,(Entity["Hannibal", Entity["Person","Hannibal::776n3"], "Entity[\"Person\", \"Hannibal::776n3\"]", "person"]),∞]&]}]

Other calculations with Historical Data

There are some computations that couldn’t be appropriately exemplified with the Second Punic War but are interesting to examine more closely.

Sub-conflicts Graph

As conflicts are usually part of larger scale battles, we can use this hierarchy to draw a graph of groups of conflicts

NestGraph[Flatten[DeleteMissing[{#["Subconflicts"]}]] &, (Entity["Pacific War", Entity["MilitaryConflict","PacificWar"], "Entity[\"MilitaryConflict\", \"PacificWar\"]", "military conflict"]), 3, VertexLabels->Placed["Name",Tooltip],ImageSize->Full]

Military Conflicts on this day

We can find out what battles started or ended in a day like today

startDates=EntityValue["MilitaryConflict",{"StartDate","EndDate"},"EntityPropertyAssociation"];

dateRule=Association[#[[1,-1]]->#[[All,;;2]]&/@GatherBy[Flatten[(Function[date,{#[[1]],date[[1]],DateValue[date[[2]],{"Day","Month"}]}]/@#[[2]]&/@Normal[Normal@Select[#,DateValue[#,"Granularity"]=="Day"&]&/@startDates])/.{{e_,_,date_},{e_,_,date_}}:>{{e,"Date",date}},1],Last]];

dateRule@DateValue[Now,{"Day","Month"}]//Column

Battles Nearby

Or, we can use the location data to map the 10 nearest conflicts to our location

nearestConflictsToHere=GeoNearest["MilitaryConflict",Here,10]

TimelinePlot[Select[nearestConflictsToHere,!MatchQ[#["EndDate"],_Missing]&]]

Rule@@@Tally[DeleteMissing[Flatten[EntityValue[GeoNearest["MilitaryConflict",Here,10],"ParentConflict"]]]]

GeoListPlot[GatherBy[GeoNearest["MilitaryConflict",Here,10],#["ParentConflict"]&]]

Future Work: Winners for military conflicts

The following line shows what battles were won by Hannibal

hannibalBattles=Switch[#[[-1]],Position[#[[1]],(Entity["Hannibal", Entity["Person","Hannibal::776n3"], "Entity[\"Person\", \"Hannibal::776n3\"]", "person"])][[1,1]],"Winner",_Integer,"Loser",_,"Indeterminate"]&/@Select[EntityValue[EntityClass["MilitaryConflict",{"EndDate"->Interval[(Entity["Hannibal", Entity["Person","Hannibal::776n3"], "Entity[\"Person\", \"Hannibal::776n3\"]", "person"])[{"BirthDate","DeathDate"}]]}],{"Commanders","Battles","WinnerFaction"},"EntityAssociation"],MemberQ[#,(Entity["Hannibal", Entity["Person","Hannibal::776n3"], "Entity[\"Person\", \"Hannibal::776n3\"]", "person"]),∞]&&MatchQ[#[[2]],_Missing]&]

PieChart[#[[All,2]],ChartLabels->#[[All,1]]]&@Tally[hannibalBattles]

The following line shows what battles were won by Scipio Africanus

scipioBattles=Switch[#[[-1]],Position[#[[1]],(Entity["Scipio Africanus", Entity["Person","ScipioAfricanus::s4b3r"], "Entity[\"Person\", \"ScipioAfricanus::s4b3r\"]", "person"])][[1,1]],"Winner",_Integer,"Loser",_,"Indeterminate"]&/@Select[EntityValue[EntityClass["MilitaryConflict",{"EndDate"->Interval[(Entity["Scipio Africanus", Entity["Person","ScipioAfricanus::s4b3r"], "Entity[\"Person\", \"ScipioAfricanus::s4b3r\"]", "person"])[{"BirthDate","DeathDate"}]]}],{"Commanders","Battles","WinnerFaction"},"EntityAssociation"],MemberQ[#,(Entity["Scipio Africanus", Entity["Person","ScipioAfricanus::s4b3r"], "Entity[\"Person\", \"ScipioAfricanus::s4b3r\"]", "person"]),∞]&&MatchQ[#[[2]],_Missing]&]

PieChart[#[[All,2]],ChartLabels->#[[All,1]]]&@Tally[scipioBattles]

A map of the different battles of the Second Punic War, the colors represent Roman victories (Orange), Carthaginian (Blue) and indeterminate (Green)

GeoGraphics[GeoMarker[#[[1]],"Color"->#[[2]]]&/@Normal[Switch[#[[1]],1,Orange,2,Blue,_,Darker@Green]&/@Select[EntityValue[(Entity["Second Punic War", Entity["MilitaryConflict","SecondPunicWar"], "Entity[\"MilitaryConflict\", \"SecondPunicWar\"]", "military conflict"])["Battles"],{"WinnerFaction","Position"},"EntityAssociation"],!MatchQ[#[[2]],_Missing]&]]]

Roman and Carthaginian victories with bubble sizes proportional to the total amount of casualties in each conflict

Timeline showing Roman and Carthaginian victories

TimelinePlot[Map[First,GatherBy[Normal[EntityValue[(Entity["Second Punic War", Entity["MilitaryConflict","SecondPunicWar"], "Entity[\"MilitaryConflict\", \"SecondPunicWar\"]", "military conflict"])["Battles"],"WinnerFaction","EntityAssociation"]],#[[2]]&],{2}],PlotLegends->{"Carthaginian Victory","Roman Victory","Inconclusive result"}]

Future Work: GeoIdentify and GeoEntities support for Dated entities (preliminary design)

Identify buildings built in the Roman Republic. This should identify the construction dates for the buildings

GeoEntities[(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"]),"Building"]

Nations in the year 1500 AD located in the territory covered by the Roman Republic at 100 BC

GeoEntities[Dated[(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"]),(DateObject["-100", DateObject[{-100}]])],Dated["HistoricalCountry",(DateObject["1500", DateObject[{1500}]])]]

Battles located within the territory of the Roman Republic (taking into account proposal 1 that said that the location property for the entity outside its DateInterval should be Missing)

GeoEntities[Dated[(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"]),All],Dated["MilitaryConflict",All],"Simultaneous"->True]

What countries have at one time been located in the territories covered by the Roman Republic?

GeoEntities[Dated[(Entity["Roman Republic", Entity["HistoricalCountry","RomanRepublic"], "Entity[\"HistoricalCountry\", \"RomanRepublic\"]", "historical country"]),All],Dated["HistoricalCountry",All],"Simultaneous"->False,"AlwaysCovered"->False]

Identify where a certain building was built

GeoIdentify["HistoricalCountry",(Entity["Pyramid of the Sun", Entity["Building","PiramideDelSolTeotihuacan::gptz6"], "Entity[\"Building\", \"PiramideDelSolTeotihuacan::gptz6\"]", "building"])]

Future Work: New properties for Historical Countries

We plan also to add new properties and features to the historical countries paclet. We plan to add capitals, languages and population among other data.

Historical capitals of the Abbasid Caliphate

Sample of historical population information

Future Work: New Historical Paclets

We plan also to add completely new paclets to the Wolfram Language

Organizations

Organizations should include a broad amount of data not covered by historical countries and many times present as actors in military conflicts such as the factions in a civil war. This should include war factions, military units and other organizations.

Hierarchy of the organizations present in the Free Syrian Army

Historical regions

We also plan to include regions and provinces inside the historical nations we have. This should be an historical counterpart to the AdinistrativeDivisions we currently have

Leaders

The information on Leaders is already scraped but we plan to add it to the Wolfram Language. Here are some examples showing some calculations done with said data

Roman emperors by date

Here it is shown the list of roman emperors with the area difference between the start and end of the reign

Roman emperors sorted by area difference

Here it is shown the greatest expansion done by  roman emperor (Aurelian)

nearestCountryArea@(Quantity[483664, (("mi")^2), miles squared, (("Miles")^2)])