From 4ead79d272a5cc86e5a10b8efd07166ad5584499 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Thu, 21 Jul 2022 01:00:15 +0400 Subject: [PATCH] Make Notes Search Natural Language Date Aware - Pass Scheduled, Closed Dates of Entries to Include in Embeddings - The (new?) model seems to understand dates. So can give more relevant entries if date in natural language mentioned in query - E.g "Went Surfing with Friends" vs "Went Surfing with Friends in 1984" will give different results, with the second prioritizing entries mentioning any entries with closed, scheduled dates from 1984 --- src/processor/org_mode/org_to_jsonl.py | 10 ++++++++++ src/search_type/asymmetric.py | 9 ++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/processor/org_mode/org_to_jsonl.py b/src/processor/org_mode/org_to_jsonl.py index 2c3c404b..a7e734cc 100644 --- a/src/processor/org_mode/org_to_jsonl.py +++ b/src/processor/org_mode/org_to_jsonl.py @@ -115,6 +115,16 @@ def convert_org_entries_to_jsonl(entries, verbose=0): if verbose > 2: print(f"Tags: {tags_str}") + if entry.Closed(): + entry_dict["Closed"] = entry.Closed().strftime("%Y-%m-%d") + if verbose > 2: + print(f'Closed: {entry.Closed().strftime("%Y-%m-%d")}') + + if entry.Scheduled(): + entry_dict["Scheduled"] = entry.Scheduled().strftime("%Y-%m-%d") + if verbose > 2: + print(f'Scheduled: {entry.Scheduled().strftime("%Y-%m-%d")}') + if entry.Body(): entry_dict["Body"] = entry.Body() if verbose > 2: diff --git a/src/search_type/asymmetric.py b/src/search_type/asymmetric.py index d2b1886d..4b28f1dc 100644 --- a/src/search_type/asymmetric.py +++ b/src/search_type/asymmetric.py @@ -60,9 +60,12 @@ def extract_entries(notesfile, verbose=0): if not "Body" in note or note["Body"].strip(empty_escape_sequences) == "": continue - note_string = f'{note["Title"]}' \ - f'\t{note["Tags"] if "Tags" in note else ""}' \ - f'\n{note["Body"] if "Body" in note else ""}' + scheduled_str = f'\t Scheduled for {note["Scheduled"]}' if "Scheduled" in note else "" + closed_str = f'\t Closed on {note["Closed"]}' if "Closed" in note else "" + tags_str = f'\t {note["Tags"]}' if "Tags" in note else "" + body_str = f'\n {note["Body"]}' if "Body" in note else "" + + note_string = f'{note["Title"]}{tags_str}{closed_str}{scheduled_str}{body_str}' entries.append({'compiled': note_string, 'raw': note["Raw"]}) # Close File