diff --git a/processor/org_mode/org_to_jsonl.py b/processor/org_mode/org_to_jsonl.py index 016435d3..9e786abb 100644 --- a/processor/org_mode/org_to_jsonl.py +++ b/processor/org_mode/org_to_jsonl.py @@ -2,6 +2,7 @@ # Import Modules import processor.org_mode.orgnode +from utils.helpers import get_absolute_path, is_none_or_empty import json import argparse import pathlib @@ -119,14 +120,6 @@ def convert_org_entries_to_jsonl(entries, verbose=0): return jsonl -def is_none_or_empty(item): - return item == None or (hasattr(item, '__iter__') and len(item) == 0) - - -def get_absolute_path(filepath): - return str(pathlib.Path(filepath).expanduser().absolute()) - - if __name__ == '__main__': # Setup Argument Parser parser = argparse.ArgumentParser(description="Map Org-Mode notes into (compressed) JSONL format") diff --git a/search_type/asymmetric.py b/search_type/asymmetric.py index ddcd526e..74078563 100644 --- a/search_type/asymmetric.py +++ b/search_type/asymmetric.py @@ -10,7 +10,7 @@ import re import torch import argparse import pathlib - +from utils.helpers import get_absolute_path def initialize_model(): "Initialize model for assymetric semantic search. That is, where query smaller than results" @@ -140,10 +140,6 @@ def collate_results(hits, entries, count=5): in hits[0:count]] -def get_absolute_path(filepath): - return str(pathlib.Path(filepath).expanduser().absolute()) - - if __name__ == '__main__': # Setup Argument Parser parser = argparse.ArgumentParser(description="Map Org-Mode notes into (compressed) JSONL format") diff --git a/utils/__init__.py b/utils/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/utils/helpers.py b/utils/helpers.py new file mode 100644 index 00000000..64902835 --- /dev/null +++ b/utils/helpers.py @@ -0,0 +1,9 @@ +import pathlib + + +def is_none_or_empty(item): + return item == None or (hasattr(item, '__iter__') and len(item) == 0) + + +def get_absolute_path(filepath): + return str(pathlib.Path(filepath).expanduser().absolute())