"Date" (Comparison Method)
Details
- The "Date" comparison method considers two date objects to be equivalent if they do not differ by a given amount of time.
- This allowed time difference should be given as a time Quantity using the Tolerance option in AssessmentFunction. The default tolerance is zero seconds.
- By default, the date comparison between the answer key and the answer is computed using the DateDifference function. The DistanceFunction option can be used to specify a custom temporal distance metric.
- Using the default distance function DateDifference, when the granularities are not consistent, assessment is based on the smallest granularity and the starting points of dates with larger granularities.
- When multiple values in the answer key are within the tolerance range of an answer, the closest value is selected.
- For convenience, vectors with multiple components are also accepted as input and treated as arguments to DateObject.
Examples
open all close allBasic Examples (1)
Create an AssessmentFunction for a date question with a tolerance:
dateaf = AssessmentFunction[DateObject[{2024, 6, 1}], "Date", Tolerance -> Quantity[3, "Days"]]dateaf[DateObject[{2024, 5, 29}]]Scope (2)
Create an assessment with multiple possible answers at different time scales with custom scores:
dday = Entity["MilitaryConflict", "NormandyLandings"]["StartDate"]ddaytest = AssessmentFunction[{DateObject[dday, "Year"] -> 1, DateObject[dday, "Month"] -> 5, DateObject[dday, "Day"] -> 20}]Assess an answer and retrieve the score:
result = ddaytest[{1944}]result["Score"]Assess and retrieve the score when the exact date is given:
ddaytest["June 6 1944"]["Score"]The dates do not need to be defined at the same time granularity:
keydate = DateObject[{2024, 6, 1, 8}]dayhour = AssessmentFunction[keydate, "Date", Tolerance -> Quantity[12, "Hours"] ]dayhour[DateObject[{2024, 6, 1}]]Generalizations & Extensions (1)
Any valid input for DateObject is supported when the "Date" method is explicitly specified:
vectordate = AssessmentFunction[{{2024, 1}, "Feb. 8th, 2022", 3926653555}, "Date"]See the answer key containing standardized dates:
Information[vectordate, "Key"]Applications (1)
Create a QuestionObject using "Date" interpretation on the inputs:
QuestionObject[QuestionInterface["ShortAnswer", <|"Prompt" -> "When did the Battle of Hastings begin?", "Interpreter" -> "Date"|>], AssessmentFunction[ Entity["MilitaryConflict", "BattleOfHastings"]["StartDate"], Tolerance -> Quantity[1, "Century"]]]Properties & Relations (1)
Create a QuestionObject treating years as numbers:
QuestionObject["Within fifty, in what year did Genghis Khan die?", AssessmentFunction[Entity["Person", "GenghisKhan::3256b"][EntityProperty["Person", "DeathDate"]]["Year"], "Number", Tolerance -> 50]]Using "Date" comparison with interpretation allows all common date forms:
QuestionObject[QuestionInterface["ShortAnswer", <|"Prompt" -> "Within fifty years, when did Genghis Khan die?", "Interpreter" -> "Date"|>], AssessmentFunction[Entity["Person", "GenghisKhan::3256b"][EntityProperty["Person", "DeathDate"]], "Date", Tolerance -> Quantity[50, "Years"]]]Possible Issues (2)
Answers with smaller granularities than the answer key are compared to the starting point of the key and may have nonzero distances:
daygranularity = AssessmentFunction[DateObject[{2024, 6, 1}], "Date"]daygranularity[DateObject[{2024, 6, 1, 10, 0, 0}]]Create a custom distance function conforming the answer to match the granularity of the answer key:
matchgranularity = AssessmentFunction[DateObject[{2024, 6, 1}], "Date", DistanceFunction -> (Abs@DateDifference[DateObject[#1, "Day"], #2]&)]Any value within the answer key date is marked correct:
matchgranularity[DateObject[{2024, 6, 1, 10, 0, 0}]]The date comparison method will be automatically inferred only if the answer key is a DateObject:
AssessmentFunction[DateObject[{2024, 1}]]Other date specifications will not automatically be treated as dates:
AssessmentFunction[{{2024, 1}}]Specify the method explicitly:
AssessmentFunction[{{2024, 1}}, "Date"]See Also
AssessmentFunction QuestionObject DateDifference DateObject
Question Interface Types: ShortAnswer MultipleShortAnswers