Skip to content

Commit

Permalink
fix problem with peg (close #272)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimus committed Nov 8, 2024
1 parent 82b4486 commit e2bfa0c
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 66 deletions.
2 changes: 1 addition & 1 deletion ent/internal/preparser/grammar.peg
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ _ <- MultipleSpace / SingleSpace

NotLetterOrEnd <- NotLetter / END

NotLetter <- [[^A-Z0-9_\-\.]]
NotLetter <- [[^A-Z0-9_.\-]]

MultipleSpace <- SingleSpace SingleSpace+

Expand Down
137 changes: 72 additions & 65 deletions ent/internal/preparser/grammar.peg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions testdata/test_data.md
Original file line number Diff line number Diff line change
Expand Up @@ -2647,6 +2647,15 @@ Authorship: (E. L. Braun 1940) Morton (1956)
```json
{"parsed":true,"quality":2,"qualityWarnings":[{"quality":2,"warning":"Named hybrid"},{"quality":2,"warning":"Year with parentheses"}],"verbatim":"Asplenium X inexpectatum (E.L. Braun 1940) Morton (1956)","normalized":"Asplenium × inexpectatum (E. L. Braun 1940) Morton (1956)","canonical":{"stemmed":"Asplenium inexpectat","simple":"Asplenium inexpectatum","full":"Asplenium × inexpectatum"},"cardinality":2,"rank":"sp.","authorship":{"verbatim":"(E.L. Braun 1940) Morton (1956)","normalized":"(E. L. Braun 1940) Morton (1956)","year":"1940","authors":["E. L. Braun","Morton"],"originalAuth":{"authors":["E. L. Braun"],"year":{"year":"1940"}},"combinationAuth":{"authors":["Morton"],"year":{"year":"1956","isApproximate":true}}},"hybrid":"NAMED_HYBRID","details":{"species":{"genus":"Asplenium","species":"inexpectatum","authorship":{"verbatim":"(E.L. Braun 1940) Morton (1956)","normalized":"(E. L. Braun 1940) Morton (1956)","year":"1940","authors":["E. L. Braun","Morton"],"originalAuth":{"authors":["E. L. Braun"],"year":{"year":"1940"}},"combinationAuth":{"authors":["Morton"],"year":{"year":"1956","isApproximate":true}}}}},"words":[{"verbatim":"Asplenium","normalized":"Asplenium","wordType":"GENUS","start":0,"end":9},{"verbatim":"X","normalized":"×","wordType":"HYBRID_CHAR","start":10,"end":11},{"verbatim":"inexpectatum","normalized":"inexpectatum","wordType":"SPECIES","start":12,"end":24},{"verbatim":"E.","normalized":"E.","wordType":"AUTHOR_WORD","start":26,"end":28},{"verbatim":"L.","normalized":"L.","wordType":"AUTHOR_WORD","start":28,"end":30},{"verbatim":"Braun","normalized":"Braun","wordType":"AUTHOR_WORD","start":31,"end":36},{"verbatim":"1940","normalized":"1940","wordType":"YEAR","start":37,"end":41},{"verbatim":"Morton","normalized":"Morton","wordType":"AUTHOR_WORD","start":43,"end":49},{"verbatim":"1956","normalized":"1956","wordType":"APPROXIMATE_YEAR","start":51,"end":55}],"id":"d37e04e4-90bc-5031-b91c-dbb61113bcfa","parserVersion":"test_version"}
```
Name: Androrchis × fallax (De Not.) W.Foelsche & Jakely

Canonical: Androrchis fallax

Authorship: (De Not.) W. Foelsche & Jakely

```json
{"parsed":true,"quality":2,"qualityWarnings":[{"quality":2,"warning":"Named hybrid"}],"verbatim":"Androrchis × fallax (De Not.) W.Foelsche \u0026 Jakely","normalized":"Androrchis × fallax (De Not.) W. Foelsche \u0026 Jakely","canonical":{"stemmed":"Androrchis fallax","simple":"Androrchis fallax","full":"Androrchis × fallax"},"cardinality":2,"rank":"sp.","authorship":{"verbatim":"(De Not.) W.Foelsche \u0026 Jakely","normalized":"(De Not.) W. Foelsche \u0026 Jakely","authors":["De Not.","W. Foelsche","Jakely"],"originalAuth":{"authors":["De Not."]},"combinationAuth":{"authors":["W. Foelsche","Jakely"]}},"hybrid":"NAMED_HYBRID","details":{"species":{"genus":"Androrchis","species":"fallax","authorship":{"verbatim":"(De Not.) W.Foelsche \u0026 Jakely","normalized":"(De Not.) W. Foelsche \u0026 Jakely","authors":["De Not.","W. Foelsche","Jakely"],"originalAuth":{"authors":["De Not."]},"combinationAuth":{"authors":["W. Foelsche","Jakely"]}}}},"words":[{"verbatim":"Androrchis","normalized":"Androrchis","wordType":"GENUS","start":0,"end":10},{"verbatim":"×","normalized":"×","wordType":"HYBRID_CHAR","start":11,"end":12},{"verbatim":"fallax","normalized":"fallax","wordType":"SPECIES","start":13,"end":19},{"verbatim":"De","normalized":"De","wordType":"AUTHOR_WORD","start":21,"end":23},{"verbatim":"Not.","normalized":"Not.","wordType":"AUTHOR_WORD","start":24,"end":28},{"verbatim":"W.","normalized":"W.","wordType":"AUTHOR_WORD","start":30,"end":32},{"verbatim":"Foelsche","normalized":"Foelsche","wordType":"AUTHOR_WORD","start":32,"end":40},{"verbatim":"Jakely","normalized":"Jakely","wordType":"AUTHOR_WORD","start":43,"end":49}],"id":"5fad9f92-33df-5778-923c-f2e6c1508e33","parserVersion":"test_version"}
```

Name: Salix ×capreola Andersson (1867)

Expand Down

0 comments on commit e2bfa0c

Please sign in to comment.