Update concordance lists for new measurements implementation

This commit is contained in:
Joshua Ramon Enslin 2024-11-26 11:46:29 +01:00
parent 866ef3c714
commit 4beff90c42
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE
4 changed files with 108 additions and 114 deletions

View File

@ -10,114 +10,109 @@ declare(strict_types = 1);
* Provides lists for categorizing misspelled sizes.
*/
final class MDConcLengths implements MDImporterConcordanceListInterface {
private const LENGTHS_LIST = [
// Default: Empty
"Breite" => "",
"breite" => "",
"Width" => "",
"width" => "",
"Höhe" => "",
"höhe" => "",
"Height" => "",
"height" => "",
"´´´" => "",
"Theater" => "",
"Oper" => "",
"min" => "",
"-" => "",
"a)" => "",
"/" => "",
"geöffnet" => "",
"Scheibe" => "",
"Trageöse" => "",
"ohneRahmen" => "",
"mitRahmen" => "",
"ohne Rahmen" => "",
"mit Rahmen" => "",
"Verpackung" => "",
"mitFassung" => "",
"ohneFassung" => "",
"mit Fassung" => "",
"ohne Fassung" => "",
"nichtfeststellbar" => "",
"nicht feststellbar" => "",
"amBodenhinten" => "",
"am Bodenhinten" => "",
"am Boden hinten" => "",
"andenSchildzapfen" => "",
"an den Schildzapfen" => "",
"anderMündung" => "",
"an der Mündung" => "",
"Fuß" => "",
"Innendurchmesser" => "",
"mitStulpe" => "",
"mit Stulpe" => "",
"mitHolzrahmen" => "",
"mit Holzrahmen" => "",
"mitStahlrahmen" => "",
"mit Stahlrahmen" => "",
"Pfeilhöhe" => "",
"Klingenbreite" => "",
"bis" => "",
"vorne" => "",
"hinten" => "",
"zwischenund" => "",
"Standring" => "",
"kleinsterDurchmesser" => "",
"größterDurchmesser" => "",
"kleinster Durchmesser" => "",
"größter Durchmesser" => "",
"Klinge" => "",
"Henkel" => "",
"mitFaden" => "",
"mit Faden" => "",
"ohneFaden" => "",
"ohne Faden" => "",
"nichtmessbar" => "",
"nicht messbar" => "",
"Stoffbreite" => "",
// cm
"cn" => "cm",
",cm" => "cm",
"5cm" => "cm",
"Zentimeter" => "cm",
"см" => "cm",
"ca" => "cm", // This is likely a typo
"Meter" => "m",
"Meters" => "m",
"meter" => "m",
"meters" => "m",
"Milimeter" => "mm",
"Milimeters" => "mm",
"Millimeter" => "mm",
"Millimeters" => "mm",
"мм" => "mm",
"ma" => "mm", // Either a typo for mm, or miliamper?
"inch" => "in",
"Zoll" => "in",
"zoll" => "in",
];
/**
* Require a function for getting the concordance target.
*
* @param string $input Input string.
*
* @return string
* @return MDLengthUnit|false
*/
public static function getConcordanceTarget(string $input):string {
public static function getConcordanceTarget(string $input):MDLengthUnit|false {
if (!isset(self::LENGTHS_LIST[$input])) {
throw new MDImporterMissingConcordance("Unknown length type: " . $input);
}
return match($input) {
// Default: Empty
"Breite",
"breite",
"Width",
"width",
"Höhe",
"höhe",
"Height",
"height",
"´´´",
"Theater",
"Oper",
"min",
"-",
"a)",
"/",
"geöffnet",
"Scheibe",
"Trageöse",
"ohneRahmen",
"mitRahmen",
"ohne Rahmen",
"mit Rahmen",
"Verpackung",
"mitFassung",
"ohneFassung",
"mit Fassung",
"ohne Fassung",
"nichtfeststellbar",
"nicht feststellbar",
"amBodenhinten",
"am Bodenhinten",
"am Boden hinten",
"andenSchildzapfen",
"an den Schildzapfen",
"anderMündung",
"an der Mündung",
"Fuß",
"Innendurchmesser",
"mitStulpe",
"mit Stulpe",
"mitHolzrahmen",
"mit Holzrahmen",
"mitStahlrahmen",
"mit Stahlrahmen",
"Pfeilhöhe",
"Klingenbreite",
"bis",
"vorne",
"hinten",
"zwischenund",
"Standring",
"kleinsterDurchmesser",
"größterDurchmesser",
"kleinster Durchmesser",
"größter Durchmesser",
"Klinge",
"Henkel",
"mitFaden",
"mit Faden",
"ohneFaden",
"ohne Faden",
"nichtmessbar",
"nicht messbar",
"Stoffbreite" => false,
return self::LENGTHS_LIST[$input];
// cm
"cn",
",cm",
"5cm",
"Zentimeter",
"см",
"ca" => MDLengthUnit::cm,
"Meter",
"Meters",
"meter",
"meters" => MDLengthUnit::m,
"Milimeter",
"Milimeters",
"Millimeter",
"Millimeters",
"мм",
"ma" => MDLengthUnit::mm,
"inch",
"Zoll",
"zoll" => MDLengthUnit::ft,
default => throw new MDInvalidLengthUnit("Invalid length unit " . $input),
};
}
}

View File

@ -216,7 +216,7 @@ final class MDConcMeasurementTypes implements MDImporterConcordanceListInterface
"number of pages",
"Seitenzahl",
"Paginierung" => MDMeasurementType::number_of_pages,
"Paginierung" => MDMeasurementType::number_of_parts,
"Die Axis",
"die-axis",

View File

@ -15,6 +15,7 @@ final class MDConcObjectTagRelTypes implements MDImporterConcordanceListInterfac
'' => 'tag',
'tag' => 'tag',
'description' => 'tag',
"motive" => "article",
"motiv" => "article",

View File

@ -10,27 +10,25 @@ declare(strict_types = 1);
* Provides lists for categorizing misspelled sizes.
*/
final class MDConcWeights implements MDImporterConcordanceListInterface {
private const WEIGHTS_LIST = [
"cm" => "", // Default
"Gramm" => "g",
"г" => "g",
];
/**
* Require a function for getting the concordance target.
*
* @param string $input Input string.
*
* @return string
* @return MDWeightUnit|false
*/
public static function getConcordanceTarget(string $input):string {
public static function getConcordanceTarget(string $input):MDWeightUnit|false {
if (!isset(self::WEIGHTS_LIST[$input])) {
throw new MDImporterMissingConcordance("Unknown weight type: " . $input);
}
return match($input) {
return self::WEIGHTS_LIST[$input];
"cm" => false,
"Gramm",
"г" => MDWeightUnit::g,
default => throw new MDInvalidWeightUnit("Invalid weight unit " . $input),
};
}
}