From dddad0eebb0e3f99895745cce4a56c123e9af8da Mon Sep 17 00:00:00 2001 From: Seweryn Presnal Date: Sat, 7 Oct 2023 14:42:27 +0100 Subject: [PATCH 1/6] Test GetAdjective against all major cities in the world --- .../Linguistics/StringExtensionsTests.cs | 22 +++++++++++++++++++ commonItems/Linguistics/adjective_rules.txt | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/commonItems.UnitTests/Linguistics/StringExtensionsTests.cs b/commonItems.UnitTests/Linguistics/StringExtensionsTests.cs index 2964b081..7d8ebe3c 100644 --- a/commonItems.UnitTests/Linguistics/StringExtensionsTests.cs +++ b/commonItems.UnitTests/Linguistics/StringExtensionsTests.cs @@ -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; @@ -181,6 +184,7 @@ public class StringExtensionsTests { [InlineData("Mcif", "Mcifi")] [InlineData("Maqomo", "Maqomo")] [InlineData("Frej", "Frejite")] + [InlineData("Trelew", "Trelewense")] // adjectives relying on rewrite rules [InlineData("Armenia Maioris", "Greater Armenian")] @@ -472,6 +476,24 @@ public void CorrectAdjectivesAreGeneratedForNamesFromCsv(string csvFilePath) { } } + [Fact] + public void AdjectiveRuleExistsForEveryMajorCityInTheWorld() { + var csvUrl = "https://datahub.io/core/world-cities/r/world-cities.csv"; + var csv = new WebClient().DownloadString(csvUrl); + var cities = CsvReader.ReadFromText(csv) + .Select(line => line[0]) + .Where(city => !string.IsNullOrEmpty(city)) + .ToList(); + + var output = new StringWriter(); + Console.SetOut(output); + + foreach (var city in cities) { + _ = city.GetAdjective(); + } + output.ToString().Should().NotContain("No matching adjective rule found"); + } + [Theory] // ReSharper disable StringLiteralTypo [InlineData("Vilath#?!", "Vilathian")] diff --git a/commonItems/Linguistics/adjective_rules.txt b/commonItems/Linguistics/adjective_rules.txt index ec8b5a0d..cc9e16a7 100644 --- a/commonItems/Linguistics/adjective_rules.txt +++ b/commonItems/Linguistics/adjective_rules.txt @@ -557,7 +557,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"}, From c6876a1299711d3c0b234274859844140bceb419 Mon Sep 17 00:00:00 2001 From: Seweryn Presnal Date: Sat, 7 Oct 2023 14:48:21 +0100 Subject: [PATCH 2/6] AdjectiveRuleExistsForEveryCountryAndMajorCityInTheWorld --- .../Linguistics/StringExtensionsTests.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/commonItems.UnitTests/Linguistics/StringExtensionsTests.cs b/commonItems.UnitTests/Linguistics/StringExtensionsTests.cs index 7d8ebe3c..a0cd9889 100644 --- a/commonItems.UnitTests/Linguistics/StringExtensionsTests.cs +++ b/commonItems.UnitTests/Linguistics/StringExtensionsTests.cs @@ -477,12 +477,19 @@ public void CorrectAdjectivesAreGeneratedForNamesFromCsv(string csvFilePath) { } [Fact] - public void AdjectiveRuleExistsForEveryMajorCityInTheWorld() { + public void AdjectiveRuleExistsForEveryCountryAndMajorCityInTheWorld() { var csvUrl = "https://datahub.io/core/world-cities/r/world-cities.csv"; var csv = new WebClient().DownloadString(csvUrl); var cities = CsvReader.ReadFromText(csv) .Select(line => line[0]) .Where(city => !string.IsNullOrEmpty(city)) + .Distinct() + .ToList(); + + var countries = CsvReader.ReadFromText(csv) + .Select(line => line[1]) + .Where(country => !string.IsNullOrEmpty(country)) + .Distinct() .ToList(); var output = new StringWriter(); @@ -491,6 +498,10 @@ public void AdjectiveRuleExistsForEveryMajorCityInTheWorld() { foreach (var city in cities) { _ = city.GetAdjective(); } + + foreach (var country in countries) { + _ = country.GetAdjective(); + } output.ToString().Should().NotContain("No matching adjective rule found"); } From 1accb6ef2a0f8c8d74a86442373e6fbb8041d63b Mon Sep 17 00:00:00 2001 From: Seweryn Presnal Date: Sat, 7 Oct 2023 15:50:43 +0100 Subject: [PATCH 3/6] Rules for Envigado and Nanaimo --- commonItems.UnitTests/Linguistics/StringExtensionsTests.cs | 2 ++ commonItems/Linguistics/adjective_rules.txt | 2 ++ 2 files changed, 4 insertions(+) diff --git a/commonItems.UnitTests/Linguistics/StringExtensionsTests.cs b/commonItems.UnitTests/Linguistics/StringExtensionsTests.cs index a0cd9889..2056146a 100644 --- a/commonItems.UnitTests/Linguistics/StringExtensionsTests.cs +++ b/commonItems.UnitTests/Linguistics/StringExtensionsTests.cs @@ -185,6 +185,8 @@ public class StringExtensionsTests { [InlineData("Maqomo", "Maqomo")] [InlineData("Frej", "Frejite")] [InlineData("Trelew", "Trelewense")] + [InlineData("Nanaimo", "Nanaimoite")] + [InlineData("Envigado", "Envigadeño")] // adjectives relying on rewrite rules [InlineData("Armenia Maioris", "Greater Armenian")] diff --git a/commonItems/Linguistics/adjective_rules.txt b/commonItems/Linguistics/adjective_rules.txt index cc9e16a7..ba4f5009 100644 --- a/commonItems/Linguistics/adjective_rules.txt +++ b/commonItems/Linguistics/adjective_rules.txt @@ -235,6 +235,7 @@ {"*etus", "*esian"}, // Miletus {"*ford", "*fordian"}, // Bedford {"*furt", "*furter"}, // Frankfurt +{"*gado", "*gadeño"}, // Envigado {"*gamo", "*gamasque"}, // Bergamo {"*gano", "*ganese"}, // Lugano {"*gana", "*ganite"}, // Telangana @@ -407,6 +408,7 @@ {"*ice", "*icean"}, // Nice {"*ier", "*ieran"}, // Napier {"*iev", "*ievan"}, // Kiev +{"*imo", "*imoite"}, // Nanaimo {"*ing", "*ingite"}, // Kuching {"*ini", "*inian"}, // Leontini {"*inz", "*inzer"}, // Linz From d4f63cd61f4a08d208f33bd469ec444057810d3e Mon Sep 17 00:00:00 2001 From: Seweryn Presnal Date: Sat, 7 Oct 2023 15:55:05 +0100 Subject: [PATCH 4/6] =?UTF-8?q?Adjective=20rule=20for=20Chigorod=C3=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commonItems.UnitTests/Linguistics/StringExtensionsTests.cs | 1 + commonItems/Linguistics/adjective_rules.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/commonItems.UnitTests/Linguistics/StringExtensionsTests.cs b/commonItems.UnitTests/Linguistics/StringExtensionsTests.cs index 2056146a..727f0b6a 100644 --- a/commonItems.UnitTests/Linguistics/StringExtensionsTests.cs +++ b/commonItems.UnitTests/Linguistics/StringExtensionsTests.cs @@ -187,6 +187,7 @@ public class StringExtensionsTests { [InlineData("Trelew", "Trelewense")] [InlineData("Nanaimo", "Nanaimoite")] [InlineData("Envigado", "Envigadeño")] + [InlineData("Chigorodó", "Chigorodoseño")] // adjectives relying on rewrite rules [InlineData("Armenia Maioris", "Greater Armenian")] diff --git a/commonItems/Linguistics/adjective_rules.txt b/commonItems/Linguistics/adjective_rules.txt index ba4f5009..61dadfa7 100644 --- a/commonItems/Linguistics/adjective_rules.txt +++ b/commonItems/Linguistics/adjective_rules.txt @@ -550,6 +550,7 @@ {"*ce", "*cian"}, // Thrace {"*co", "*can"}, // Morocco {"*de", "*dean"}, // Cape Verde +{"*dó", "*doseño"}, // Chigorodó {"*du", "*dunite"}, // Ordu {"*eh", "*ehi"}, {"*ej", "*ejite"}, From 552c11d4df21fcbb43380fac58d0ec103b84b6a4 Mon Sep 17 00:00:00 2001 From: Seweryn Presnal Date: Sat, 7 Oct 2023 23:43:09 +0100 Subject: [PATCH 5/6] More adjective rules --- commonItems.UnitTests/Linguistics/StringExtensionsTests.cs | 5 ++++- commonItems/Linguistics/adjective_rules.txt | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/commonItems.UnitTests/Linguistics/StringExtensionsTests.cs b/commonItems.UnitTests/Linguistics/StringExtensionsTests.cs index 727f0b6a..3c73d91c 100644 --- a/commonItems.UnitTests/Linguistics/StringExtensionsTests.cs +++ b/commonItems.UnitTests/Linguistics/StringExtensionsTests.cs @@ -188,6 +188,9 @@ public class StringExtensionsTests { [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")] @@ -485,7 +488,7 @@ public void AdjectiveRuleExistsForEveryCountryAndMajorCityInTheWorld() { var csv = new WebClient().DownloadString(csvUrl); var cities = CsvReader.ReadFromText(csv) .Select(line => line[0]) - .Where(city => !string.IsNullOrEmpty(city)) + .Where(city => !string.IsNullOrEmpty(city) && !city.StartsWith("Zürich (Kreis")) .Distinct() .ToList(); diff --git a/commonItems/Linguistics/adjective_rules.txt b/commonItems/Linguistics/adjective_rules.txt index 61dadfa7..af3ac44d 100644 --- a/commonItems/Linguistics/adjective_rules.txt +++ b/commonItems/Linguistics/adjective_rules.txt @@ -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 @@ -342,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 @@ -585,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 From 55ab899d31d2744e530ef2d7b2d0a14000a7c530 Mon Sep 17 00:00:00 2001 From: Seweryn Presnal Date: Sat, 7 Oct 2023 23:46:44 +0100 Subject: [PATCH 6/6] Update commonItems.csproj --- commonItems/commonItems.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commonItems/commonItems.csproj b/commonItems/commonItems.csproj index 39201c66..d89cccf7 100644 --- a/commonItems/commonItems.csproj +++ b/commonItems/commonItems.csproj @@ -6,7 +6,7 @@ False PGCG.$(AssemblyName) - 8.4.1 + 8.4.2 PGCG https://github.com/ParadoxGameConverters/commonItems.NET https://github.com/ParadoxGameConverters/commonItems.NET