Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
b1635457
Unverified
Commit
b1635457
authored
Mar 07, 2024
by
Bowen Liang
Committed by
GitHub
Mar 07, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `python-docx` to extract docx files (#2654)
parent
c0b82f8e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
10 deletions
+12
-10
word_extractor.py
api/core/rag/extractor/word_extractor.py
+11
-9
requirements.txt
api/requirements.txt
+1
-1
No files found.
api/core/rag/extractor/word_extractor.py
View file @
b1635457
...
@@ -10,7 +10,7 @@ from core.rag.models.document import Document
...
@@ -10,7 +10,7 @@ from core.rag.models.document import Document
class
WordExtractor
(
BaseExtractor
):
class
WordExtractor
(
BaseExtractor
):
"""Load
pdf
files.
"""Load
docx
files.
Args:
Args:
...
@@ -46,14 +46,16 @@ class WordExtractor(BaseExtractor):
...
@@ -46,14 +46,16 @@ class WordExtractor(BaseExtractor):
def
extract
(
self
)
->
list
[
Document
]:
def
extract
(
self
)
->
list
[
Document
]:
"""Load given path as single page."""
"""Load given path as single page."""
import
docx2txt
from
docx
import
Document
as
docx_Document
return
[
document
=
docx_Document
(
self
.
file_path
)
Document
(
doc_texts
=
[
paragraph
.
text
for
paragraph
in
document
.
paragraphs
]
page_content
=
docx2txt
.
process
(
self
.
file_path
),
content
=
'
\n
'
.
join
(
doc_texts
)
metadata
=
{
"source"
:
self
.
file_path
},
)
return
[
Document
(
]
page_content
=
content
,
metadata
=
{
"source"
:
self
.
file_path
},
)]
@
staticmethod
@
staticmethod
def
_is_valid_url
(
url
:
str
)
->
bool
:
def
_is_valid_url
(
url
:
str
)
->
bool
:
...
...
api/requirements.txt
View file @
b1635457
...
@@ -32,7 +32,7 @@ celery==5.2.7
...
@@ -32,7 +32,7 @@ celery==5.2.7
redis~=4.5.4
redis~=4.5.4
openpyxl==3.1.2
openpyxl==3.1.2
chardet~=5.1.0
chardet~=5.1.0
docx2txt==0.8
python-docx~=1.1.0
pypdfium2==4.16.0
pypdfium2==4.16.0
resend~=0.7.0
resend~=0.7.0
pyjwt~=2.8.0
pyjwt~=2.8.0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment