Handle commas when guessing time certainty
This commit is contained in:
		| @@ -232,8 +232,7 @@ final class NodaUncertaintyHelper { | |||||||
|      */ |      */ | ||||||
|     public static function trim(string $input):string { |     public static function trim(string $input):string { | ||||||
|  |  | ||||||
|         $input = \trim($input, ", \t\n\r\n;-:"); |         return \trim($input, ", \t\n\r\n;-:"); | ||||||
|         return $input; |  | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -280,7 +279,7 @@ final class NodaUncertaintyHelper { | |||||||
|      */ |      */ | ||||||
|     public static function guessTimeCertainty(string $zeit_name):bool { |     public static function guessTimeCertainty(string $zeit_name):bool { | ||||||
|  |  | ||||||
|         $zeit_name = \strtolower($zeit_name); |         $zeit_name = self::trim(strtolower($zeit_name)); | ||||||
|  |  | ||||||
|         // Attempt to guess uncertainty based on prefixes. |         // Attempt to guess uncertainty based on prefixes. | ||||||
|         foreach (self::TIME_UNCERTAINTY_PREFIXES as $prefix) { |         foreach (self::TIME_UNCERTAINTY_PREFIXES as $prefix) { | ||||||
| @@ -343,7 +342,7 @@ final class NodaUncertaintyHelper { | |||||||
|      */ |      */ | ||||||
|     public static function guessPlaceCertainty(string $ort_name):bool { |     public static function guessPlaceCertainty(string $ort_name):bool { | ||||||
|  |  | ||||||
|         $ort_name = \trim(\strtolower($ort_name), ', ;-_'); |         $ort_name = self::trim(\strtolower($ort_name)); | ||||||
|  |  | ||||||
|         // Attempt to guess uncertainty based on prefixes. |         // Attempt to guess uncertainty based on prefixes. | ||||||
|         foreach (NodaUncertaintyHelper::PLACE_UNCERTAINTY_PREFIXES as $prefix) { |         foreach (NodaUncertaintyHelper::PLACE_UNCERTAINTY_PREFIXES as $prefix) { | ||||||
| @@ -404,7 +403,7 @@ final class NodaUncertaintyHelper { | |||||||
|      */ |      */ | ||||||
|     public static function guessPersinstCertainty(string $name):bool { |     public static function guessPersinstCertainty(string $name):bool { | ||||||
|  |  | ||||||
|         $name = \trim(\strtolower($name), ', ;-_'); |         $name = self::trim(\strtolower($name)); | ||||||
|  |  | ||||||
|         // Attempt to guess uncertainty based on prefixes. |         // Attempt to guess uncertainty based on prefixes. | ||||||
|         foreach (NodaUncertaintyHelper::PERSINST_UNCERTAINTY_PREFIXES as $prefix) { |         foreach (NodaUncertaintyHelper::PERSINST_UNCERTAINTY_PREFIXES as $prefix) { | ||||||
|   | |||||||
| @@ -26,6 +26,9 @@ final class NodaUncertaintyHelperTest extends TestCase { | |||||||
|     public function testCleanUncertaintyIndicatorsTime():void { |     public function testCleanUncertaintyIndicatorsTime():void { | ||||||
|  |  | ||||||
|         self::assertEquals("1950", NodaUncertaintyHelper::cleanUncertaintyIndicatorsTime("wohl 1950")); |         self::assertEquals("1950", NodaUncertaintyHelper::cleanUncertaintyIndicatorsTime("wohl 1950")); | ||||||
|  |         self::assertEquals("1950", NodaUncertaintyHelper::cleanUncertaintyIndicatorsTime("1950?")); | ||||||
|  |         self::assertEquals("1950", NodaUncertaintyHelper::cleanUncertaintyIndicatorsTime("1950?,")); | ||||||
|  |         self::assertEquals("1950", NodaUncertaintyHelper::cleanUncertaintyIndicatorsTime("1950,")); | ||||||
|         self::assertEquals("1950", NodaUncertaintyHelper::cleanUncertaintyIndicatorsTime("1950")); |         self::assertEquals("1950", NodaUncertaintyHelper::cleanUncertaintyIndicatorsTime("1950")); | ||||||
|  |  | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user