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
+
1
11
---
2
12
sidebar_label: docx_wrangling
3
13
title: formfyxer.docx_wrangling
4
14
---
5
15
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
+ ```
7
26
8
27
Update the document with the modified runs.
9
28
@@ -24,7 +43,15 @@ Take a careful look at the output document to make sure it is still correct.
24
43
25
44
The modified document.
26
45
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
+ ```
28
55
29
56
Return a JSON representation of the paragraphs and runs in the DOCX file.
30
57
@@ -37,7 +64,18 @@ Return a JSON representation of the paragraphs and runs in the DOCX file.
37
64
38
65
A JSON representation of the paragraphs and runs in the DOCX file.
39
66
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
+ ```
41
79
42
80
Scan the DOCX and return a list of modified text with Jinja2 variable names inserted.
43
81
@@ -52,7 +90,19 @@ Scan the DOCX and return a list of modified text with Jinja2 variable names inse
52
90
53
91
A list of tuples, each containing a paragraph number, run number, and the modified text of the run.
54
92
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
+ ```
56
106
57
107
Use GPT to rewrite the contents of a DOCX file paragraph by paragraph. Does not handle tables, footers, or
58
108
other structures yet.
@@ -104,11 +154,23 @@ You may also want to customize the input example to better match your use case.
104
154
105
155
A list of tuples, each containing a paragraph number, run number, and the modified text of the run.
106
156
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
+ ```
108
164
109
165
Convert a DOCX file to plain language with the help of OpenAI.
110
166
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
+ ```
112
174
113
175
Uses OpenAI to guess the variable names for a document and then modifies the document with the guesses.
114
176
0 commit comments