Skip to content

Commit 6804f70

Browse files
Merge pull request #565 from SuffolkLITLab/formfyxer_dir
Stop making two folders for FormFyxer
2 parents 2e6aebc + cc051f6 commit 6804f70

File tree

7 files changed

+613
-1314
lines changed

7 files changed

+613
-1314
lines changed

docs/components/FormFyxer/docx_wrangling.md

Lines changed: 68 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
1+
# Table of Contents
2+
3+
* [formfyxer.docx\_wrangling](#formfyxer.docx_wrangling)
4+
* [update\_docx](#formfyxer.docx_wrangling.update_docx)
5+
* [get\_docx\_repr](#formfyxer.docx_wrangling.get_docx_repr)
6+
* [get\_labeled\_docx\_runs](#formfyxer.docx_wrangling.get_labeled_docx_runs)
7+
* [get\_modified\_docx\_runs](#formfyxer.docx_wrangling.get_modified_docx_runs)
8+
* [make\_docx\_plain\_language](#formfyxer.docx_wrangling.make_docx_plain_language)
9+
* [modify\_docx\_with\_openai\_guesses](#formfyxer.docx_wrangling.modify_docx_with_openai_guesses)
10+
111
---
212
sidebar_label: docx_wrangling
313
title: formfyxer.docx_wrangling
414
---
515

6-
#### update\_docx
16+
<a id="formfyxer.docx_wrangling.update_docx"></a>
17+
18+
#### update\_docx(document: Union[docx.document.Document, str], modified\_runs: List[Tuple[int, int, str, int]])
19+
20+
```python
21+
def update_docx(
22+
document: Union[docx.document.Document, str],
23+
modified_runs: List[Tuple[int, int, str,
24+
int]]) -> docx.document.Document
25+
```
726

827
Update the document with the modified runs.
928

@@ -24,7 +43,15 @@ Take a careful look at the output document to make sure it is still correct.
2443

2544
The modified document.
2645

27-
#### get\_docx\_repr
46+
<a id="formfyxer.docx_wrangling.get_docx_repr"></a>
47+
48+
#### get\_docx\_repr(docx\_path: str, paragraph\_start: int = 0, paragraph\_end: Optional[int] = None)
49+
50+
```python
51+
def get_docx_repr(docx_path: str,
52+
paragraph_start: int = 0,
53+
paragraph_end: Optional[int] = None)
54+
```
2855

2956
Return a JSON representation of the paragraphs and runs in the DOCX file.
3057

@@ -37,7 +64,18 @@ Return a JSON representation of the paragraphs and runs in the DOCX file.
3764

3865
A JSON representation of the paragraphs and runs in the DOCX file.
3966

40-
#### get\_labeled\_docx\_runs
67+
<a id="formfyxer.docx_wrangling.get_labeled_docx_runs"></a>
68+
69+
#### get\_labeled\_docx\_runs(docx\_path: Optional[str] = None, docx\_repr=Optional[str], custom\_people\_names: Optional[Tuple[str, str]] = None, openai\_client: Optional[OpenAI] = None, api\_key: Optional[str] = None)
70+
71+
```python
72+
def get_labeled_docx_runs(
73+
docx_path: Optional[str] = None,
74+
docx_repr=Optional[str],
75+
custom_people_names: Optional[Tuple[str, str]] = None,
76+
openai_client: Optional[OpenAI] = None,
77+
api_key: Optional[str] = None) -> List[Tuple[int, int, str, int]]
78+
```
4179

4280
Scan the DOCX and return a list of modified text with Jinja2 variable names inserted.
4381

@@ -52,7 +90,19 @@ Scan the DOCX and return a list of modified text with Jinja2 variable names inse
5290

5391
A list of tuples, each containing a paragraph number, run number, and the modified text of the run.
5492

55-
#### get\_modified\_docx\_runs
93+
<a id="formfyxer.docx_wrangling.get_modified_docx_runs"></a>
94+
95+
#### get\_modified\_docx\_runs(docx\_path: Optional[str] = None, docx\_repr: Optional[str] = None, custom\_example: str = "", instructions: str = "", openai\_client: Optional[OpenAI] = None, api\_key: Optional[str] = None, temperature=0.5)
96+
97+
```python
98+
def get_modified_docx_runs(docx_path: Optional[str] = None,
99+
docx_repr: Optional[str] = None,
100+
custom_example: str = "",
101+
instructions: str = "",
102+
openai_client: Optional[OpenAI] = None,
103+
api_key: Optional[str] = None,
104+
temperature=0.5) -> List[Tuple[int, int, str, int]]
105+
```
56106

57107
Use GPT to rewrite the contents of a DOCX file paragraph by paragraph. Does not handle tables, footers, or
58108
other structures yet.
@@ -104,11 +154,23 @@ You may also want to customize the input example to better match your use case.
104154

105155
A list of tuples, each containing a paragraph number, run number, and the modified text of the run.
106156

107-
#### make\_docx\_plain\_language
157+
<a id="formfyxer.docx_wrangling.make_docx_plain_language"></a>
158+
159+
#### make\_docx\_plain\_language(docx\_path: str)
160+
161+
```python
162+
def make_docx_plain_language(docx_path: str) -> docx.document.Document
163+
```
108164

109165
Convert a DOCX file to plain language with the help of OpenAI.
110166

111-
#### modify\_docx\_with\_openai\_guesses
167+
<a id="formfyxer.docx_wrangling.modify_docx_with_openai_guesses"></a>
168+
169+
#### modify\_docx\_with\_openai\_guesses(docx\_path: str)
170+
171+
```python
172+
def modify_docx_with_openai_guesses(docx_path: str) -> docx.document.Document
173+
```
112174

113175
Uses OpenAI to guess the variable names for a document and then modifies the document with the guesses.
114176

0 commit comments

Comments
 (0)