Enable time splitter to recognize sz as abbr. for század
This commit is contained in:
parent
3664bcf3f6
commit
80cd88222d
|
@ -743,7 +743,7 @@ final class NodaTimeSplitter {
|
|||
$bcBceIndicator = '+';
|
||||
|
||||
// 17. Jahrhundert
|
||||
if (preg_match("/^[0-9][0-9]\.\ (Jh\.|Jahrhundert|század)$/", $datum)) {
|
||||
if (preg_match("/^[0-9][0-9]\.\ (Jh\.|Jahrhundert|sz|század)$/", $datum)) {
|
||||
if ($centuryNo = intval(substr($datum, 0, 2))) {
|
||||
$centuryNo--;
|
||||
return [(string)$centuryNo . "01", strval($centuryNo + 1) . "00", "00", "00", $bcBceIndicator, ""];
|
||||
|
@ -751,7 +751,7 @@ final class NodaTimeSplitter {
|
|||
}
|
||||
|
||||
// 1. Jahrhundert
|
||||
if (preg_match("/^[0-9]\.\ (Jh\.|Jahrhundert|század)$/", $datum)) {
|
||||
if (preg_match("/^[0-9]\.\ (Jh\.|Jahrhundert|sz|század)$/", $datum)) {
|
||||
echo "HI";
|
||||
if ($centuryNo = intval(substr($datum, 0, 1))) {
|
||||
$centuryNo--;
|
||||
|
@ -760,24 +760,24 @@ final class NodaTimeSplitter {
|
|||
}
|
||||
|
||||
// 17.-18. Jahrhundert
|
||||
if (preg_match("/^[0-9][0-9]\.\-[0-9][0-9]\.\ (Jh\.|Jahrhundert|század)$/", $datum)) {
|
||||
if (preg_match("/^[0-9][0-9]\.\-[0-9][0-9]\.\ (Jh\.|Jahrhundert|sz|század)$/", $datum)) {
|
||||
return self::negotiate_century_span_bce_ce(substr($datum, 0, 2), substr($datum, 4, 2));
|
||||
}
|
||||
// 17-18. Jahrhundert
|
||||
if (preg_match("/^[0-9][0-9]\-[0-9][0-9]\.\ (Jh\.|Jahrhundert|század)$/", $datum)) {
|
||||
if (preg_match("/^[0-9][0-9]\-[0-9][0-9]\.\ (Jh\.|Jahrhundert|sz|század)$/", $datum)) {
|
||||
return self::negotiate_century_span_bce_ce(substr($datum, 0, 2), substr($datum, 3, 2));
|
||||
}
|
||||
|
||||
// 1.-12. Jahrhundert
|
||||
if (preg_match("/^[0-9]\.\-[0-9][0-9]\.\ (Jh\.|Jahrhundert|század)$/", $datum)) {
|
||||
if (preg_match("/^[0-9]\.\-[0-9][0-9]\.\ (Jh\.|Jahrhundert|sz|század)$/", $datum)) {
|
||||
return self::negotiate_century_span_bce_ce(substr($datum, 0, 1), substr($datum, 3, 2));
|
||||
}
|
||||
// 1.-2. Jahrhundert
|
||||
if (preg_match("/^[0-9]\.\-[0-9]\.\ (Jh\.|Jahrhundert|század)$/", $datum)) {
|
||||
if (preg_match("/^[0-9]\.\-[0-9]\.\ (Jh\.|Jahrhundert|sz|század)$/", $datum)) {
|
||||
return self::negotiate_century_span_bce_ce(substr($datum, 0, 1), substr($datum, 3, 1));
|
||||
}
|
||||
// 1-2. Jahrhundert
|
||||
if (preg_match("/^[0-9]\-[0-9]\.\ (Jh\.|Jahrhundert|század)$/", $datum)) {
|
||||
if (preg_match("/^[0-9]\-[0-9]\.\ (Jh\.|Jahrhundert|sz|század)$/", $datum)) {
|
||||
return self::negotiate_century_span_bce_ce(substr($datum, 0, 1), substr($datum, 2, 1));
|
||||
}
|
||||
|
||||
|
|
|
@ -350,6 +350,30 @@ final class NodaTimeSplitterTest extends TestCase {
|
|||
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "Januar 2020 v. Chr.");
|
||||
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
||||
|
||||
$output = NodaTimeSplitter::attempt_splitting("20. sz");
|
||||
self::assertEquals($output, [
|
||||
0 => "1901",
|
||||
1 => "2000",
|
||||
2 => "00",
|
||||
3 => "00",
|
||||
4 => "+",
|
||||
5 => "",
|
||||
]);
|
||||
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "1901-2000");
|
||||
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1951);
|
||||
|
||||
$output = NodaTimeSplitter::attempt_splitting("20. század");
|
||||
self::assertEquals($output, [
|
||||
0 => "1901",
|
||||
1 => "2000",
|
||||
2 => "00",
|
||||
3 => "00",
|
||||
4 => "+",
|
||||
5 => "",
|
||||
]);
|
||||
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "1901-2000");
|
||||
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1951);
|
||||
|
||||
$output = NodaTimeSplitter::attempt_splitting("Kr. e. 20. század");
|
||||
self::assertEquals($output, [
|
||||
0 => "-2000",
|
||||
|
|
Loading…
Reference in New Issue
Block a user