Spaces:
Sleeping
Sleeping
Update src/core/AcronymManager.py
Browse files- src/core/AcronymManager.py +19 -2
src/core/AcronymManager.py
CHANGED
|
@@ -8,9 +8,26 @@ class AcronymManager:
|
|
| 8 |
Maintains a global dictionary of Acronym -> Definition mappings.
|
| 9 |
Persists to disk so knowledge is shared across all documents and sessions.
|
| 10 |
"""
|
| 11 |
-
def __init__(self, storage_path=
|
| 12 |
# We save this in the current directory so it persists
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
self.acronyms = self._load_acronyms()
|
| 15 |
self.logger = logging.getLogger(__name__)
|
| 16 |
|
|
|
|
| 8 |
Maintains a global dictionary of Acronym -> Definition mappings.
|
| 9 |
Persists to disk so knowledge is shared across all documents and sessions.
|
| 10 |
"""
|
| 11 |
+
def __init__(self, storage_path=None):
|
| 12 |
# We save this in the current directory so it persists
|
| 13 |
+
if storage_path:
|
| 14 |
+
self.storage_path = storage_path
|
| 15 |
+
else:
|
| 16 |
+
# 1. Get the absolute path to this file (AcronymManager.py)
|
| 17 |
+
# Example: /app/src/core/AcronymManager.py
|
| 18 |
+
current_file_path = os.path.abspath(__file__)
|
| 19 |
+
|
| 20 |
+
# 2. Go up one level to the 'core' folder
|
| 21 |
+
core_dir = os.path.dirname(current_file_path)
|
| 22 |
+
|
| 23 |
+
# 3. Go up one more level to the 'src' folder (or app root)
|
| 24 |
+
src_dir = os.path.dirname(core_dir)
|
| 25 |
+
|
| 26 |
+
# 4. Define the path explicitly
|
| 27 |
+
self.storage_path = os.path.join(src_dir, "acronyms.json")
|
| 28 |
+
|
| 29 |
+
self.logger = logging.getLogger(__name__)
|
| 30 |
+
self.acronyms = self._load_acronyms()
|
| 31 |
self.acronyms = self._load_acronyms()
|
| 32 |
self.logger = logging.getLogger(__name__)
|
| 33 |
|