Detection and Normalization of Temporal Expressions in French Text — Part 4: A Demonstrator Application

5. The Demonstrator Application

5.1 The Use Case

  • “Je veux un résumé de mes transactions aujourd’hui.”
  • “Je voudrais demander un certificat pour les 3 derniers mois svp !”
  • “Je voudrais demander un document pour décembre et janvier derniers svp.”
  • Pouvez-vous m’envoyer un document pour février à mars 2020 et depuis le mois d’octobre 2021 svp ?
  • Pouvez-vous m’envoyer un document pour la semaine prochaine svp ?
  • [2022-02-21, 2022-02-22),
  • [2021-11-21, 2022-02-22),
  • [2021-12-01, 2022-01-01) and [2022-01-01, 2022-02-01) (or [2021-12-01, 2022-02-01) if we merge those two intervals)
  • [2020-02-01, 2020-04-01) and [2021-10-01, 2022-02-02)
  • [2022-02-22, 2022-03-02)

5.2 The Demonstrator Application

  • (1) Graphical representation
  • (2) Prediction from the ML Model
  • (3) Prediction from the ML model (in tuple format)
  • (4) Deduced periods
  • (2): We retrieve the raw output from the machine learning model, which is our famous normalized temporal expressions defined in article 2 and trained as described in article 3.
  • (3): Same raw output as (2), but rewritten under the format of a structured object to be better processed by the machine.
  • (4): The objects in (3) are post-processed by referencing the current day to retrieve the correct periods.
  • (1): We represent the objects in (4) under user-friendly graphs thanks to available libraries.

5.3 Implementation: The Back-end

Documentation and example of the request body for the API
Example of response for the above request.
{
"preds": [
"REL DIR - CURRENT D0"
],
"context": {
...
}
}

5.4 Implementation: The Front-end

  • 5.4.1 Convert the normalized expressions to JSON objects: We convert strings like
ABS DIR - PAST M2
{
"type": "ABS",
"value": [
{
"unit": "M",
"value": 2
}
],
"mode": "DIR",
"tense": "PAST"
}
{
ABS: "type",
REL: "type",
DUR: "type",
FREQ: "type",
NONE: "type",
DIR: "mode",
IND: "mode",
FROM: "anchor",
TO: "anchor",
BEFORE: "anchor",
AFTER: "anchor",
PREV: "tense",
NEXT: "tense",
PAST: "tense",
FUTURE: "tense",
CURRENT:"tense",
START: "partial",
MID: "partial",
END: "partial",
LESS: "approximation",
MORE: "approximation",
APPROX: "approximation",
FIRST: "ordinal",
LAST: "ordinal"
}
  • 5.4.2 Post-processing to get absolute dates: To retrieve the final dates from the temporal expressions and the reference date (today, for example): no magic, we need to consider every single case of type, tense and value as described in the table at the end of section 3.
  • 5.4.3 Graphical representation: Finally, to represent the periods under a graph, we use timelines of the library apexcharts. The library supports Angular, ReactJS and VueJS frameworks and also pure JS. You can have a look if you are interested.

Recap

References

Acknowledgement

About

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
La Javaness R&D

La Javaness R&D

We help organizations to succeed in the new paradigm of “AI@scale”, by using machine intelligence responsibly and efficiently : www.lajavaness.com