Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More adjective rules and a test for GetAdjective against all major cities in the world #360

Merged
merged 6 commits into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions commonItems.UnitTests/Linguistics/StringExtensionsTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using commonItems.Linguistics;
using Csv;
using FluentAssertions;
using System;
using System.IO;
using System.Linq;
using System.Net;
using Xunit;

namespace commonItems.UnitTests.Linguistics;
Expand Down Expand Up @@ -181,6 +184,13 @@
[InlineData("Mcif", "Mcifi")]
[InlineData("Maqomo", "Maqomo")]
[InlineData("Frej", "Frejite")]
[InlineData("Trelew", "Trelewense")]
[InlineData("Nanaimo", "Nanaimoite")]
[InlineData("Envigado", "Envigadeño")]
[InlineData("Chigorodó", "Chigorodoseño")]
[InlineData("San Bernardo", "San Bernardino")]
[InlineData("Encantado", "Encantense")]
[InlineData("Lincoln", "Lincolnite")]

// adjectives relying on rewrite rules
[InlineData("Armenia Maioris", "Greater Armenian")]
Expand Down Expand Up @@ -472,6 +482,35 @@
}
}

[Fact]
public void AdjectiveRuleExistsForEveryCountryAndMajorCityInTheWorld() {
var csvUrl = "https://datahub.io/core/world-cities/r/world-cities.csv";
var csv = new WebClient().DownloadString(csvUrl);

Check warning on line 488 in commonItems.UnitTests/Linguistics/StringExtensionsTests.cs

View workflow job for this annotation

GitHub Actions / test_and_check_coverage

'WebClient.WebClient()' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.' (https://aka.ms/dotnet-warnings/SYSLIB0014)

Check warning on line 488 in commonItems.UnitTests/Linguistics/StringExtensionsTests.cs

View workflow job for this annotation

GitHub Actions / test (self-hosted, windows)

'WebClient.WebClient()' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.' (https://aka.ms/dotnet-warnings/SYSLIB0014)

Check warning on line 488 in commonItems.UnitTests/Linguistics/StringExtensionsTests.cs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

'WebClient.WebClient()' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.' (https://aka.ms/dotnet-warnings/SYSLIB0014)
var cities = CsvReader.ReadFromText(csv)
.Select(line => line[0])
.Where(city => !string.IsNullOrEmpty(city) && !city.StartsWith("Zürich (Kreis"))
.Distinct()
.ToList();

var countries = CsvReader.ReadFromText(csv)
.Select(line => line[1])
.Where(country => !string.IsNullOrEmpty(country))
.Distinct()
.ToList();

var output = new StringWriter();
Console.SetOut(output);

foreach (var city in cities) {
_ = city.GetAdjective();
}

foreach (var country in countries) {
_ = country.GetAdjective();
}
output.ToString().Should().NotContain("No matching adjective rule found");
}

[Theory]
// ReSharper disable StringLiteralTypo
[InlineData("Vilath#?!", "Vilathian")]
Expand Down
9 changes: 8 additions & 1 deletion commonItems/Linguistics/adjective_rules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
{"*anon", "*anese"}, // Lebanon
{"*anya", "*anyan"}, // Netanya
{"*aras", "*arentine"}, // Taras
{"*ardo", "*ardino"}, // San Bernardo
{"*aros", "*arian"}, // Paros
{"*atar", "*atari"}, // Qatar
{"*atte", "*atian"}, // Ville Platte
Expand Down Expand Up @@ -235,6 +236,7 @@
{"*etus", "*esian"}, // Miletus
{"*ford", "*fordian"}, // Bedford
{"*furt", "*furter"}, // Frankfurt
{"*gado", "*gadeño"}, // Envigado
{"*gamo", "*gamasque"}, // Bergamo
{"*gano", "*ganese"}, // Lugano
{"*gana", "*ganite"}, // Telangana
Expand Down Expand Up @@ -341,6 +343,7 @@
{"*[c]cis", "*[c]cidian"}, // Chalcis
{"*[c]nai", "*[c]naite"}, // Chennai
{"*[v]ris", "*[v]risian"}, // Marmaris
{"*[v]ado", "*[v]ense"}, // Encantado
{"*[c]ver", "*[c]ver"}, // Denver
{"*[v]ver", "*[v]verian"}, // Hanover

Expand Down Expand Up @@ -407,6 +410,7 @@
{"*ice", "*icean"}, // Nice
{"*ier", "*ieran"}, // Napier
{"*iev", "*ievan"}, // Kiev
{"*imo", "*imoite"}, // Nanaimo
{"*ing", "*ingite"}, // Kuching
{"*ini", "*inian"}, // Leontini
{"*inz", "*inzer"}, // Linz
Expand Down Expand Up @@ -548,6 +552,7 @@
{"*ce", "*cian"}, // Thrace
{"*co", "*can"}, // Morocco
{"*de", "*dean"}, // Cape Verde
{"*dó", "*doseño"}, // Chigorodó
{"*du", "*dunite"}, // Ordu
{"*eh", "*ehi"},
{"*ej", "*ejite"},
Expand All @@ -557,7 +562,8 @@
{"*én", "*enés"}, // Jaén
{"*eo", "*ean"}, // Bengeo
{"*er", "*erite"}, // Casper
{"*es", "*ian"}, // Maldives
{"*es", "*ian"}, // Maldives,
{"*ew", "*ewense"}, // Trelew
{"*ge", "*ginian"}, // Carthage
{"*gh", "*ghian"}, // Middlesbroughian
{"*gk", "*gkan"},
Expand All @@ -581,6 +587,7 @@
{"*ku", "*kuvian"}, // Baku
{"*ld", "*ldian"}, // Chesterfield
{"*ll", "*llese"}, // Marshall
{"*ln", "*lnite"}, // https://en.wikipedia.org/wiki/Lincoln,_Nebraska
{"*lo", "*lonian"}, // Buffalo
{"*lu", "*lan"}, // Honolulu
{"*me", "*man"}, // Rome
Expand Down
2 changes: 1 addition & 1 deletion commonItems/commonItems.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<PackageId>PGCG.$(AssemblyName)</PackageId>
<Version>8.4.1</Version>
<Version>8.4.2</Version>
<Authors>PGCG</Authors>
<PackageProjectUrl>https://github.com/ParadoxGameConverters/commonItems.NET</PackageProjectUrl>
<RepositoryUrl>https://github.com/ParadoxGameConverters/commonItems.NET</RepositoryUrl>
Expand Down
Loading