DOCX
gllm-docproc | Tutorial: DOCX Loader | Use Case: Advanced DPO Pipeline | API Reference
DOCX Loader is a component designed for extracting information from a DOCX file and converting it into a standardized JSON format.
Installation
# you can use a Conda environment
pip install --extra-index-url https://oauth2accesstoken:$(gcloud auth print-access-token)@glsdk.gdplabs.id/gen-ai-internal/simple/ "gllm-docproc[docx]"# you can use a Conda environment
$token = (gcloud auth print-access-token)
pip install --extra-index-url "https://oauth2accesstoken:$token@glsdk.gdplabs.id/gen-ai-internal/simple/" "gllm-docproc[docx]"# you can use a Conda environment
FOR /F "tokens=*" %T IN ('gcloud auth print-access-token') DO SET TOKEN=%T
pip install --extra-index-url "https://oauth2accesstoken:%TOKEN%@glsdk.gdplabs.id/gen-ai-internal/simple/" "gllm-docproc[docx]"You can use the following as a sample file: docx-example.docx.
Recommendation
We recommend to use DOCX2Python Loader.
DOCX2Python Loader
DOCX2PythonLoader is responsible to extract Text, Tables, and Images from within DOCX document by using the python-docx library.
Create a script called main.py:
from gllm_docproc.loader.docx import DOCX2PythonLoader
source = "./data/source/docx-example.docx"
# initialize DOCX2Python Loader
loader = DOCX2PythonLoader()
# load source
loaded_elements = loader.load(source)Run the script:
python main.pyThe loader will generate the following: output JSON.
Python DOCX Loader
PythonDOCXLoader is responsible to extract Text and Tables from within DOCX document body by using the docx2python library.
Create a script called main.py:
Run the script:
The loader will generate the following: output JSON.
Python DOCX Table Loader
PythonDOCXTableLoader is responsible to extract Tables from within DOCX document body by using the python-docx library.
Create a script called main.py:
Run the script:
The loader will generate the following: output JSON.
Last updated