You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for creating and maintaining the recurrent library—it's a powerful tool for parsing natural language date and time expressions. However, I've noticed an issue where the library doesn't correctly interpret the word "now" as the current date and time.
Here the code with an example
import datetime
from recurrent.event_parser import RecurringEvent
# Create an instance of the parser with the current date and time
now_date = datetime.datetime.now()
parser = RecurringEvent(now_date=now_date)
# Define the specific string to test
time_string = "are you free now?"
# Function to extract dates
def extract_dates(text):
"""
Parses the provided text to extract a date or time.
Args:
text (str): The natural language text to parse.
Returns:
datetime.datetime or None: The parsed datetime object or None if parsing fails.
"""
try:
parsed_date = parser.parse(text) # Parse the input text
if isinstance(parsed_date, datetime.datetime): # Check if the result is a datetime object
return parsed_date # Return the parsed date
else:
return None # Return None if parsing fails or the result is not a datetime
except Exception as e:
return str(e) # Return the exception message if an error occurs
# Extract the date for the specific test string
extracted_date = extract_dates(time_string)
# Print the result
print(f"'{time_string}':\t{extracted_date}")
This is the ouput:
Expected Behavior:
The library should return the current date and time when parsing the word "now".
Actual Behavior:
The library fails to return the current date and time or does not recognize "now" correctly.
Improving the handling of the word "now" would enhance the library’s ability to process real-time queries. Thank you for considering this enhancement!
The text was updated successfully, but these errors were encountered:
Thank you for creating and maintaining the recurrent library—it's a powerful tool for parsing natural language date and time expressions. However, I've noticed an issue where the library doesn't correctly interpret the word "now" as the current date and time.
Here the code with an example
This is the ouput:
Expected Behavior:
The library should return the current date and time when parsing the word "now".
Actual Behavior:
The library fails to return the current date and time or does not recognize "now" correctly.
Improving the handling of the word "now" would enhance the library’s ability to process real-time queries. Thank you for considering this enhancement!
The text was updated successfully, but these errors were encountered: