Skip to content

Date rule doesn't match well with action #776

@kwalcock

Description

@kwalcock

The rule

- name: date-range-10
  priority: ${rulepriority}
  label: DateRange
  type: token
  example: "First two weeks of May"
  action: mkDateRangeMentionWithWeek
  pattern: |
    (?<week> /(?i)(first|second|last)/ /(?i)two/ /(?i)weeks/) /(?i)of/ @month:PossibleMonth

gets processed by

  private def getWeekRange(weekNormalizer: WeekNormalizer)(argName: String, m:Mention): Option[WeekRange] = {
    val wordsOpt = getArgWords(argName, m)

    if (wordsOpt.isEmpty) None
    else if (wordsOpt.get.mkString(" ").toLowerCase().equals("last week")) {getLastWeekRange(m)}
    else if (wordsOpt.get.mkString(" ").toLowerCase().equals("last two weeks")) {getLastTwoWeeksRange(m)}
    else weekNormalizer.norm(wordsOpt.get)
  }

and doesn't take the possibility of "last weeks [of June]" into account. An internal exception is eventually thrown and also swallowed. weekNormalizer.norm doesn't take care of it, either, because WeekNormalizer.normMapper doesn't have third weeks.

The code should account for any match of the rule and vice versa.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions