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---
212sidebar_label: docx_wrangling
313title: 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
827Update 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
2956Return 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
4280Scan 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
57107Use GPT to rewrite the contents of a DOCX file paragraph by paragraph. Does not handle tables, footers, or
58108other 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
109165Convert 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
113175Uses OpenAI to guess the variable names for a document and then modifies the document with the guesses.
114176
0 commit comments