Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Returning invalid values when input is wrong #134

Open
VivekMahale-TFT opened this issue Nov 3, 2023 · 1 comment
Open

Returning invalid values when input is wrong #134

VivekMahale-TFT opened this issue Nov 3, 2023 · 1 comment

Comments

@VivekMahale-TFT
Copy link

VivekMahale-TFT commented Nov 3, 2023

  • ctparse - Parse natural language time expressions in Python version:
  • Python version: 3.10
  • Operating System: Linux

Description

Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.

What I did do?

I encountered issues with ctparse while using it for natural language date and time processing, especially with return dates. When attempting date-time validation, I observed problems with ctparse not providing None responses for incorrect inputs, sometimes generating random dates.

I have attached image for reference:

The examples one is correct,

Screenshot from 2023-11-03 16-29-17

I plan to raise this issue on GitHub and seek a solution if possible.

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
@sebastianmika
Copy link
Contributor

Hi,

thanks for sharing your feedback. However, I am afraid there is no straight forward solution to your problem, at least none that I am seeing. ctparse by nature is not perfect but rather tries to generate the best possible match. I.e. as long as there is one rule that generates at least one production, that will be returned.

To mitigate your issue you can build auxiallary logic on the meta data in the response:

res = ctparse("how are you?")
# the score can be understood as log-quality - very small values like this are a sign of low quality
res.score
# how much of the original text was used for this response? If that is just a small part (here 1/4) there is likely something fishy
len(res.resolution) / len("how are you?")

I hope that helps.

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

No branches or pull requests

2 participants