-
Notifications
You must be signed in to change notification settings - Fork 1
/
strategies.py
25 lines (21 loc) · 792 Bytes
/
strategies.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from enum import Enum
from .layout import LayoutDocumentLoading
from .read import ReadDocumentLoading
from .web import WebDocumentLoading
from .word_document import WordDocumentLoading
class LoadingStrategy(Enum):
LAYOUT = "layout"
READ = "read"
WEB = "web"
DOCX = "docx"
def get_document_loader(loader_strategy: str):
if loader_strategy == LoadingStrategy.LAYOUT.value:
return LayoutDocumentLoading()
elif loader_strategy == LoadingStrategy.READ.value:
return ReadDocumentLoading()
elif loader_strategy == LoadingStrategy.WEB.value:
return WebDocumentLoading()
elif loader_strategy == LoadingStrategy.DOCX.value:
return WordDocumentLoading()
else:
raise Exception(f"Unknown loader strategy: {loader_strategy}")