Identify and clean component uncertainty in timespans
This commit is contained in:
@@ -266,6 +266,15 @@ final class NodaUncertaintyHelper {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (str_contains($name, '-')) {
|
||||||
|
$parts = explode('-', $name);
|
||||||
|
$partsCleaned = [];
|
||||||
|
foreach ($parts as $part) {
|
||||||
|
$partsCleaned[] = self::cleanUncertaintyIndicatorsTime($part);
|
||||||
|
}
|
||||||
|
$name = implode('-', $partsCleaned);
|
||||||
|
}
|
||||||
|
|
||||||
// Remove uncertainty prefixes
|
// Remove uncertainty prefixes
|
||||||
foreach (NodaUncertaintyHelper::TIME_UNCERTAINTY_PREFIXES as $prefix) {
|
foreach (NodaUncertaintyHelper::TIME_UNCERTAINTY_PREFIXES as $prefix) {
|
||||||
if (\substr($name, 0, \strlen($prefix)) === "$prefix") {
|
if (\substr($name, 0, \strlen($prefix)) === "$prefix") {
|
||||||
@@ -296,6 +305,13 @@ final class NodaUncertaintyHelper {
|
|||||||
|
|
||||||
$zeit_name = self::trim(strtolower($zeit_name));
|
$zeit_name = self::trim(strtolower($zeit_name));
|
||||||
|
|
||||||
|
if (str_contains($zeit_name, '-')) {
|
||||||
|
$parts = explode('-', $zeit_name);
|
||||||
|
foreach ($parts as $part) {
|
||||||
|
if (self::guessTimeCertainty($part) === false) return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 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) {
|
||||||
if (\substr($zeit_name, 0, \strlen($prefix)) === $prefix) {
|
if (\substr($zeit_name, 0, \strlen($prefix)) === $prefix) {
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ final class NodaUncertaintyHelperTest extends TestCase {
|
|||||||
public static function uncertainTimesProvider():array {
|
public static function uncertainTimesProvider():array {
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
'infix: "1950-wohl 1960"' => ["1950-ca. 1960", "1950-1960", false],
|
||||||
|
'uncertainty prefix + infix: "ca. 1950-ca. 1960"' => ["ca. 1950-ca. 1960", "1950-1960", false],
|
||||||
|
'uncertainty prefix + infix: "wohl 1950-wohl 1960"' => ["wohl 1950-wohl 1960", "1950-1960", false],
|
||||||
'uncertainty prefix: "wohl 1950"' => ["wohl 1950", "1950", false],
|
'uncertainty prefix: "wohl 1950"' => ["wohl 1950", "1950", false],
|
||||||
'uncertainty prefix: "etwa 1950"' => ["etwa 1950", "1950", false],
|
'uncertainty prefix: "etwa 1950"' => ["etwa 1950", "1950", false],
|
||||||
'uncertainty suffix: "1950?"' => ["1950?", "1950", false],
|
'uncertainty suffix: "1950?"' => ["1950?", "1950", false],
|
||||||
|
|||||||
Reference in New Issue
Block a user