From 4beff90c42fcb1e9d182281b7a08408a54d7eedb Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Tue, 26 Nov 2024 11:46:29 +0100 Subject: [PATCH] Update concordance lists for new measurements implementation --- src/MDConcLengths.php | 195 ++++++++++++++++---------------- src/MDConcMeasurementTypes.php | 2 +- src/MDConcObjectTagRelTypes.php | 1 + src/MDConcWeights.php | 24 ++-- 4 files changed, 108 insertions(+), 114 deletions(-) diff --git a/src/MDConcLengths.php b/src/MDConcLengths.php index 7d2e1ff..4066c8f 100644 --- a/src/MDConcLengths.php +++ b/src/MDConcLengths.php @@ -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), + + }; } } diff --git a/src/MDConcMeasurementTypes.php b/src/MDConcMeasurementTypes.php index 189ba37..1fa00a8 100644 --- a/src/MDConcMeasurementTypes.php +++ b/src/MDConcMeasurementTypes.php @@ -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", diff --git a/src/MDConcObjectTagRelTypes.php b/src/MDConcObjectTagRelTypes.php index 9da1e1b..adde394 100644 --- a/src/MDConcObjectTagRelTypes.php +++ b/src/MDConcObjectTagRelTypes.php @@ -15,6 +15,7 @@ final class MDConcObjectTagRelTypes implements MDImporterConcordanceListInterfac '' => 'tag', 'tag' => 'tag', + 'description' => 'tag', "motive" => "article", "motiv" => "article", diff --git a/src/MDConcWeights.php b/src/MDConcWeights.php index f3ec426..6eba607 100644 --- a/src/MDConcWeights.php +++ b/src/MDConcWeights.php @@ -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), + + }; } }