Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to extract date when intent is "What date is today?" #1350

Open
al06825 opened this issue Aug 14, 2023 · 3 comments
Open

How to extract date when intent is "What date is today?" #1350

al06825 opened this issue Aug 14, 2023 · 3 comments

Comments

@al06825
Copy link

al06825 commented Aug 14, 2023

Software Version
nlp.js 4.27.0
node 18.16.0
npm 9.5.1
Operating System Win 10

I wanna extract date when intent is "What date is today?"
I got answer to be "Today is {{date}}" and it returned "Today is today" per the log below.

I wish to have answer like "Today is 2023-08-14"... but how?

Below is the log I got....

"intent": "inquiry.today",
"score": 0.9992725501954545,
"domain": "default",
"sourceEntities": [
{
"start": 12,
"end": 16,
"resolution": {
"values": [
{
"timex": "2023-08-14",
"type": "date",
"value": "2023-08-14"
}
]
},
"text": "today",
"typeName": "datetimeV2.date",
"entity": "date"
}
],
"entities": [
{
"start": 12,
"end": 16,
"len": 5,
"accuracy": 0.95,
"sourceText": "today",
"utteranceText": "today",
"entity": "date",
"rawEntity": "datetimeV2.date",
"resolution": {
"type": "date",
"timex": "2023-08-14",
"strValue": "2023-08-14",
"date": "2023-08-14T00:00:00.000Z"
}
}
],
"answers": [
{
"answer": "Today is today"
}
],
"answer": "Today is today",

@MarketingPip
Copy link

@al06825 - not an official maintainer / nor a contributor. But pretty familiar with this package.

You need to refer to the NER Manager - Built-in Entites & register a entity extractor. Then you can parse the utterance with your chose of entity extractor to do something like this (assuming the extractor you choose has date supports).

Other than that - read the documentation (the page I linked to) & it should answer your question in full.

Hope this helps! 😄

@al06825
Copy link
Author

al06825 commented Oct 17, 2023 via email

@MarketingPip
Copy link

@al06825 I didn't even realize either! Assuming you the date in that log is correct - you can use the entity for the date by grabbing the JSON value / key with corresponding entity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants