mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-27 17:35:07 +01:00
Allow reuse of get_absolute_path, is_none_or_empty methods
- Move them to utils.helper.py for reuse - Import those modules where required - Delete duplicate methods defined in org_to_jsonl.py, asymmetric.py
This commit is contained in:
parent
9703afb814
commit
649e5d1327
4 changed files with 11 additions and 13 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
# Import Modules
|
# Import Modules
|
||||||
import processor.org_mode.orgnode
|
import processor.org_mode.orgnode
|
||||||
|
from utils.helpers import get_absolute_path, is_none_or_empty
|
||||||
import json
|
import json
|
||||||
import argparse
|
import argparse
|
||||||
import pathlib
|
import pathlib
|
||||||
|
@ -119,14 +120,6 @@ def convert_org_entries_to_jsonl(entries, verbose=0):
|
||||||
return jsonl
|
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__':
|
if __name__ == '__main__':
|
||||||
# Setup Argument Parser
|
# Setup Argument Parser
|
||||||
parser = argparse.ArgumentParser(description="Map Org-Mode notes into (compressed) JSONL format")
|
parser = argparse.ArgumentParser(description="Map Org-Mode notes into (compressed) JSONL format")
|
||||||
|
|
|
@ -10,7 +10,7 @@ import re
|
||||||
import torch
|
import torch
|
||||||
import argparse
|
import argparse
|
||||||
import pathlib
|
import pathlib
|
||||||
|
from utils.helpers import get_absolute_path
|
||||||
|
|
||||||
def initialize_model():
|
def initialize_model():
|
||||||
"Initialize model for assymetric semantic search. That is, where query smaller than results"
|
"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]]
|
in hits[0:count]]
|
||||||
|
|
||||||
|
|
||||||
def get_absolute_path(filepath):
|
|
||||||
return str(pathlib.Path(filepath).expanduser().absolute())
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# Setup Argument Parser
|
# Setup Argument Parser
|
||||||
parser = argparse.ArgumentParser(description="Map Org-Mode notes into (compressed) JSONL format")
|
parser = argparse.ArgumentParser(description="Map Org-Mode notes into (compressed) JSONL format")
|
||||||
|
|
0
utils/__init__.py
Normal file
0
utils/__init__.py
Normal file
9
utils/helpers.py
Normal file
9
utils/helpers.py
Normal file
|
@ -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())
|
Loading…
Reference in a new issue