Skip to content

Commit

Permalink
distinguish in and ex authors (close #271)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimus committed Nov 6, 2024
1 parent 05e573a commit feb8b4a
Show file tree
Hide file tree
Showing 10 changed files with 4,397 additions and 4,314 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Fix [#271]: distinguish between `ex` and `in`.
- Fix [#270]: missing verbatim authorship for names that look similar to
combination uninomial in ICZN.
- Fix [#268]: if botanical author looks like a combination uninomial,
Expand Down
6 changes: 5 additions & 1 deletion ent/parsed/parsed.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ type AuthGroup struct {
// authors, that sometimes appear in scientific names after "ex"
// qualifier.
ExAuthors *Authors `json:"exAuthors,omitempty"`
// ExAuthors provided only if "with_details=true" A "special" group of
// InAuthors provided only if "with_details=true" A "special" group of
// authors, that sometimes appear in scientific names after "in"
// qualifier.
InAuthors *Authors `json:"inAuthors,omitempty"`
// EmendAuthors provided only if "with_details=true" A "special" group of
// authors, that sometimes appear in scientific names after "emend."
// qualifier.
EmendAuthors *Authors `json:"emendAuthors,omitempty"`
Expand Down
8 changes: 7 additions & 1 deletion ent/parsed/warning.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ const (
AuthEmendWarn
AuthEmendWithoutDotWarn
AuthExWarn
AuthInWarn
AuthExWithDotWarn
AuthInWithDotWarn
AuthMissingOneParensWarn
AuthQuestionWarn
AuthShortWarn
Expand Down Expand Up @@ -78,8 +80,10 @@ var warningMap = map[Warning]string{
AuthDoubleParensWarn: "Authorship in double parentheses",
AuthEmendWarn: "Emend authors are not required",
AuthEmendWithoutDotWarn: "`emend` without a period",
AuthExWarn: "Ex authors are not required (ICZN only)",
AuthExWarn: "`ex` authors are not required (ICZN only)",
AuthInWarn: "`in` authors are not required",
AuthExWithDotWarn: "`ex` ends with a period",
AuthInWithDotWarn: "`in` ends with a period",
AuthMissingOneParensWarn: "Authorship is missing one parenthesis",
AuthQuestionWarn: "Author as a question mark",
AuthShortWarn: "Author is too short",
Expand Down Expand Up @@ -150,7 +154,9 @@ var WarningQualityMap = map[Warning]int{
AuthEmendWarn: 2,
AuthEmendWithoutDotWarn: 3,
AuthExWarn: 2,
AuthInWarn: 2,
AuthExWithDotWarn: 3,
AuthInWithDotWarn: 3,
AuthMissingOneParensWarn: 4,
AuthQuestionWarn: 4,
AuthShortWarn: 3,
Expand Down
2 changes: 1 addition & 1 deletion ent/parsed/warning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestJSONWarn(t *testing.T) {
{dataOb{"Tail", parsed.TailWarn, []int{}},
`{"f1":"Tail","warning":"Unparsed tail","f2":[]}`},
{dataOb{"AuthEx", parsed.AuthExWarn, []int{2, 3, 4}},
`{"f1":"AuthEx","warning":"Ex authors are not required (ICZN only)","f2":[2,3,4]}`},
`{"f1":"AuthEx","warning":"` + "`ex`" + ` authors are not required (ICZN only)","f2":[2,3,4]}`},
}
enc := gnfmt.GNjson{}
var dob dataOb
Expand Down
10 changes: 10 additions & 0 deletions ent/parser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,7 @@ type teamType int
const (
teamDefault teamType = iota
teamEx
teamIn
teamEmend
)

Expand Down Expand Up @@ -1020,6 +1021,15 @@ func (p *Engine) newAuthorsGroupNode(n *node32) *authorsGroupNode {
p.addWarn(parsed.AuthExWithDotWarn)
}
t2wrd.Normalized = "ex"
case ruleAuthorIn:
p.addWarn(parsed.AuthInWarn)
t2t = teamIn
t2wrd = p.newWordNode(n, parsed.AuthorWordType)
inWrd := strings.TrimSpace(t2wrd.Verbatim)
if inWrd[len(inWrd)-1] == '.' {
p.addWarn(parsed.AuthInWithDotWarn)
}
t2wrd.Normalized = "in"
case ruleAuthorEmend:
p.addWarn(parsed.AuthEmendWarn)
t2t = teamEmend
Expand Down
1 change: 1 addition & 0 deletions ent/parser/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ var nodeRules = map[pegRule]struct{}{
ruleAuthorEmend: {},
ruleAuthorEtAl: {},
ruleAuthorEx: {},
ruleAuthorIn: {},
ruleAuthorPrefix: {},
ruleAuthorSep: {},
ruleAuthorSuffix: {},
Expand Down
10 changes: 6 additions & 4 deletions ent/parser/grammar.peg
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ GenusWord <- (AbbrGenus / UninomialWord) !(_ AuthorWord)

InfraspGroup <- InfraspEpithet (_ InfraspEpithet)? (_ InfraspEpithet)?

InfraspEpithet <- (Rank _?)? !(AuthorEx) Word (_ IgnoredWord)? (_? Authorship)?
InfraspEpithet <- (Rank _?)? !(AuthorEx / AuthorIn) Word (_ IgnoredWord)? (_? Authorship)?

CultivarWordGroup <- ((RankCultivar _)? CultivarApostrophe
CultivarRecursive CultivarApostrophe) /
Expand All @@ -72,7 +72,7 @@ CultivarRecursive <- NotHybridChar CultivarRecursive / &CultivarApostrophe

CultivarApostrophe <- '\'' / '‘' / '’' / '"' / '“' / '”'

SpeciesEpithet <- !(AuthorEx) Word (_ IgnoredWord)? (_? Authorship)?
SpeciesEpithet <- !(AuthorEx / AuthorIn) Word (_ IgnoredWord)? (_? Authorship)?

IgnoredWord <- 'mihi.' / 'mihi'

Expand Down Expand Up @@ -206,7 +206,7 @@ BasionymAuthorship1 <- '(' _? AuthorsGroup _? ')'

BasionymAuthorship2Parens <- '(' _? '(' _? AuthorsGroup _? ')' _? ')'

AuthorsGroup <- AuthorsTeam (','?_ (AuthorEmend / AuthorEx) AuthorsTeam)?
AuthorsGroup <- AuthorsTeam (','?_ (AuthorEmend / AuthorEx / AuthorIn) AuthorsTeam)?

AuthorsTeam <- Author (AuthorSep Author)* (_? ','? _? Year)?

Expand All @@ -218,7 +218,9 @@ AuthorSep2 <- _? ',' _?

AuthorSepSpanish <- _? 'y' _?

AuthorEx <- ('ex' '.'? / 'ms' _ 'in' / 'in') _
AuthorEx <- ('ex' '.'? ) _

AuthorIn <- ( 'ms' _ 'in' / 'in') _

AuthorEmend <- 'emend' '.'? _

Expand Down
Loading

0 comments on commit feb8b4a

Please sign in to comment.