Skip to content

Commit

Permalink
Support pattern: before ##/####
Browse files Browse the repository at this point in the history
  • Loading branch information
kspurgin committed Jan 25, 2024
1 parent 7c15c87 commit b2b625c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/emendate/date_part_tagger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ def full_match_tagger
end

def full_match_date_part_tagger
# case result.date_part_types.sort.join(" ")
# end
case result.date_part_types.join(" ")
when "number1or2 year"
proc { tag_numeric_month }
end
end

def partial_match_tagger
Expand Down
9 changes: 9 additions & 0 deletions spec/emendate/date_part_tagger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@
end
end

context "with before ##/####" do
let(:string) { "before 11/1950" }

it "segments as expected" do
expect(types).to eq(%i[before month year])
expect(result.lexeme).to eq(string)
end
end

context "with ####.#" do
let(:string) { "2020.0" }

Expand Down
2 changes: 1 addition & 1 deletion spec/support/examples.csv
Original file line number Diff line number Diff line change
Expand Up @@ -312,5 +312,5 @@
"Y3388E2S3","Y3388E2S3","y####e#s#","currently_unparseable;edtf;edtf2;exponential_year;letter_prefixed_year;significant_digits",,,"0","nilValue","nilValue","nilValue","nilValue",,,"Unprocessable string",,
"1947/ca. 1965","1947/ca. 1965","####/ca. ####","approximate;year_granularity;range","ccp",,"0","1947","1965","1947-01-01","1965-12-31","approximate, end",,"na",,
"1815 or later","1815 or later","#### or later","or_after;year_granularity;after_before","ccp","open_unknown_end_date: '2022-06-01'","0","1815","2022","1815-01-01","2022-06-01",,,,"[1815..]","1815 or a later date"
"before 11/1750","before 11/1750","before ##/####","after_before;year_month_granularity","ccp","open_unknown_start_date: '1600-02-15'","0","1600-02","1749-10","1600-02-15","1749-10-31",,,"na","[..1750-11]","1749-11 or an earlier date"
"before 11/1750","before 11/1750","before ##/####","after_before;year_month_granularity","ccp","open_unknown_start_date: '1600-02-15'","0","1600-02","1750-10","1600-02-15","1750-10-31",,,"na","[..1750-11]","1750-11 or an earlier date"
"Sept. 28, 1969","Sept. 28, 1969","MON. ##, ####","year_month_day_granularity","ccp",,"0","1969-09-28","1969-09-28","1969-09-28","1969-09-28",,,,"1969-09-28","1969-09-28"

0 comments on commit b2b625c

Please sign in to comment.