Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.
Python ai4sciencedocument-analysisdocxextract-datalayout-analysisocrparserpdfpdf-converterpdf-extractor-llmpdf-extractor-pretrainpdf-extractor-ragpdf-parserpptxpythonxlsx
feat: refactor DOCX utilities and update dependencies for improved processing
myhloli6f766641413b
diff --git a/mineru/model/docx/docx_converter.py b/mineru/model/docx/docx_converter.pyindex 3c35472e..2439a86f 100644--- a/mineru/model/docx/docx_converter.py+++ b/mineru/model/docx/docx_converter.py@@ -14,11 +14,11 @@ from docx.text.hyperlink import Hyperlinkfrom docx.text.run import Runfrom lxml import etreefrom pydantic import AnyUrl+from mammoth.conversion import convert_document_element_to_html+from mammoth.docx import body_xml-from mineru.model.utils.docx.mammoth import body_xml-from mineru.model.utils.docx.mammoth.conversion import convert_document_element_to_html-from mineru.model.utils.docx.mammoth.office_xml import read_str-from mineru.model.utils.docx.math.omml import oMath2Latex+from mineru.model.docx.tools.office_xml import read_str+from mineru.model.docx.tools.math.omml import oMath2Latexfrom mineru.utils.docx_fomatting import Formatting, Scriptfrom mineru.utils.enum_class import BlockType, ContentTypefrom mineru.utils.pdf_reader import image_to_b64strdiff --git a/mineru/model/docx/equations.docx b/mineru/model/docx/equations.docxnew file mode 100644index 00000000..5ae9bf8dBinary files /dev/null and b/mineru/model/docx/equations.docx differdiff --git a/mineru/model/docx/main.py b/mineru/model/docx/main.pyindex fd20f6d4..3122f0e4 100644--- a/mineru/model/docx/main.py+++ b/mineru/model/docx/main.py@@ -14,4 +14,5 @@ def convert_binary(file_binary: BinaryIO):return converter.blocksif __name__ == "__main__":- print(convert_path("test.docx"))\ No newline at end of file+ # print(convert_path("test.docx"))+ print(convert_path("equations.docx"))\ No newline at end of filediff --git a/mineru/model/docx/tools/__init__.py b/mineru/model/docx/tools/__init__.pynew file mode 100644index 00000000..1e17167c--- /dev/null+++ b/mineru/model/docx/tools/__init__.py@@ -0,0 +1 @@+# Copyright (c) Opendatalab. All rights reserved.diff --git a/mineru/model/utils/docx/__init__.py b/mineru/model/docx/tools/math/__init__.pysimilarity index 100%rename from mineru/model/utils/docx/__init__.pyrename to mineru/model/docx/tools/math/__init__.pydiff --git a/mineru/model/utils/docx/math/latex_dict.py b/mineru/model/docx/tools/math/latex_dict.pysimilarity index 100%rename from mineru/model/utils/docx/math/latex_dict.pyrename to mineru/model/docx/tools/math/latex_dict.pydiff --git a/mineru/model/utils/docx/math/omml.py b/mineru/model/docx/tools/math/omml.pysimilarity index 100%rename from mineru/model/utils/docx/math/omml.pyrename to mineru/model/docx/tools/math/omml.pydiff --git a/mineru/model/docx/tools/office_xml.py b/mineru/model/docx/tools/office_xml.pynew file mode 100644index 00000000..d811cade--- /dev/null+++ b/mineru/model/docx/tools/office_xml.py@@ -0,0 +1,55 @@+import xml.dom.minidom++from mammoth.docx.xmlparser import XmlText, XmlElement+from mammoth.docx.office_xml import _collapse_alternate_content, _namespaces+++def parse_xml_str(xml_str, namespace_mapping=None):+ if namespace_mapping is None:+ namespace_prefixes = {}+ else:+ namespace_prefixes = dict((uri, prefix) for prefix, uri in namespace_mapping)++ document = xml.dom.minidom.parseString(xml_str)++ def convert_node(node):+ if node.nodeType == xml.dom.Node.ELEMENT_NODE:+ return convert_element(node)+ elif node.nodeType == xml.dom.Node.TEXT_NODE:+ return XmlText(node.nodeValue)+ else:+ return None++ def convert_element(element):+ converted_name = convert_name(element)++ converted_attributes = dict(+ (convert_name(attribute), attribute.value)+ for attribute in element.attributes.values()+ if attribute.namespaceURI != "http://www.w3.org/2000/xmlns/"+ )++ converted_children = []+ for child_node in element.childNodes:+ converted_child_node = convert_node(child_node)+ if converted_child_node is not None:+ converted_children.append(converted_child_node)++ return XmlElement(converted_name, converted_attributes, converted_children)++ def convert_name(node):+ if node.namespaceURI is None:+ return node.localName+ else:+ prefix = namespace_prefixes.get(node.namespaceURI)+ if prefix is None:+ return "{%s}%s" % (node.namespaceURI, node.localName)+ else:+ return "%s:%s" % (prefix, node.localName)++ return convert_node(document.documentElement)+++def read_str(xml_str):+ i = parse_xml_str(xml_str, _namespaces)+ return _collapse_alternate_content(i)[0]diff --git a/mineru/model/utils/docx/mammoth/__init__.py b/mineru/model/utils/docx/mammoth/__init__.pydeleted file mode 100644index e69de29b..00000000diff --git a/mineru/model/utils/docx/mammoth/body_xml.py b/mineru/model/utils/docx/mammoth/body_xml.pydeleted file mode 100644index 65900cff..00000000--- a/mineru/model/utils/docx/mammoth/body_xml.py+++ /dev/null@@ -1,810 +0,0 @@-import contextlib-import re-import sys-from . import documents-from . import results-from . import lists-from . import transforms-from . import complex_fields-from . import dingbats-from .xmlparser import node_types, XmlElement, null_xml_element-from .styles_xml import Styles-from .uris import replace_fragment, uri_to_zip_entry_name--if sys.version_info >= (3, ):- unichr = chr---def reader(- numbering=None,- content_types=None,- relationships=None,- styles=None,- docx_file=None,- files=None-):-- if styles is None:- styles = Styles.EMPTY-- read_all = _create_reader(- numbering=numbering,- content_types=content_types,- relationships=relationships,- styles=styles,- docx_file=docx_file,- files=files,- )- return _BodyReader(read_all)----class _BodyReader(object):- def __init__(self, read_all):- self._read_all = read_all-- def read_all(self, elements):- result = self._read_all(elements)- return results.Result(result.elements, result.messages)---def _create_reader(numbering, content_types, relationships, styles, docx_file, files):- current_instr_text = []- complex_field_stack = []-- # When a paragraph is marked as deleted, its contents should be combined- # with the following paragraph. See 17.13.5.15 del (Deleted Paragraph) of- # ECMA-376 4th edition Part 1.- deleted_paragraph_contents = []-- _ignored_elements = set([- "office-word:wrap",- "v:shadow",- "v:shapetype",- "w:annotationRef",- "w:bookmarkEnd",- "w:sectPr",- "w:proofErr",- "w:lastRenderedPageBreak",- "w:commentRangeStart",- "w:commentRangeEnd",- "w:del",- "w:footnoteRef",- "w:endnoteRef",- "w:pPr",- "w:rPr",- "w:tblPr",- "w:tblGrid",- "w:trPr",- "w:tcPr",- ])-- def text(element):- return _success(documents.Text(_inner_text(element)))-- def run(element):- properties = element.find_child_or_null("w:rPr")- vertical_alignment = properties \- .find_child_or_null("w:vertAlign") \- .attributes.get("w:val")- font = properties.find_child_or_null("w:rFonts").attributes.get("w:ascii")-- font_size_string = properties.find_child_or_null("w:sz").attributes.get("w:val")- if _is_int(font_size_string):- # w:sz gives the font size in half points, so halve the value to get the size in points- font_size = int(font_size_string) / 2- else:- font_size = None-- is_bold = read_boolean_element(properties.find_child("w:b"))- is_italic = read_boolean_element(properties.find_child("w:i"))- is_underline = read_underline_element(properties.find_child("w:u"))- is_strikethrough = read_boolean_element(properties.find_child("w:strike"))- is_all_caps = read_boolean_element(properties.find_child("w:caps"))- is_small_caps = read_boolean_element(properties.find_child("w:smallCaps"))- highlight = read_highlight_value(properties.find_child_or_null("w:highlight").attributes.get("w:val"))-- def add_complex_field_hyperlink(children):- hyperlink_kwargs = current_hyperlink_kwargs()- if hyperlink_kwargs is None:- return children- else:- return [documents.hyperlink(children=children, **hyperlink_kwargs)]-- return _ReadResult.map_results(- _read_run_style(properties),- _read_xml_elements(element.children).map(add_complex_field_hyperlink),- lambda style, children: documents.run(- children=children,- style_id=style[0],- style_name=style[1],- is_bold=is_bold,- is_italic=is_italic,- is_underline=is_underline,- is_strikethrough=is_strikethrough,- is_all_caps=is_all_caps,- is_small_caps=is_small_caps,- vertical_alignment=vertical_alignment,- font=font,- font_size=font_size,- highlight=highlight,- ))-- def _read_run_style(properties):- return _read_style(properties, "w:rStyle", "Run", styles.find_character_style_by_id)-- def read_boolean_element(element):- if element is None:- return False- else:- return read_boolean_attribute_value(element.attributes.get("w:val"))-- def read_boolean_attribute_value(value):- return value not in ["false", "0"]-- def read_underline_element(element):- return element and element.attributes.get("w:val") not in [None, "false", "0", "none"]-- def read_highlight_value(value):- if not value or value == "none":- return None- else:- return value-- def paragraph(element):- properties = element.find_child_or_null("w:pPr")-- is_deleted = properties.find_child_or_null("w:rPr").find_child("w:del")-- if is_deleted is not None:- for child in element.children:- deleted_paragraph_contents.append(child)- return _empty_result-- else:- alignment = properties.find_child_or_null("w:jc").attributes.get("w:val")- indent = _read_paragraph_indent(properties.find_child_or_null("w:ind"))-- children_xml = element.children- if deleted_paragraph_contents:- children_xml = deleted_paragraph_contents + children_xml- del deleted_paragraph_contents[:]-- return _ReadResult.map_results(- _read_paragraph_style(properties),- _read_xml_elements(children_xml),- lambda style, children: documents.paragraph(- children=children,- style_id=style[0],- style_name=style[1],- numbering=_read_numbering_properties(- paragraph_style_id=style[0],- element=properties.find_child_or_null("w:numPr"),- ),- alignment=alignment,- indent=indent,- )).append_extra()-- def _read_paragraph_style(properties):- return _read_style(properties, "w:pStyle", "Paragraph", styles.find_paragraph_style_by_id)-- def current_hyperlink_kwargs():- for complex_field in reversed(complex_field_stack):- if isinstance(complex_field, complex_fields.Hyperlink):- return complex_field.kwargs-- return None-- def read_fld_char(element):- fld_char_type = element.attributes.get("w:fldCharType")- if fld_char_type == "begin":- complex_field_stack.append(complex_fields.begin(fld_char=element))- del current_instr_text[:]-- elif fld_char_type == "end":- complex_field = complex_field_stack.pop()- if isinstance(complex_field, complex_fields.Begin):- complex_field = parse_current_instr_text(complex_field)-- if isinstance(complex_field, complex_fields.Checkbox):- return _success(documents.checkbox(checked=complex_field.checked))-- elif fld_char_type == "separate":- complex_field_separate = complex_field_stack.pop()- complex_field = parse_current_instr_text(complex_field_separate)- complex_field_stack.append(complex_field)-- return _empty_result-- def parse_current_instr_text(complex_field):- instr_text = "".join(current_instr_text)-- if isinstance(complex_field, complex_fields.Begin):- fld_char = complex_field.fld_char- else:- fld_char = null_xml_element-- return parse_instr_text(instr_text, fld_char=fld_char)-- def parse_instr_text(instr_text, *, fld_char):- external_link_result = re.match(r'\s*HYPERLINK "(.*)"', instr_text)- if external_link_result is not None:- return complex_fields.hyperlink(dict(href=external_link_result.group(1)))-- internal_link_result = re.match(r'\s*HYPERLINK\s+\\l\s+"(.*)"', instr_text)- if internal_link_result is not None:- return complex_fields.hyperlink(dict(anchor=internal_link_result.group(1)))-- checkbox_result = re.match(r'\s*FORMCHECKBOX\s*', instr_text)- if checkbox_result is not None:- checkbox_element = fld_char \- .find_child_or_null("w:ffData") \- .find_child_or_null("w:checkBox")- checked_element = checkbox_element.find_child("w:checked")-- if checked_element is None:- checked = read_boolean_element(checkbox_element.find_child("w:default"))- else:- checked = read_boolean_element(checked_element)-- return complex_fields.checkbox(checked=checked)-- return None-- def read_instr_text(element):- current_instr_text.append(_inner_text(element))- return _empty_result-- def _read_style(properties, style_tag_name, style_type, find_style_by_id):- messages = []- style_id = properties \- .find_child_or_null(style_tag_name) \- .attributes.get("w:val")-- if style_id is None:- style_name = None- else:- style = find_style_by_id(style_id)- if style is None:- style_name = None- messages.append(_undefined_style_warning(style_type, style_id))- else:- style_name = style.name-- return _ReadResult([style_id, style_name], [], messages)-- def _undefined_style_warning(style_type, style_id):- return results.warning("{0} style with ID {1} was referenced but not defined in the document".format(style_type, style_id))-- def _read_numbering_properties(paragraph_style_id, element):- num_id = element.find_child_or_null("w:numId").attributes.get("w:val")- level_index = element.find_child_or_null("w:ilvl").attributes.get("w:val")- if num_id is not None and level_index is not None:- return numbering.find_level(num_id, level_index)-- if paragraph_style_id is not None:- level = numbering.find_level_by_paragraph_style_id(paragraph_style_id)- if level is not None:- return level-- # Some malformed documents define numbering levels without an index, and- # reference the numbering using a w:numPr element without a w:ilvl child.- # To handle such cases, we assume a level of 0 as a fallback.- if num_id is not None:- return numbering.find_level(num_id, "0")-- return None-- def _read_paragraph_indent(element):- attributes = element.attributes- return documents.paragraph_indent(- start=attributes.get("w:start") or attributes.get("w:left"),- end=attributes.get("w:end") or attributes.get("w:right"),- first_line=attributes.get("w:firstLine"),- hanging=attributes.get("w:hanging"),- )-- def tab(element):- return _success(documents.tab())--- def no_break_hyphen(element):- return _success(documents.text(unichr(0x2011)))--- def soft_hyphen(element):- return _success(documents.text(u"\u00ad"))-- def symbol(element):- # See 17.3.3.30 sym (Symbol Character) of ECMA-376 4th edition Part 1- font = element.attributes.get("w:font")- char = element.attributes.get("w:char")-- unicode_code_point = dingbats.get((font, int(char, 16)))-- if unicode_code_point is None and re.match("^F0..", char):- unicode_code_point = dingbats.get((font, int(char[2:], 16)))-- if unicode_code_point is None:- warning = results.warning("A w:sym element with an unsupported character was ignored: char {0} in font {1}".format(- char,- font,- ))- return _empty_result_with_message(warning)- else:- return _success(documents.text(unichr(unicode_code_point)))--- def table(element):- properties = element.find_child_or_null("w:tblPr")- return _ReadResult.map_results(- read_table_style(properties),- _read_xml_elements(element.children)- .flat_map(calculate_row_spans),-- lambda style, children: documents.table(- children=children,- style_id=style[0],- style_name=style[1],- ),- )--- def read_table_style(properties):- return _read_style(properties, "w:tblStyle", "Table", styles.find_table_style_by_id)--- def table_row(element):- properties = element.find_child_or_null("w:trPr")-- # See 17.13.5.12 del (Deleted Table Row) of ECMA-376 4th edition Part 1- is_deleted = bool(properties.find_child("w:del"))- if is_deleted:- return _empty_result-- is_header = bool(properties.find_child("w:tblHeader"))- return _read_xml_elements(element.children) \- .map(lambda children: documents.table_row(- children=children,- is_header=is_header,- ))--- def table_cell(element):- properties = element.find_child_or_null("w:tcPr")- gridspan = properties \- .find_child_or_null("w:gridSpan") \- .attributes.get("w:val")-- if gridspan is None:- colspan = 1- else:- colspan = int(gridspan)-- return _read_xml_elements(element.children) \- .map(lambda children: documents.table_cell_unmerged(- children=children,- colspan=colspan,- rowspan=1,- vmerge=read_vmerge(properties),- ))-- def read_vmerge(properties):- vmerge_element = properties.find_child("w:vMerge")- if vmerge_element is None:- return False- else:- val = vmerge_element.attributes.get("w:val")- return val == "continue" or not val--- def calculate_row_spans(rows):- unexpected_non_rows = any(- not isinstance(row, documents.TableRow)- for row in rows- )- if unexpected_non_rows:- rows = remove_unmerged_table_cells(rows)- return _elements_result_with_messages(rows, [results.warning(- "unexpected non-row element in table, cell merging may be incorrect"- )])-- unexpected_non_cells = any(- not isinstance(cell, documents.TableCellUnmerged)- for row in rows- for cell in row.children- )- if unexpected_non_cells:- rows = remove_unmerged_table_cells(rows)- return _elements_result_with_messages(rows, [results.warning(- "unexpected non-cell element in table row, cell merging may be incorrect"- )])-- columns = {}- for row in rows:- cell_index = 0- for cell in row.children:- if cell.vmerge and cell_index in columns:- columns[cell_index].rowspan += 1- else:- columns[cell_index] = cell- cell.vmerge = False- cell_index += cell.colspan-- for row in rows:- row.children = [- documents.table_cell(- children=cell.children,- colspan=cell.colspan,- rowspan=cell.rowspan,- )- for cell in row.children- if not cell.vmerge- ]-- return _success(rows)--- def remove_unmerged_table_cells(rows):- return list(map(- transforms.element_of_type(- documents.TableCellUnmerged,- lambda cell: documents.table_cell(- children=cell.children,- colspan=cell.colspan,- rowspan=cell.rowspan,- ),- ),- rows,- ))--- def read_child_elements(element):- return _read_xml_elements(element.children)--- def pict(element):- return read_child_elements(element).to_extra()--- def hyperlink(element):- relationship_id = element.attributes.get("r:id")- anchor = element.attributes.get("w:anchor")- target_frame = element.attributes.get("w:tgtFrame") or None- children_result = _read_xml_elements(element.children)-- def create(**kwargs):- return children_result.map(lambda children: documents.hyperlink(- children=children,- target_frame=target_frame,- **kwargs- ))-- if relationship_id is not None:- href = relationships.find_target_by_relationship_id(relationship_id)- if anchor is not None:- href = replace_fragment(href, anchor)-- return create(href=href)- elif anchor is not None:- return create(anchor=anchor)- else:- return children_result--- def bookmark_start(element):- name = element.attributes.get("w:name")- if name == "_GoBack":- return _empty_result- else:- return _success(documents.bookmark(name))--- def break_(element):- break_type = element.attributes.get("w:type")-- if not break_type or break_type == "textWrapping":- return _success(documents.line_break)- elif break_type == "page":- return _success(documents.page_break)- elif break_type == "column":- return _success(documents.column_break)- else:- warning = results.warning("Unsupported break type: {0}".format(break_type))- return _empty_result_with_message(warning)--- def inline(element):- properties_element = element.find_child_or_null("wp:docPr")-- properties = properties_element.attributes- if properties.get("descr", "").strip():- alt_text = properties.get("descr")- else:- alt_text = properties.get("title")-- hlink_click_element = properties_element.find_child_or_null("a:hlinkClick")- hyperlink_relationship_id = hlink_click_element.attributes.get("r:id")- if hyperlink_relationship_id:- href = relationships.find_target_by_relationship_id(hyperlink_relationship_id)- else:- href = None-- blips = element.find_children("a:graphic") \- .find_children("a:graphicData") \- .find_children("pic:pic") \- .find_children("pic:blipFill") \- .find_children("a:blip")- return _read_blips(blips, alt_text=alt_text, href=href)-- def _read_blips(blips, alt_text, href):- return _ReadResult.concat(lists.map(lambda blip: _read_blip(blip, alt_text=alt_text, href=href), blips))-- def _read_blip(element, alt_text, href):- blip_image = _find_blip_image(element)-- if blip_image is None:- warning = results.warning("Could not find image file for a:blip element")- return _empty_result_with_message(warning)-- result = _read_image(blip_image, alt_text)- if href is None:- return result- else:- return result.map(lambda image_elements: documents.hyperlink(- image_elements,- href=href,- ))-- def _read_image(image_file, alt_text):- image_path, open_image = image_file- content_type = content_types.find_content_type(image_path)- image = documents.image(alt_text=alt_text, content_type=content_type, open=open_image)-- if content_type in ["image/png", "image/gif", "image/jpeg", "image/svg+xml", "image/tiff"]:- messages = []- else:- messages = [results.warning("Image of type {0} is unlikely to display in web browsers".format(content_type))]-- return _element_result_with_messages(image, messages)-- def _find_blip_image(element):- embed_relationship_id = element.attributes.get("r:embed")- link_relationship_id = element.attributes.get("r:link")- if embed_relationship_id is not None:- return _find_embedded_image(embed_relationship_id)- elif link_relationship_id is not None:- return _find_linked_image(link_relationship_id)- else:- return None-- def _find_embedded_image(relationship_id):- target = relationships.find_target_by_relationship_id(relationship_id)- image_path = uri_to_zip_entry_name("word", target)-- def open_image():- image_file = docx_file.open(image_path)- if hasattr(image_file, "__exit__"):- return image_file- else:- return contextlib.closing(image_file)-- return image_path, open_image--- def _find_linked_image(relationship_id):- image_path = relationships.find_target_by_relationship_id(relationship_id)-- def open_image():- return files.open(image_path)-- return image_path, open_image-- def read_imagedata(element):- relationship_id = element.attributes.get("r:id")- if relationship_id is None:- warning = results.warning("A v:imagedata element without a relationship ID was ignored")- return _empty_result_with_message(warning)- else:- title = element.attributes.get("o:title")- return _read_image(_find_embedded_image(relationship_id), title)-- def note_reference_reader(note_type):- def note_reference(element):- return _success(documents.note_reference(note_type, element.attributes["w:id"]))-- return note_reference-- def read_comment_reference(element):- return _success(documents.comment_reference(element.attributes["w:id"]))-- def alternate_content(element):- return read_child_elements(element.find_child_or_null("mc:Fallback"))-- def read_sdt(element):- content_result = read_child_elements(element.find_child_or_null("w:sdtContent"))-- def handle_content(content):- # From the WordML standard: https://learn.microsoft.com/en-us/openspecs/office_standards/ms-docx/3350cb64-931f-41f7-8824-f18b2568ce66- #- # > A CT_SdtCheckbox element that specifies that the parent- # > structured document tag is a checkbox when displayed in the- # > document. The parent structured document tag contents MUST- # > contain a single character and optionally an additional- # > character in a deleted run.- checkbox = element.find_child_or_null("w:sdtPr").find_child("wordml:checkbox")-- if checkbox is None:- return content-- checked_element = checkbox.find_child("wordml:checked")- is_checked = (- checked_element is not None and- read_boolean_attribute_value(checked_element.attributes.get("wordml:val"))- )- document_checkbox = documents.checkbox(checked=is_checked)-- has_checkbox = False-- def transform_text(text):- nonlocal has_checkbox- if len(text.value) > 0 and not has_checkbox:- has_checkbox = True- return document_checkbox- else:- return text-- replaced_content = list(map(- transforms.element_of_type(documents.Text, transform_text),- content,- ))-- if has_checkbox:- return replaced_content- else:- return document_checkbox-- return content_result.map(handle_content)-- handlers = {- "w:t": text,- "w:r": run,- "w:p": paragraph,- "w:fldChar": read_fld_char,- "w:instrText": read_instr_text,- "w:tab": tab,- "w:noBreakHyphen": no_break_hyphen,- "w:softHyphen": soft_hyphen,- "w:sym": symbol,- "w:tbl": table,- "w:tr": table_row,- "w:tc": table_cell,- "w:ins": read_child_elements,- "w:object": read_child_elements,- "w:smartTag": read_child_elements,- "w:drawing": read_child_elements,- "v:group": read_child_elements,- "v:rect": read_child_elements,- "v:roundrect": read_child_elements,- "v:shape": read_child_elements,- "v:textbox": read_child_elements,- "w:txbxContent": read_child_elements,- "w:pict": pict,- "w:hyperlink": hyperlink,- "w:bookmarkStart": bookmark_start,- "w:br": break_,- "wp:inline": inline,- "wp:anchor": inline,- "v:imagedata": read_imagedata,- "w:footnoteReference": note_reference_reader("footnote"),- "w:endnoteReference": note_reference_reader("endnote"),- "w:commentReference": read_comment_reference,- "mc:AlternateContent": alternate_content,- "w:sdt": read_sdt- }-- def read(element):- handler = handlers.get(element.name)- if handler is None:- if element.name not in _ignored_elements:- warning = results.warning("An unrecognised element was ignored: {0}".format(element.name))- return _empty_result_with_message(warning)- else:- return _empty_result- else:- return handler(element)--- def _read_xml_elements(nodes):- elements = filter(lambda node: isinstance(node, XmlElement), nodes)- return _ReadResult.concat(lists.map(read, elements))-- return _read_xml_elements---def _inner_text(node):- if node.node_type == node_types.text:- return node.value- else:- return "".join(_inner_text(child) for child in node.children)----class _ReadResult(object):- @staticmethod- def concat(results):- return _ReadResult(- lists.flat_map(lambda result: result.elements, results),- lists.flat_map(lambda result: result.extra, results),- lists.flat_map(lambda result: result.messages, results))--- @staticmethod- def map_results(first, second, func):- return _ReadResult(- [func(first.elements, second.elements)],- first.extra + second.extra,- first.messages + second.messages)-- def __init__(self, elements, extra, messages):- self.elements = elements- self.extra = extra- self.messages = messages-- def map(self, func):- elements = func(self.elements)- if not isinstance(elements, list):- elements = [elements]- return _ReadResult(- elements,- self.extra,- self.messages)-- def flat_map(self, func):- result = func(self.elements)- return _ReadResult(- result.elements,- self.extra + result.extra,- self.messages + result.messages)--- def to_extra(self):- return _ReadResult([], _concat(self.extra, self.elements), self.messages)-- def append_extra(self):- return _ReadResult(_concat(self.elements, self.extra), [], self.messages)--def _success(elements):- if not isinstance(elements, list):- elements = [elements]- return _ReadResult(elements, [], [])--def _element_result_with_messages(element, messages):- return _elements_result_with_messages([element], messages)--def _elements_result_with_messages(elements, messages):- return _ReadResult(elements, [], messages)--_empty_result = _ReadResult([], [], [])--def _empty_result_with_message(message):- return _ReadResult([], [], [message])--def _concat(*values):- result = []- for value in values:- for element in value:- result.append(element)- return result---def _is_int(value):- if value is None:- return False-- try:- int(value)- except ValueError:- return False-- return Truediff --git a/mineru/model/utils/docx/mammoth/complex_fields.py b/mineru/model/utils/docx/mammoth/complex_fields.pydeleted file mode 100644index ac641812..00000000--- a/mineru/model/utils/docx/mammoth/complex_fields.py+++ /dev/null@@ -1,29 +0,0 @@-class unknown(object):- pass---class Begin:- def __init__(self, *, fld_char):- self.fld_char = fld_char---def begin(*, fld_char):- return Begin(fld_char=fld_char)---class Hyperlink(object):- def __init__(self, kwargs):- self.kwargs = kwargs---def hyperlink(kwargs):- return Hyperlink(kwargs=kwargs)---class Checkbox:- def __init__(self, *, checked):- self.checked = checked---def checkbox(*, checked):- return Checkbox(checked=checked)diff --git a/mineru/model/utils/docx/mammoth/conversion.py b/mineru/model/utils/docx/mammoth/conversion.pydeleted file mode 100644index eb73945c..00000000--- a/mineru/model/utils/docx/mammoth/conversion.py+++ /dev/null@@ -1,384 +0,0 @@-# coding=utf-8--from __future__ import unicode_literals--from functools import partial--import cobble--from . import documents, results, html_paths, html-from . import writers-from .lists import find_index---def convert_document_element_to_html(element,- style_map=None,- convert_image=None,- id_prefix=None,- output_format=None,- ignore_empty_paragraphs=True):- if style_map is None:- style_map = []-- if id_prefix is None:- id_prefix = ""-- if isinstance(element, documents.Document):- comments = dict(- (comment.comment_id, comment)- for comment in element.comments- )- else:- comments = {}-- messages = []- converter = _DocumentConverter(- messages=messages,- style_map=style_map,- convert_image=convert_image,- id_prefix=id_prefix,- ignore_empty_paragraphs=ignore_empty_paragraphs,- note_references=[],- comments=comments,- )- context = _ConversionContext(is_table_header=False)- nodes = converter.visit(element, context)-- writer = writers.writer(output_format)- html.write(writer, html.collapse(html.strip_empty(nodes)))- return results.Result(writer.as_string(), messages)---class _ConversionContext(object):- is_table_header = cobble.field()-- def copy(self, **kwargs):- return cobble.copy(self, **kwargs)---class _DocumentConverter(documents.element_visitor(args=1)):- def __init__(self, messages, style_map, convert_image, id_prefix, ignore_empty_paragraphs, note_references,- comments):- self._messages = messages- self._style_map = style_map- self._id_prefix = id_prefix- self._ignore_empty_paragraphs = ignore_empty_paragraphs- self._note_references = note_references- self._referenced_comments = []- self._convert_image = convert_image- self._comments = comments-- def visit_document(self, document, context):- nodes = self._visit_all(document.children, context)- notes = [- document.notes.resolve(reference)- for reference in self._note_references- ]- notes_list = html.element("ol", {}, self._visit_all(notes, context))- comments = html.element("dl", {}, [- html_node- for referenced_comment in self._referenced_comments- for html_node in self.visit_comment(referenced_comment, context)- ])- return nodes + [notes_list, comments]-- def visit_paragraph(self, paragraph, context):- def children():- content = self._visit_all(paragraph.children, context)- if self._ignore_empty_paragraphs:- return content- else:- return [html.force_write] + content-- html_path = self._find_html_path_for_paragraph(paragraph)- return html_path.wrap(children)-- def visit_run(self, run, context):- nodes = lambda: self._visit_all(run.children, context)- paths = []- if run.highlight is not None:- style = self._find_style(Highlight(color=run.highlight), "highlight")- if style is not None:- paths.append(style.html_path)- if run.is_small_caps:- paths.append(self._find_style_for_run_property("small_caps"))- if run.is_all_caps:- paths.append(self._find_style_for_run_property("all_caps"))- if run.is_strikethrough:- paths.append(self._find_style_for_run_property("strikethrough", default="s"))- if run.is_underline:- paths.append(self._find_style_for_run_property("underline"))- if run.vertical_alignment == documents.VerticalAlignment.subscript:- paths.append(html_paths.element(["sub"], fresh=False))- if run.vertical_alignment == documents.VerticalAlignment.superscript:- paths.append(html_paths.element(["sup"], fresh=False))- if run.is_italic:- paths.append(self._find_style_for_run_property("italic", default="em"))- if run.is_bold:- paths.append(self._find_style_for_run_property("bold", default="strong"))- paths.append(self._find_html_path_for_run(run))-- for path in paths:- nodes = partial(path.wrap, nodes)-- return nodes()-- def _find_style_for_run_property(self, element_type, default=None):- style = self._find_style(None, element_type)- if style is not None:- return style.html_path- elif default is not None:- return html_paths.element(default, fresh=False)- else:- return html_paths.empty-- def visit_image(self, image, context):- return []-- def visit_text(self, text, context):- return [html.text(text.value)]-- def visit_hyperlink(self, hyperlink, context):- if hyperlink.anchor is None:- href = hyperlink.href- else:- href = "#{0}".format(self._html_id(hyperlink.anchor))-- attributes = {"href": href}- if hyperlink.target_frame is not None:- attributes["target"] = hyperlink.target_frame-- nodes = self._visit_all(hyperlink.children, context)- return [html.collapsible_element("a", attributes, nodes)]-- def visit_checkbox(self, checkbox, context):- attributes = {"type": "checkbox"}-- if checkbox.checked:- attributes["checked"] = "checked"-- return [html.element("input", attributes)]-- def visit_bookmark(self, bookmark, context):- element = html.collapsible_element(- "a",- {"id": self._html_id(bookmark.name)},- [html.force_write])- return [element]-- def visit_tab(self, tab, context):- return [html.text("\t")]-- _default_table_path = html_paths.path([html_paths.element(["table"], fresh=True)])-- def visit_table(self, table, context):- return self._find_html_path(table, "table", self._default_table_path) \- .wrap(lambda: self._convert_table_children(table, context))-- def _convert_table_children(self, table, context):- body_index = find_index(- lambda child: not isinstance(child, documents.TableRow) or not child.is_header,- table.children,- )- if body_index is None:- body_index = len(table.children)-- if body_index == 0:- children = self._visit_all(table.children, context.copy(is_table_header=False))- else:- head_rows = self._visit_all(table.children[:body_index], context.copy(is_table_header=True))- body_rows = self._visit_all(table.children[body_index:], context.copy(is_table_header=False))- children = [- html.element("thead", {}, head_rows),- html.element("tbody", {}, body_rows),- ]-- return [html.force_write] + children-- def visit_table_row(self, table_row, context):- return [html.element("tr", {}, [html.force_write] + self._visit_all(table_row.children, context))]-- def visit_table_cell(self, table_cell, context):- if context.is_table_header:- tag_name = "th"- else:- tag_name = "td"- attributes = {}- if table_cell.colspan != 1:- attributes["colspan"] = str(table_cell.colspan)- if table_cell.rowspan != 1:- attributes["rowspan"] = str(table_cell.rowspan)- nodes = [html.force_write] + self._visit_all(table_cell.children, context)- return [- html.element(tag_name, attributes, nodes)- ]-- def visit_break(self, break_, context):- return self._find_html_path_for_break(break_).wrap(lambda: [])-- def _find_html_path_for_break(self, break_):- style = self._find_style(break_, "break")- if style is not None:- return style.html_path- elif break_.break_type == "line":- return html_paths.path([html_paths.element("br", fresh=True)])- else:- return html_paths.empty-- def visit_note_reference(self, note_reference, context):- self._note_references.append(note_reference)- note_number = len(self._note_references)- return [- html.element("sup", {}, [- html.element("a", {- "href": "#" + self._note_html_id(note_reference),- "id": self._note_ref_html_id(note_reference),- }, [html.text("[{0}]".format(note_number))])- ])- ]-- def visit_note(self, note, context):- note_body = self._visit_all(note.body, context) + [- html.collapsible_element("p", {}, [- html.text(" "),- html.element("a", {"href": "#" + self._note_ref_html_id(note)}, [- html.text(_up_arrow)- ]),- ])- ]- return [- html.element("li", {"id": self._note_html_id(note)}, note_body)- ]-- def visit_comment_reference(self, reference, context):- def nodes():- comment = self._comments[reference.comment_id]- count = len(self._referenced_comments) + 1- label = "[{0}{1}]".format(_comment_author_label(comment), count)- self._referenced_comments.append((label, comment))- return [- # TODO: remove duplication with note references- html.element("a", {- "href": "#" + self._referent_html_id("comment", reference.comment_id),- "id": self._reference_html_id("comment", reference.comment_id),- }, [html.text(label)])- ]-- html_path = self._find_html_path(- None,- "comment_reference",- default=html_paths.ignore,- )-- return html_path.wrap(nodes)-- def visit_comment(self, referenced_comment, context):- label, comment = referenced_comment- # TODO remove duplication with notes- body = self._visit_all(comment.body, context) + [- html.collapsible_element("p", {}, [- html.text(" "),- html.element("a", {"href": "#" + self._reference_html_id("comment", comment.comment_id)}, [- html.text(_up_arrow)- ]),- ])- ]- return [- html.element(- "dt",- {"id": self._referent_html_id("comment", comment.comment_id)},- [html.text("Comment {0}".format(label))],- ),- html.element("dd", {}, body),- ]-- def _visit_all(self, elements, context):- return [- html_node- for element in elements- for html_node in self.visit(element, context)- ]-- def _find_html_path_for_paragraph(self, paragraph):- default = html_paths.path([html_paths.element("p", fresh=True)])- return self._find_html_path(paragraph, "paragraph", default, warn_unrecognised=True)-- def _find_html_path_for_run(self, run):- return self._find_html_path(run, "run", default=html_paths.empty, warn_unrecognised=True)-- def _find_html_path(self, element, element_type, default, warn_unrecognised=False):- style = self._find_style(element, element_type)- if style is not None:- return style.html_path-- if warn_unrecognised and getattr(element, "style_id", None) is not None:- self._messages.append(results.warning(- "Unrecognised {0} style: {1} (Style ID: {2})".format(- element_type, element.style_name, element.style_id)- ))-- return default-- def _find_style(self, element, element_type):- for style in self._style_map:- document_matcher = style.document_matcher- if _document_matcher_matches(document_matcher, element, element_type):- return style-- def _note_html_id(self, note):- return self._referent_html_id(note.note_type, note.note_id)-- def _note_ref_html_id(self, note):- return self._reference_html_id(note.note_type, note.note_id)-- def _referent_html_id(self, reference_type, reference_id):- return self._html_id("{0}-{1}".format(reference_type, reference_id))-- def _reference_html_id(self, reference_type, reference_id):- return self._html_id("{0}-ref-{1}".format(reference_type, reference_id))-- def _html_id(self, suffix):- return "{0}{1}".format(self._id_prefix, suffix)---class Highlight:- color = cobble.field()---def _document_matcher_matches(matcher, element, element_type):- if matcher.element_type in ["underline", "strikethrough", "all_caps", "small_caps", "bold", "italic",- "comment_reference"]:- return matcher.element_type == element_type- elif matcher.element_type == "highlight":- return (- matcher.element_type == element_type and- (matcher.color is None or matcher.color == element.color)- )- elif matcher.element_type == "break":- return (- matcher.element_type == element_type and- matcher.break_type == element.break_type- )- else: # matcher.element_type in ["paragraph", "run"]:- return (- matcher.element_type == element_type and (- matcher.style_id is None or- matcher.style_id == element.style_id- ) and (- matcher.style_name is None or- element.style_name is not None and (matcher.style_name.matches(element.style_name))- ) and (- element_type != "paragraph" or- matcher.numbering is None or- matcher.numbering == element.numbering- )- )---def _comment_author_label(comment):- return comment.author_initials or ""---_up_arrow = "↑"diff --git a/mineru/model/utils/docx/mammoth/dingbats.py b/mineru/model/utils/docx/mammoth/dingbats.pydeleted file mode 100644index 3edef51b..00000000--- a/mineru/model/utils/docx/mammoth/dingbats.py+++ /dev/null@@ -1,1065 +0,0 @@-# Generated by https://github.com/mwilliamson/dingbat-to-unicode--dingbats = {- ('Symbol', 32): 32,- ('Symbol', 33): 33,- ('Symbol', 34): 8704,- ('Symbol', 35): 35,- ('Symbol', 36): 8707,- ('Symbol', 37): 37,- ('Symbol', 38): 38,- ('Symbol', 39): 8717,- ('Symbol', 40): 40,- ('Symbol', 41): 41,- ('Symbol', 42): 42,- ('Symbol', 43): 43,- ('Symbol', 44): 44,- ('Symbol', 45): 8722,- ('Symbol', 46): 46,- ('Symbol', 47): 47,- ('Symbol', 48): 48,- ('Symbol', 49): 49,- ('Symbol', 50): 50,- ('Symbol', 51): 51,- ('Symbol', 52): 52,- ('Symbol', 53): 53,- ('Symbol', 54): 54,- ('Symbol', 55): 55,- ('Symbol', 56): 56,- ('Symbol', 57): 57,- ('Symbol', 58): 58,- ('Symbol', 59): 59,- ('Symbol', 60): 60,- ('Symbol', 61): 61,- ('Symbol', 62): 62,- ('Symbol', 63): 63,- ('Symbol', 64): 8773,- ('Symbol', 65): 913,- ('Symbol', 66): 914,- ('Symbol', 67): 935,- ('Symbol', 68): 916,- ('Symbol', 69): 917,- ('Symbol', 70): 934,- ('Symbol', 71): 915,- ('Symbol', 72): 919,- ('Symbol', 73): 921,- ('Symbol', 74): 977,- ('Symbol', 75): 922,- ('Symbol', 76): 923,- ('Symbol', 77): 924,- ('Symbol', 78): 925,- ('Symbol', 79): 927,- ('Symbol', 80): 928,- ('Symbol', 81): 920,- ('Symbol', 82): 929,- ('Symbol', 83): 931,- ('Symbol', 84): 932,- ('Symbol', 85): 933,- ('Symbol', 86): 962,- ('Symbol', 87): 937,- ('Symbol', 88): 926,- ('Symbol', 89): 936,- ('Symbol', 90): 918,- ('Symbol', 91): 91,- ('Symbol', 92): 8756,- ('Symbol', 93): 93,- ('Symbol', 94): 8869,- ('Symbol', 95): 95,- ('Symbol', 96): 8254,- ('Symbol', 97): 945,- ('Symbol', 98): 946,- ('Symbol', 99): 967,- ('Symbol', 100): 948,- ('Symbol', 101): 949,- ('Symbol', 102): 966,- ('Symbol', 103): 947,- ('Symbol', 104): 951,- ('Symbol', 105): 953,- ('Symbol', 106): 981,- ('Symbol', 107): 954,- ('Symbol', 108): 955,- ('Symbol', 109): 956,- ('Symbol', 110): 957,- ('Symbol', 111): 959,- ('Symbol', 112): 960,- ('Symbol', 113): 952,- ('Symbol', 114): 961,- ('Symbol', 115): 963,- ('Symbol', 116): 964,- ('Symbol', 117): 965,- ('Symbol', 118): 982,- ('Symbol', 119): 969,- ('Symbol', 120): 958,- ('Symbol', 121): 968,- ('Symbol', 122): 950,- ('Symbol', 123): 123,- ('Symbol', 124): 124,- ('Symbol', 125): 125,- ('Symbol', 126): 126,- ('Symbol', 160): 8364,- ('Symbol', 161): 978,- ('Symbol', 162): 8242,- ('Symbol', 163): 8804,- ('Symbol', 164): 8260,- ('Symbol', 165): 8734,- ('Symbol', 166): 402,- ('Symbol', 167): 9827,- ('Symbol', 168): 9830,- ('Symbol', 169): 9829,- ('Symbol', 170): 9824,- ('Symbol', 171): 8596,- ('Symbol', 172): 8592,- ('Symbol', 173): 8593,- ('Symbol', 174): 8594,- ('Symbol', 175): 8595,- ('Symbol', 176): 176,- ('Symbol', 177): 177,- ('Symbol', 178): 8243,- ('Symbol', 179): 8805,- ('Symbol', 180): 215,- ('Symbol', 181): 8733,- ('Symbol', 182): 8706,- ('Symbol', 183): 8226,- ('Symbol', 184): 247,- ('Symbol', 185): 8800,- ('Symbol', 186): 8801,- ('Symbol', 187): 8776,- ('Symbol', 188): 8230,- ('Symbol', 189): 9168,- ('Symbol', 190): 9135,- ('Symbol', 191): 8629,- ('Symbol', 192): 8501,- ('Symbol', 193): 8465,- ('Symbol', 194): 8476,- ('Symbol', 195): 8472,- ('Symbol', 196): 8855,- ('Symbol', 197): 8853,- ('Symbol', 198): 8709,- ('Symbol', 199): 8745,- ('Symbol', 200): 8746,- ('Symbol', 201): 8835,- ('Symbol', 202): 8839,- ('Symbol', 203): 8836,- ('Symbol', 204): 8834,- ('Symbol', 205): 8838,- ('Symbol', 206): 8712,- ('Symbol', 207): 8713,- ('Symbol', 208): 8736,- ('Symbol', 209): 8711,- ('Symbol', 210): 174,- ('Symbol', 211): 169,- ('Symbol', 212): 8482,- ('Symbol', 213): 8719,- ('Symbol', 214): 8730,- ('Symbol', 215): 8901,- ('Symbol', 216): 172,- ('Symbol', 217): 8743,- ('Symbol', 218): 8744,- ('Symbol', 219): 8660,- ('Symbol', 220): 8656,- ('Symbol', 221): 8657,- ('Symbol', 222): 8658,- ('Symbol', 223): 8659,- ('Symbol', 224): 9674,- ('Symbol', 225): 12296,- ('Symbol', 226): 174,- ('Symbol', 227): 169,- ('Symbol', 228): 8482,- ('Symbol', 229): 8721,- ('Symbol', 230): 9115,- ('Symbol', 231): 9116,- ('Symbol', 232): 9117,- ('Symbol', 233): 9121,- ('Symbol', 234): 9122,- ('Symbol', 235): 9123,- ('Symbol', 236): 9127,- ('Symbol', 237): 9128,- ('Symbol', 238): 9129,- ('Symbol', 239): 9130,- ('Symbol', 240): 63743,- ('Symbol', 241): 12297,- ('Symbol', 242): 8747,- ('Symbol', 243): 8992,- ('Symbol', 244): 9134,- ('Symbol', 245): 8993,- ('Symbol', 246): 9118,- ('Symbol', 247): 9119,- ('Symbol', 248): 9120,- ('Symbol', 249): 9124,- ('Symbol', 250): 9125,- ('Symbol', 251): 9126,- ('Symbol', 252): 9131,- ('Symbol', 253): 9132,- ('Symbol', 254): 9133,- ('Webdings', 32): 32,- ('Webdings', 33): 128375,- ('Webdings', 34): 128376,- ('Webdings', 35): 128370,- ('Webdings', 36): 128374,- ('Webdings', 37): 127942,- ('Webdings', 38): 127894,- ('Webdings', 39): 128391,- ('Webdings', 40): 128488,- ('Webdings', 41): 128489,- ('Webdings', 42): 128496,- ('Webdings', 43): 128497,- ('Webdings', 44): 127798,- ('Webdings', 45): 127895,- ('Webdings', 46): 128638,- ('Webdings', 47): 128636,- ('Webdings', 48): 128469,- ('Webdings', 49): 128470,- ('Webdings', 50): 128471,- ('Webdings', 51): 9204,- ('Webdings', 52): 9205,- ('Webdings', 53): 9206,- ('Webdings', 54): 9207,- ('Webdings', 55): 9194,- ('Webdings', 56): 9193,- ('Webdings', 57): 9198,- ('Webdings', 58): 9197,- ('Webdings', 59): 9208,- ('Webdings', 60): 9209,- ('Webdings', 61): 9210,- ('Webdings', 62): 128474,- ('Webdings', 63): 128499,- ('Webdings', 64): 128736,- ('Webdings', 65): 127959,- ('Webdings', 66): 127960,- ('Webdings', 67): 127961,- ('Webdings', 68): 127962,- ('Webdings', 69): 127964,- ('Webdings', 70): 127981,- ('Webdings', 71): 127963,- ('Webdings', 72): 127968,- ('Webdings', 73): 127958,- ('Webdings', 74): 127965,- ('Webdings', 75): 128739,- ('Webdings', 76): 128269,- ('Webdings', 77): 127956,- ('Webdings', 78): 128065,- ('Webdings', 79): 128066,- ('Webdings', 80): 127966,- ('Webdings', 81): 127957,- ('Webdings', 82): 128740,- ('Webdings', 83): 127967,- ('Webdings', 84): 128755,- ('Webdings', 85): 128364,- ('Webdings', 86): 128363,- ('Webdings', 87): 128360,- ('Webdings', 88): 128264,- ('Webdings', 89): 127892,- ('Webdings', 90): 127893,- ('Webdings', 91): 128492,- ('Webdings', 92): 128637,- ('Webdings', 93): 128493,- ('Webdings', 94): 128490,- ('Webdings', 95): 128491,- ('Webdings', 96): 11156,- ('Webdings', 97): 10004,- ('Webdings', 98): 128690,- ('Webdings', 99): 11036,- ('Webdings', 100): 128737,- ('Webdings', 101): 128230,- ('Webdings', 102): 128753,- ('Webdings', 103): 11035,- ('Webdings', 104): 128657,- ('Webdings', 105): 128712,- ('Webdings', 106): 128745,- ('Webdings', 107): 128752,- ('Webdings', 108): 128968,- ('Webdings', 109): 128372,- ('Webdings', 110): 11044,- ('Webdings', 111): 128741,- ('Webdings', 112): 128660,- ('Webdings', 113): 128472,- ('Webdings', 114): 128473,- ('Webdings', 115): 10067,- ('Webdings', 116): 128754,- ('Webdings', 117): 128647,- ('Webdings', 118): 128653,- ('Webdings', 119): 9971,- ('Webdings', 120): 10680,- ('Webdings', 121): 8854,- ('Webdings', 122): 128685,- ('Webdings', 123): 128494,- ('Webdings', 124): 9168,- ('Webdings', 125): 128495,- ('Webdings', 126): 128498,- ('Webdings', 128): 128697,- ('Webdings', 129): 128698,- ('Webdings', 130): 128713,- ('Webdings', 131): 128714,- ('Webdings', 132): 128700,- ('Webdings', 133): 128125,- ('Webdings', 134): 127947,- ('Webdings', 135): 9975,- ('Webdings', 136): 127938,- ('Webdings', 137): 127948,- ('Webdings', 138): 127946,- ('Webdings', 139): 127940,- ('Webdings', 140): 127949,- ('Webdings', 141): 127950,- ('Webdings', 142): 128664,- ('Webdings', 143): 128480,- ('Webdings', 144): 128738,- ('Webdings', 145): 128176,- ('Webdings', 146): 127991,- ('Webdings', 147): 128179,- ('Webdings', 148): 128106,- ('Webdings', 149): 128481,- ('Webdings', 150): 128482,- ('Webdings', 151): 128483,- ('Webdings', 152): 10031,- ('Webdings', 153): 128388,- ('Webdings', 154): 128389,- ('Webdings', 155): 128387,- ('Webdings', 156): 128390,- ('Webdings', 157): 128441,- ('Webdings', 158): 128442,- ('Webdings', 159): 128443,- ('Webdings', 160): 128373,- ('Webdings', 161): 128368,- ('Webdings', 162): 128445,- ('Webdings', 163): 128446,- ('Webdings', 164): 128203,- ('Webdings', 165): 128466,- ('Webdings', 166): 128467,- ('Webdings', 167): 128366,- ('Webdings', 168): 128218,- ('Webdings', 169): 128478,- ('Webdings', 170): 128479,- ('Webdings', 171): 128451,- ('Webdings', 172): 128450,- ('Webdings', 173): 128444,- ('Webdings', 174): 127917,- ('Webdings', 175): 127900,- ('Webdings', 176): 127896,- ('Webdings', 177): 127897,- ('Webdings', 178): 127911,- ('Webdings', 179): 128191,- ('Webdings', 180): 127902,- ('Webdings', 181): 128247,- ('Webdings', 182): 127903,- ('Webdings', 183): 127916,- ('Webdings', 184): 128253,- ('Webdings', 185): 128249,- ('Webdings', 186): 128254,- ('Webdings', 187): 128251,- ('Webdings', 188): 127898,- ('Webdings', 189): 127899,- ('Webdings', 190): 128250,- ('Webdings', 191): 128187,- ('Webdings', 192): 128421,- ('Webdings', 193): 128422,- ('Webdings', 194): 128423,- ('Webdings', 195): 128377,- ('Webdings', 196): 127918,- ('Webdings', 197): 128379,- ('Webdings', 198): 128380,- ('Webdings', 199): 128223,- ('Webdings', 200): 128385,- ('Webdings', 201): 128384,- ('Webdings', 202): 128424,- ('Webdings', 203): 128425,- ('Webdings', 204): 128447,- ('Webdings', 205): 128426,- ('Webdings', 206): 128476,- ('Webdings', 207): 128274,- ('Webdings', 208): 128275,- ('Webdings', 209): 128477,- ('Webdings', 210): 128229,- ('Webdings', 211): 128228,- ('Webdings', 212): 128371,- ('Webdings', 213): 127779,- ('Webdings', 214): 127780,- ('Webdings', 215): 127781,- ('Webdings', 216): 127782,- ('Webdings', 217): 9729,- ('Webdings', 218): 127784,- ('Webdings', 219): 127783,- ('Webdings', 220): 127785,- ('Webdings', 221): 127786,- ('Webdings', 222): 127788,- ('Webdings', 223): 127787,- ('Webdings', 224): 127772,- ('Webdings', 225): 127777,- ('Webdings', 226): 128715,- ('Webdings', 227): 128719,- ('Webdings', 228): 127869,- ('Webdings', 229): 127864,- ('Webdings', 230): 128718,- ('Webdings', 231): 128717,- ('Webdings', 232): 9413,- ('Webdings', 233): 9855,- ('Webdings', 234): 128710,- ('Webdings', 235): 128392,- ('Webdings', 236): 127891,- ('Webdings', 237): 128484,- ('Webdings', 238): 128485,- ('Webdings', 239): 128486,- ('Webdings', 240): 128487,- ('Webdings', 241): 128746,- ('Webdings', 242): 128063,- ('Webdings', 243): 128038,- ('Webdings', 244): 128031,- ('Webdings', 245): 128021,- ('Webdings', 246): 128008,- ('Webdings', 247): 128620,- ('Webdings', 248): 128622,- ('Webdings', 249): 128621,- ('Webdings', 250): 128623,- ('Webdings', 251): 128506,- ('Webdings', 252): 127757,- ('Webdings', 253): 127759,- ('Webdings', 254): 127758,- ('Webdings', 255): 128330,- ('Wingdings', 32): 32,- ('Wingdings', 33): 128393,- ('Wingdings', 34): 9986,- ('Wingdings', 35): 9985,- ('Wingdings', 36): 128083,- ('Wingdings', 37): 128365,- ('Wingdings', 38): 128366,- ('Wingdings', 39): 128367,- ('Wingdings', 40): 128383,- ('Wingdings', 41): 9990,- ('Wingdings', 42): 128386,- ('Wingdings', 43): 128387,- ('Wingdings', 44): 128234,- ('Wingdings', 45): 128235,- ('Wingdings', 46): 128236,- ('Wingdings', 47): 128237,- ('Wingdings', 48): 128448,- ('Wingdings', 49): 128449,- ('Wingdings', 50): 128462,- ('Wingdings', 51): 128463,- ('Wingdings', 52): 128464,- ('Wingdings', 53): 128452,- ('Wingdings', 54): 8987,- ('Wingdings', 55): 128430,- ('Wingdings', 56): 128432,- ('Wingdings', 57): 128434,- ('Wingdings', 58): 128435,- ('Wingdings', 59): 128436,- ('Wingdings', 60): 128427,- ('Wingdings', 61): 128428,- ('Wingdings', 62): 9991,- ('Wingdings', 63): 9997,- ('Wingdings', 64): 128398,- ('Wingdings', 65): 9996,- ('Wingdings', 66): 128399,- ('Wingdings', 67): 128077,- ('Wingdings', 68): 128078,- ('Wingdings', 69): 9756,- ('Wingdings', 70): 9758,- ('Wingdings', 71): 9757,- ('Wingdings', 72): 9759,- ('Wingdings', 73): 128400,- ('Wingdings', 74): 9786,- ('Wingdings', 75): 128528,- ('Wingdings', 76): 9785,- ('Wingdings', 77): 128163,- ('Wingdings', 78): 128369,- ('Wingdings', 79): 127987,- ('Wingdings', 80): 127985,- ('Wingdings', 81): 9992,- ('Wingdings', 82): 9788,- ('Wingdings', 83): 127778,- ('Wingdings', 84): 10052,- ('Wingdings', 85): 128326,- ('Wingdings', 86): 10014,- ('Wingdings', 87): 128328,- ('Wingdings', 88): 10016,- ('Wingdings', 89): 10017,- ('Wingdings', 90): 9770,- ('Wingdings', 91): 9775,- ('Wingdings', 92): 128329,- ('Wingdings', 93): 9784,- ('Wingdings', 94): 9800,- ('Wingdings', 95): 9801,- ('Wingdings', 96): 9802,- ('Wingdings', 97): 9803,- ('Wingdings', 98): 9804,- ('Wingdings', 99): 9805,- ('Wingdings', 100): 9806,- ('Wingdings', 101): 9807,- ('Wingdings', 102): 9808,- ('Wingdings', 103): 9809,- ('Wingdings', 104): 9810,- ('Wingdings', 105): 9811,- ('Wingdings', 106): 128624,- ('Wingdings', 107): 128629,- ('Wingdings', 108): 9899,- ('Wingdings', 109): 128318,- ('Wingdings', 110): 9724,- ('Wingdings', 111): 128911,- ('Wingdings', 112): 128912,- ('Wingdings', 113): 10065,- ('Wingdings', 114): 10066,- ('Wingdings', 115): 128927,- ('Wingdings', 116): 10731,- ('Wingdings', 117): 9670,- ('Wingdings', 118): 10070,- ('Wingdings', 119): 11049,- ('Wingdings', 120): 8999,- ('Wingdings', 121): 11193,- ('Wingdings', 122): 8984,- ('Wingdings', 123): 127989,- ('Wingdings', 124): 127990,- ('Wingdings', 125): 128630,- ('Wingdings', 126): 128631,- ('Wingdings', 127): 9647,- ('Wingdings', 128): 127243,- ('Wingdings', 129): 10112,- ('Wingdings', 130): 10113,- ('Wingdings', 131): 10114,- ('Wingdings', 132): 10115,- ('Wingdings', 133): 10116,- ('Wingdings', 134): 10117,- ('Wingdings', 135): 10118,- ('Wingdings', 136): 10119,- ('Wingdings', 137): 10120,- ('Wingdings', 138): 10121,- ('Wingdings', 139): 127244,- ('Wingdings', 140): 10122,- ('Wingdings', 141): 10123,- ('Wingdings', 142): 10124,- ('Wingdings', 143): 10125,- ('Wingdings', 144): 10126,- ('Wingdings', 145): 10127,- ('Wingdings', 146): 10128,- ('Wingdings', 147): 10129,- ('Wingdings', 148): 10130,- ('Wingdings', 149): 10131,- ('Wingdings', 150): 128610,- ('Wingdings', 151): 128608,- ('Wingdings', 152): 128609,- ('Wingdings', 153): 128611,- ('Wingdings', 154): 128606,- ('Wingdings', 155): 128604,- ('Wingdings', 156): 128605,- ('Wingdings', 157): 128607,- ('Wingdings', 158): 8729,- ('Wingdings', 159): 8226,- ('Wingdings', 160): 11037,- ('Wingdings', 161): 11096,- ('Wingdings', 162): 128902,- ('Wingdings', 163): 128904,- ('Wingdings', 164): 128906,- ('Wingdings', 165): 128907,- ('Wingdings', 166): 128319,- ('Wingdings', 167): 9642,- ('Wingdings', 168): 128910,- ('Wingdings', 169): 128961,- ('Wingdings', 170): 128965,- ('Wingdings', 171): 9733,- ('Wingdings', 172): 128971,- ('Wingdings', 173): 128975,- ('Wingdings', 174): 128979,- ('Wingdings', 175): 128977,- ('Wingdings', 176): 11216,- ('Wingdings', 177): 8982,- ('Wingdings', 178): 11214,- ('Wingdings', 179): 11215,- ('Wingdings', 180): 11217,- ('Wingdings', 181): 10026,- ('Wingdings', 182): 10032,- ('Wingdings', 183): 128336,- ('Wingdings', 184): 128337,- ('Wingdings', 185): 128338,- ('Wingdings', 186): 128339,- ('Wingdings', 187): 128340,- ('Wingdings', 188): 128341,- ('Wingdings', 189): 128342,- ('Wingdings', 190): 128343,- ('Wingdings', 191): 128344,- ('Wingdings', 192): 128345,- ('Wingdings', 193): 128346,- ('Wingdings', 194): 128347,- ('Wingdings', 195): 11184,- ('Wingdings', 196): 11185,- ('Wingdings', 197): 11186,- ('Wingdings', 198): 11187,- ('Wingdings', 199): 11188,- ('Wingdings', 200): 11189,- ('Wingdings', 201): 11190,- ('Wingdings', 202): 11191,- ('Wingdings', 203): 128618,- ('Wingdings', 204): 128619,- ('Wingdings', 205): 128597,- ('Wingdings', 206): 128596,- ('Wingdings', 207): 128599,- ('Wingdings', 208): 128598,- ('Wingdings', 209): 128592,- ('Wingdings', 210): 128593,- ('Wingdings', 211): 128594,- ('Wingdings', 212): 128595,- ('Wingdings', 213): 9003,- ('Wingdings', 214): 8998,- ('Wingdings', 215): 11160,- ('Wingdings', 216): 11162,- ('Wingdings', 217): 11161,- ('Wingdings', 218): 11163,- ('Wingdings', 219): 11144,- ('Wingdings', 220): 11146,- ('Wingdings', 221): 11145,- ('Wingdings', 222): 11147,- ('Wingdings', 223): 129128,- ('Wingdings', 224): 129130,- ('Wingdings', 225): 129129,- ('Wingdings', 226): 129131,- ('Wingdings', 227): 129132,- ('Wingdings', 228): 129133,- ('Wingdings', 229): 129135,- ('Wingdings', 230): 129134,- ('Wingdings', 231): 129144,- ('Wingdings', 232): 129146,- ('Wingdings', 233): 129145,- ('Wingdings', 234): 129147,- ('Wingdings', 235): 129148,- ('Wingdings', 236): 129149,- ('Wingdings', 237): 129151,- ('Wingdings', 238): 129150,- ('Wingdings', 239): 8678,- ('Wingdings', 240): 8680,- ('Wingdings', 241): 8679,- ('Wingdings', 242): 8681,- ('Wingdings', 243): 11012,- ('Wingdings', 244): 8691,- ('Wingdings', 245): 11009,- ('Wingdings', 246): 11008,- ('Wingdings', 247): 11011,- ('Wingdings', 248): 11010,- ('Wingdings', 249): 129196,- ('Wingdings', 250): 129197,- ('Wingdings', 251): 128502,- ('Wingdings', 252): 10003,- ('Wingdings', 253): 128503,- ('Wingdings', 254): 128505,- ('Wingdings 2', 32): 32,- ('Wingdings 2', 33): 128394,- ('Wingdings 2', 34): 128395,- ('Wingdings 2', 35): 128396,- ('Wingdings 2', 36): 128397,- ('Wingdings 2', 37): 9988,- ('Wingdings 2', 38): 9984,- ('Wingdings 2', 39): 128382,- ('Wingdings 2', 40): 128381,- ('Wingdings 2', 41): 128453,- ('Wingdings 2', 42): 128454,- ('Wingdings 2', 43): 128455,- ('Wingdings 2', 44): 128456,- ('Wingdings 2', 45): 128457,- ('Wingdings 2', 46): 128458,- ('Wingdings 2', 47): 128459,- ('Wingdings 2', 48): 128460,- ('Wingdings 2', 49): 128461,- ('Wingdings 2', 50): 128203,- ('Wingdings 2', 51): 128465,- ('Wingdings 2', 52): 128468,- ('Wingdings 2', 53): 128437,- ('Wingdings 2', 54): 128438,- ('Wingdings 2', 55): 128439,- ('Wingdings 2', 56): 128440,- ('Wingdings 2', 57): 128429,- ('Wingdings 2', 58): 128431,- ('Wingdings 2', 59): 128433,- ('Wingdings 2', 60): 128402,- ('Wingdings 2', 61): 128403,- ('Wingdings 2', 62): 128408,- ('Wingdings 2', 63): 128409,- ('Wingdings 2', 64): 128410,- ('Wingdings 2', 65): 128411,- ('Wingdings 2', 66): 128072,- ('Wingdings 2', 67): 128073,- ('Wingdings 2', 68): 128412,- ('Wingdings 2', 69): 128413,- ('Wingdings 2', 70): 128414,- ('Wingdings 2', 71): 128415,- ('Wingdings 2', 72): 128416,- ('Wingdings 2', 73): 128417,- ('Wingdings 2', 74): 128070,- ('Wingdings 2', 75): 128071,- ('Wingdings 2', 76): 128418,- ('Wingdings 2', 77): 128419,- ('Wingdings 2', 78): 128401,- ('Wingdings 2', 79): 128500,- ('Wingdings 2', 80): 128504,- ('Wingdings 2', 81): 128501,- ('Wingdings 2', 82): 9745,- ('Wingdings 2', 83): 11197,- ('Wingdings 2', 84): 9746,- ('Wingdings 2', 85): 11198,- ('Wingdings 2', 86): 11199,- ('Wingdings 2', 87): 128711,- ('Wingdings 2', 88): 10680,- ('Wingdings 2', 89): 128625,- ('Wingdings 2', 90): 128628,- ('Wingdings 2', 91): 128626,- ('Wingdings 2', 92): 128627,- ('Wingdings 2', 93): 8253,- ('Wingdings 2', 94): 128633,- ('Wingdings 2', 95): 128634,- ('Wingdings 2', 96): 128635,- ('Wingdings 2', 97): 128614,- ('Wingdings 2', 98): 128612,- ('Wingdings 2', 99): 128613,- ('Wingdings 2', 100): 128615,- ('Wingdings 2', 101): 128602,- ('Wingdings 2', 102): 128600,- ('Wingdings 2', 103): 128601,- ('Wingdings 2', 104): 128603,- ('Wingdings 2', 105): 9450,- ('Wingdings 2', 106): 9312,- ('Wingdings 2', 107): 9313,- ('Wingdings 2', 108): 9314,- ('Wingdings 2', 109): 9315,- ('Wingdings 2', 110): 9316,- ('Wingdings 2', 111): 9317,- ('Wingdings 2', 112): 9318,- ('Wingdings 2', 113): 9319,- ('Wingdings 2', 114): 9320,- ('Wingdings 2', 115): 9321,- ('Wingdings 2', 116): 9471,- ('Wingdings 2', 117): 10102,- ('Wingdings 2', 118): 10103,- ('Wingdings 2', 119): 10104,- ('Wingdings 2', 120): 10105,- ('Wingdings 2', 121): 10106,- ('Wingdings 2', 122): 10107,- ('Wingdings 2', 123): 10108,- ('Wingdings 2', 124): 10109,- ('Wingdings 2', 125): 10110,- ('Wingdings 2', 126): 10111,- ('Wingdings 2', 128): 9737,- ('Wingdings 2', 129): 127765,- ('Wingdings 2', 130): 9789,- ('Wingdings 2', 131): 9790,- ('Wingdings 2', 132): 11839,- ('Wingdings 2', 133): 10013,- ('Wingdings 2', 134): 128327,- ('Wingdings 2', 135): 128348,- ('Wingdings 2', 136): 128349,- ('Wingdings 2', 137): 128350,- ('Wingdings 2', 138): 128351,- ('Wingdings 2', 139): 128352,- ('Wingdings 2', 140): 128353,- ('Wingdings 2', 141): 128354,- ('Wingdings 2', 142): 128355,- ('Wingdings 2', 143): 128356,- ('Wingdings 2', 144): 128357,- ('Wingdings 2', 145): 128358,- ('Wingdings 2', 146): 128359,- ('Wingdings 2', 147): 128616,- ('Wingdings 2', 148): 128617,- ('Wingdings 2', 149): 8901,- ('Wingdings 2', 150): 128900,- ('Wingdings 2', 151): 10625,- ('Wingdings 2', 152): 9679,- ('Wingdings 2', 153): 9675,- ('Wingdings 2', 154): 128901,- ('Wingdings 2', 155): 128903,- ('Wingdings 2', 156): 128905,- ('Wingdings 2', 157): 8857,- ('Wingdings 2', 158): 10687,- ('Wingdings 2', 159): 128908,- ('Wingdings 2', 160): 128909,- ('Wingdings 2', 161): 9726,- ('Wingdings 2', 162): 9632,- ('Wingdings 2', 163): 9633,- ('Wingdings 2', 164): 128913,- ('Wingdings 2', 165): 128914,- ('Wingdings 2', 166): 128915,- ('Wingdings 2', 167): 128916,- ('Wingdings 2', 168): 9635,- ('Wingdings 2', 169): 128917,- ('Wingdings 2', 170): 128918,- ('Wingdings 2', 171): 128919,- ('Wingdings 2', 172): 128920,- ('Wingdings 2', 173): 11049,- ('Wingdings 2', 174): 11045,- ('Wingdings 2', 175): 9671,- ('Wingdings 2', 176): 128922,- ('Wingdings 2', 177): 9672,- ('Wingdings 2', 178): 128923,- ('Wingdings 2', 179): 128924,- ('Wingdings 2', 180): 128925,- ('Wingdings 2', 181): 128926,- ('Wingdings 2', 182): 11050,- ('Wingdings 2', 183): 11047,- ('Wingdings 2', 184): 9674,- ('Wingdings 2', 185): 128928,- ('Wingdings 2', 186): 9686,- ('Wingdings 2', 187): 9687,- ('Wingdings 2', 188): 11210,- ('Wingdings 2', 189): 11211,- ('Wingdings 2', 190): 11200,- ('Wingdings 2', 191): 11201,- ('Wingdings 2', 192): 11039,- ('Wingdings 2', 193): 11202,- ('Wingdings 2', 194): 11043,- ('Wingdings 2', 195): 11042,- ('Wingdings 2', 196): 11203,- ('Wingdings 2', 197): 11204,- ('Wingdings 2', 198): 128929,- ('Wingdings 2', 199): 128930,- ('Wingdings 2', 200): 128931,- ('Wingdings 2', 201): 128932,- ('Wingdings 2', 202): 128933,- ('Wingdings 2', 203): 128934,- ('Wingdings 2', 204): 128935,- ('Wingdings 2', 205): 128936,- ('Wingdings 2', 206): 128937,- ('Wingdings 2', 207): 128938,- ('Wingdings 2', 208): 128939,- ('Wingdings 2', 209): 128940,- ('Wingdings 2', 210): 128941,- ('Wingdings 2', 211): 128942,- ('Wingdings 2', 212): 128943,- ('Wingdings 2', 213): 128944,- ('Wingdings 2', 214): 128945,- ('Wingdings 2', 215): 128946,- ('Wingdings 2', 216): 128947,- ('Wingdings 2', 217): 128948,- ('Wingdings 2', 218): 128949,- ('Wingdings 2', 219): 128950,- ('Wingdings 2', 220): 128951,- ('Wingdings 2', 221): 128952,- ('Wingdings 2', 222): 128953,- ('Wingdings 2', 223): 128954,- ('Wingdings 2', 224): 128955,- ('Wingdings 2', 225): 128956,- ('Wingdings 2', 226): 128957,- ('Wingdings 2', 227): 128958,- ('Wingdings 2', 228): 128959,- ('Wingdings 2', 229): 128960,- ('Wingdings 2', 230): 128962,- ('Wingdings 2', 231): 128964,- ('Wingdings 2', 232): 128966,- ('Wingdings 2', 233): 128969,- ('Wingdings 2', 234): 128970,- ('Wingdings 2', 235): 10038,- ('Wingdings 2', 236): 128972,- ('Wingdings 2', 237): 128974,- ('Wingdings 2', 238): 128976,- ('Wingdings 2', 239): 128978,- ('Wingdings 2', 240): 10041,- ('Wingdings 2', 241): 128963,- ('Wingdings 2', 242): 128967,- ('Wingdings 2', 243): 10031,- ('Wingdings 2', 244): 128973,- ('Wingdings 2', 245): 128980,- ('Wingdings 2', 246): 11212,- ('Wingdings 2', 247): 11213,- ('Wingdings 2', 248): 8251,- ('Wingdings 2', 249): 8258,- ('Wingdings 3', 32): 32,- ('Wingdings 3', 33): 11104,- ('Wingdings 3', 34): 11106,- ('Wingdings 3', 35): 11105,- ('Wingdings 3', 36): 11107,- ('Wingdings 3', 37): 11110,- ('Wingdings 3', 38): 11111,- ('Wingdings 3', 39): 11113,- ('Wingdings 3', 40): 11112,- ('Wingdings 3', 41): 11120,- ('Wingdings 3', 42): 11122,- ('Wingdings 3', 43): 11121,- ('Wingdings 3', 44): 11123,- ('Wingdings 3', 45): 11126,- ('Wingdings 3', 46): 11128,- ('Wingdings 3', 47): 11131,- ('Wingdings 3', 48): 11133,- ('Wingdings 3', 49): 11108,- ('Wingdings 3', 50): 11109,- ('Wingdings 3', 51): 11114,- ('Wingdings 3', 52): 11116,- ('Wingdings 3', 53): 11115,- ('Wingdings 3', 54): 11117,- ('Wingdings 3', 55): 11085,- ('Wingdings 3', 56): 11168,- ('Wingdings 3', 57): 11169,- ('Wingdings 3', 58): 11170,- ('Wingdings 3', 59): 11171,- ('Wingdings 3', 60): 11172,- ('Wingdings 3', 61): 11173,- ('Wingdings 3', 62): 11174,- ('Wingdings 3', 63): 11175,- ('Wingdings 3', 64): 11152,- ('Wingdings 3', 65): 11153,- ('Wingdings 3', 66): 11154,- ('Wingdings 3', 67): 11155,- ('Wingdings 3', 68): 11136,- ('Wingdings 3', 69): 11139,- ('Wingdings 3', 70): 11134,- ('Wingdings 3', 71): 11135,- ('Wingdings 3', 72): 11140,- ('Wingdings 3', 73): 11142,- ('Wingdings 3', 74): 11141,- ('Wingdings 3', 75): 11143,- ('Wingdings 3', 76): 11151,- ('Wingdings 3', 77): 11149,- ('Wingdings 3', 78): 11150,- ('Wingdings 3', 79): 11148,- ('Wingdings 3', 80): 11118,- ('Wingdings 3', 81): 11119,- ('Wingdings 3', 82): 9099,- ('Wingdings 3', 83): 8996,- ('Wingdings 3', 84): 8963,- ('Wingdings 3', 85): 8997,- ('Wingdings 3', 86): 9251,- ('Wingdings 3', 87): 9085,- ('Wingdings 3', 88): 8682,- ('Wingdings 3', 89): 11192,- ('Wingdings 3', 90): 129184,- ('Wingdings 3', 91): 129185,- ('Wingdings 3', 92): 129186,- ('Wingdings 3', 93): 129187,- ('Wingdings 3', 94): 129188,- ('Wingdings 3', 95): 129189,- ('Wingdings 3', 96): 129190,- ('Wingdings 3', 97): 129191,- ('Wingdings 3', 98): 129192,- ('Wingdings 3', 99): 129193,- ('Wingdings 3', 100): 129194,- ('Wingdings 3', 101): 129195,- ('Wingdings 3', 102): 129104,- ('Wingdings 3', 103): 129106,- ('Wingdings 3', 104): 129105,- ('Wingdings 3', 105): 129107,- ('Wingdings 3', 106): 129108,- ('Wingdings 3', 107): 129109,- ('Wingdings 3', 108): 129111,- ('Wingdings 3', 109): 129110,- ('Wingdings 3', 110): 129112,- ('Wingdings 3', 111): 129113,- ('Wingdings 3', 112): 9650,- ('Wingdings 3', 113): 9660,- ('Wingdings 3', 114): 9651,- ('Wingdings 3', 115): 9661,- ('Wingdings 3', 116): 9664,- ('Wingdings 3', 117): 9654,- ('Wingdings 3', 118): 9665,- ('Wingdings 3', 119): 9655,- ('Wingdings 3', 120): 9699,- ('Wingdings 3', 121): 9698,- ('Wingdings 3', 122): 9700,- ('Wingdings 3', 123): 9701,- ('Wingdings 3', 124): 128896,- ('Wingdings 3', 125): 128898,- ('Wingdings 3', 126): 128897,- ('Wingdings 3', 128): 128899,- ('Wingdings 3', 129): 11205,- ('Wingdings 3', 130): 11206,- ('Wingdings 3', 131): 11207,- ('Wingdings 3', 132): 11208,- ('Wingdings 3', 133): 11164,- ('Wingdings 3', 134): 11166,- ('Wingdings 3', 135): 11165,- ('Wingdings 3', 136): 11167,- ('Wingdings 3', 137): 129040,- ('Wingdings 3', 138): 129042,- ('Wingdings 3', 139): 129041,- ('Wingdings 3', 140): 129043,- ('Wingdings 3', 141): 129044,- ('Wingdings 3', 142): 129046,- ('Wingdings 3', 143): 129045,- ('Wingdings 3', 144): 129047,- ('Wingdings 3', 145): 129048,- ('Wingdings 3', 146): 129050,- ('Wingdings 3', 147): 129049,- ('Wingdings 3', 148): 129051,- ('Wingdings 3', 149): 129052,- ('Wingdings 3', 150): 129054,- ('Wingdings 3', 151): 129053,- ('Wingdings 3', 152): 129055,- ('Wingdings 3', 153): 129024,- ('Wingdings 3', 154): 129026,- ('Wingdings 3', 155): 129025,- ('Wingdings 3', 156): 129027,- ('Wingdings 3', 157): 129028,- ('Wingdings 3', 158): 129030,- ('Wingdings 3', 159): 129029,- ('Wingdings 3', 160): 129031,- ('Wingdings 3', 161): 129032,- ('Wingdings 3', 162): 129034,- ('Wingdings 3', 163): 129033,- ('Wingdings 3', 164): 129035,- ('Wingdings 3', 165): 129056,- ('Wingdings 3', 166): 129058,- ('Wingdings 3', 167): 129060,- ('Wingdings 3', 168): 129062,- ('Wingdings 3', 169): 129064,- ('Wingdings 3', 170): 129066,- ('Wingdings 3', 171): 129068,- ('Wingdings 3', 172): 129180,- ('Wingdings 3', 173): 129181,- ('Wingdings 3', 174): 129182,- ('Wingdings 3', 175): 129183,- ('Wingdings 3', 176): 129070,- ('Wingdings 3', 177): 129072,- ('Wingdings 3', 178): 129074,- ('Wingdings 3', 179): 129076,- ('Wingdings 3', 180): 129078,- ('Wingdings 3', 181): 129080,- ('Wingdings 3', 182): 129082,- ('Wingdings 3', 183): 129081,- ('Wingdings 3', 184): 129083,- ('Wingdings 3', 185): 129176,- ('Wingdings 3', 186): 129178,- ('Wingdings 3', 187): 129177,- ('Wingdings 3', 188): 129179,- ('Wingdings 3', 189): 129084,- ('Wingdings 3', 190): 129086,- ('Wingdings 3', 191): 129085,- ('Wingdings 3', 192): 129087,- ('Wingdings 3', 193): 129088,- ('Wingdings 3', 194): 129090,- ('Wingdings 3', 195): 129089,- ('Wingdings 3', 196): 129091,- ('Wingdings 3', 197): 129092,- ('Wingdings 3', 198): 129094,- ('Wingdings 3', 199): 129093,- ('Wingdings 3', 200): 129095,- ('Wingdings 3', 201): 11176,- ('Wingdings 3', 202): 11177,- ('Wingdings 3', 203): 11178,- ('Wingdings 3', 204): 11179,- ('Wingdings 3', 205): 11180,- ('Wingdings 3', 206): 11181,- ('Wingdings 3', 207): 11182,- ('Wingdings 3', 208): 11183,- ('Wingdings 3', 209): 129120,- ('Wingdings 3', 210): 129122,- ('Wingdings 3', 211): 129121,- ('Wingdings 3', 212): 129123,- ('Wingdings 3', 213): 129124,- ('Wingdings 3', 214): 129125,- ('Wingdings 3', 215): 129127,- ('Wingdings 3', 216): 129126,- ('Wingdings 3', 217): 129136,- ('Wingdings 3', 218): 129138,- ('Wingdings 3', 219): 129137,- ('Wingdings 3', 220): 129139,- ('Wingdings 3', 221): 129140,- ('Wingdings 3', 222): 129141,- ('Wingdings 3', 223): 129143,- ('Wingdings 3', 224): 129142,- ('Wingdings 3', 225): 129152,- ('Wingdings 3', 226): 129154,- ('Wingdings 3', 227): 129153,- ('Wingdings 3', 228): 129155,- ('Wingdings 3', 229): 129156,- ('Wingdings 3', 230): 129157,- ('Wingdings 3', 231): 129159,- ('Wingdings 3', 232): 129158,- ('Wingdings 3', 233): 129168,- ('Wingdings 3', 234): 129170,- ('Wingdings 3', 235): 129169,- ('Wingdings 3', 236): 129171,- ('Wingdings 3', 237): 129172,- ('Wingdings 3', 238): 129174,- ('Wingdings 3', 239): 129173,- ('Wingdings 3', 240): 129175,-}diff --git a/mineru/model/utils/docx/mammoth/documents.py b/mineru/model/utils/docx/mammoth/documents.pydeleted file mode 100644index fbd71baa..00000000--- a/mineru/model/utils/docx/mammoth/documents.py+++ /dev/null@@ -1,286 +0,0 @@-import cobble---class Element(object):- def copy(self, **kwargs):- return cobble.copy(self, **kwargs)---class HasChildren(Element):- children = cobble.field()---class Document(HasChildren):- notes = cobble.field()- comments = cobble.field()--class Paragraph(HasChildren):- style_id = cobble.field()- style_name = cobble.field()- numbering = cobble.field()- alignment = cobble.field()- indent = cobble.field()---class ParagraphIndent(object):- start = cobble.field()- end = cobble.field()- first_line = cobble.field()- hanging = cobble.field()---class Indent(object):- left = cobble.field()- right = cobble.field()- first_line = cobble.field()- hanging = cobble.field()---class Run(HasChildren):- style_id = cobble.field()- style_name = cobble.field()- is_bold = cobble.field()- is_italic = cobble.field()- is_underline = cobble.field()- is_strikethrough = cobble.field()- is_all_caps = cobble.field()- is_small_caps = cobble.field()- vertical_alignment = cobble.field()- font = cobble.field()- font_size = cobble.field()- highlight = cobble.field()--class Text(Element):- value = cobble.field()--class Hyperlink(HasChildren):- href = cobble.field()- anchor = cobble.field()- target_frame = cobble.field()--class Checkbox(Element):- checked = cobble.field()--checkbox = Checkbox--class Table(HasChildren):- style_id = cobble.field()- style_name = cobble.field()--class TableRow(HasChildren):- is_header = cobble.field()--class TableCell(HasChildren):- colspan = cobble.field()- rowspan = cobble.field()--class TableCellUnmerged:- children = cobble.field()- colspan = cobble.field()- rowspan = cobble.field()- vmerge = cobble.field()-- def _accept1(self, visitor, arg0):- return visitor.visit_table_cell(self, arg0)-- def copy(self, **kwargs):- return cobble.copy(self, **kwargs)--class Break(Element):- break_type = cobble.field()--line_break = Break("line")-page_break = Break("page")-column_break = Break("column")---class Tab(Element):- pass---class Image(Element):- alt_text = cobble.field()- content_type = cobble.field()- open = cobble.field()---def document(children, notes=None, comments=None):- if notes is None:- notes = Notes({})- if comments is None:- comments = []- return Document(children, notes, comments=comments)--def paragraph(children, style_id=None, style_name=None, numbering=None, alignment=None, indent=None):- if indent is None:- indent = paragraph_indent()-- return Paragraph(children, style_id, style_name, numbering, alignment=alignment, indent=indent)--def paragraph_indent(start=None, end=None, first_line=None, hanging=None):- return ParagraphIndent(start=start, end=end, first_line=first_line, hanging=hanging)--def run(- children,- style_id=None,- style_name=None,- is_bold=None,- is_italic=None,- is_underline=None,- is_strikethrough=None,- is_all_caps=None,- is_small_caps=None,- vertical_alignment=None,- font=None,- font_size=None,- highlight=None,-):- if vertical_alignment is None:- vertical_alignment = VerticalAlignment.baseline- return Run(- children=children,- style_id=style_id,- style_name=style_name,- is_bold=bool(is_bold),- is_italic=bool(is_italic),- is_underline=bool(is_underline),- is_strikethrough=bool(is_strikethrough),- is_all_caps=bool(is_all_caps),- is_small_caps=bool(is_small_caps),- vertical_alignment=vertical_alignment,- font=font,- font_size=font_size,- highlight=highlight,- )--class VerticalAlignment(object):- baseline = "baseline"- superscript = "superscript"- subscript = "subscript"--text = Text--_tab = Tab()--def tab():- return _tab---image = Image--def hyperlink(children, href=None, anchor=None, target_frame=None):- return Hyperlink(href=href, anchor=anchor, target_frame=target_frame, children=children)---class Bookmark(Element):- name = cobble.field()--bookmark = Bookmark---def table(children, style_id=None, style_name=None):- return Table(children=children, style_id=style_id, style_name=style_name)--def table_row(children, is_header=None):- return TableRow(children=children, is_header=bool(is_header))--def table_cell(children, colspan=None, rowspan=None):- if colspan is None:- colspan = 1- if rowspan is None:- rowspan = 1- return TableCell(children=children, colspan=colspan, rowspan=rowspan)--def table_cell_unmerged(children, colspan, rowspan, vmerge):- return TableCellUnmerged(children=children, colspan=colspan, rowspan=rowspan, vmerge=vmerge)--def numbering_level(level_index, is_ordered):- return _NumberingLevel(str(level_index), bool(is_ordered))--class _NumberingLevel(object):- level_index = cobble.field()- is_ordered = cobble.field()--class Note(Element):- note_type = cobble.field()- note_id = cobble.field()- body = cobble.field()---note = Note---class Notes(object):- def __init__(self, notes):- self._notes = notes-- def find_note(self, note_type, note_id):- return self._notes[(note_type, note_id)]-- def resolve(self, reference):- return self.find_note(reference.note_type, reference.note_id)-- def __eq__(self, other):- return isinstance(other, Notes) and self._notes == other._notes-- def __ne__(self, other):- return not (self == other)--def notes(notes_list):- return Notes(dict(- (_note_key(note), note)- for note in notes_list- ))--def _note_key(note):- return (note.note_type, note.note_id)--class NoteReference(Element):- note_type = cobble.field()- note_id = cobble.field()--note_reference = NoteReference---class Comment(object):- comment_id = cobble.field()- body = cobble.field()- author_name = cobble.field()- author_initials = cobble.field()--def comment(comment_id, body, author_name=None, author_initials=None):- return Comment(- comment_id=comment_id,- body=body,- author_name=author_name,- author_initials=author_initials,- )--class CommentReference(Element):- comment_id = cobble.field()--comment_reference = CommentReference--def element_visitor(args):- return cobble.visitor(Element, args=args)diff --git a/mineru/model/utils/docx/mammoth/html/__init__.py b/mineru/model/utils/docx/mammoth/html/__init__.pydeleted file mode 100644index 2ad3791d..00000000--- a/mineru/model/utils/docx/mammoth/html/__init__.py+++ /dev/null@@ -1,135 +0,0 @@-from ..lists import flat_map-from .nodes import TextNode, Tag, Element, ForceWrite, NodeVisitor---def text(value):- return TextNode(value)---def tag(tag_names, attributes=None, collapsible=None, separator=None):- if not isinstance(tag_names, list):- tag_names = [tag_names]- if attributes is None:- attributes = {}- return Tag(tag_names=tag_names, attributes=attributes, collapsible=bool(collapsible), separator=separator)---def element(tag_names, attributes=None, children=None, collapsible=None, separator=None):- if children is None:- children = []-- element_tag = tag(tag_names=tag_names, attributes=attributes, collapsible=collapsible, separator=separator)- return Element(element_tag, children)---def collapsible_element(tag_names, attributes=None, children=None):- return element(tag_names, attributes, children, collapsible=True)---force_write = ForceWrite()---def strip_empty(nodes):- return flat_map(_strip_empty_node, nodes)---def _strip_empty_node(node):- return StripEmpty().visit(node)---class StripEmpty(NodeVisitor):- def visit_text_node(self, node):- if node.value:- return [node]- else:- return []-- def visit_element(self, element):- children = strip_empty(element.children)- if len(children) == 0 and not element.is_void():- return []- else:- return [Element(element.tag, children)]-- def visit_force_write(self, node):- return [node]---def collapse(nodes):- collapsed = []-- for node in nodes:- _collapsing_add(collapsed, node)-- return collapsed--class _CollapseNode(NodeVisitor):- def visit_text_node(self, node):- return node-- def visit_element(self, element):- return Element(element.tag, collapse(element.children))-- def visit_force_write(self, node):- return node--_collapse_node = _CollapseNode().visit---def _collapsing_add(collapsed, node):- collapsed_node = _collapse_node(node)- if not _try_collapse(collapsed, collapsed_node):- collapsed.append(collapsed_node)--def _try_collapse(collapsed, node):- if not collapsed:- return False-- last = collapsed[-1]- if not isinstance(last, Element) or not isinstance(node, Element):- return False-- if not node.collapsible:- return False-- if not _is_match(last, node):- return False-- if node.separator:- last.children.append(text(node.separator))-- for child in node.children:- _collapsing_add(last.children, child)-- return True--def _is_match(first, second):- return first.tag_name in second.tag_names and first.attributes == second.attributes---def write(writer, nodes):- visitor = _NodeWriter(writer)- visitor.visit_all(nodes)---class _NodeWriter(NodeVisitor):- def __init__(self, writer):- self._writer = writer-- def visit_text_node(self, node):- self._writer.text(node.value)-- def visit_element(self, element):- if element.is_void():- self._writer.self_closing(element.tag_name, element.attributes)- else:- self._writer.start(element.tag_name, element.attributes)- self.visit_all(element.children)- self._writer.end(element.tag_name)-- def visit_force_write(self, element):- pass-- def visit_all(self, nodes):- for node in nodes:- self.visit(node)diff --git a/mineru/model/utils/docx/mammoth/html/nodes.py b/mineru/model/utils/docx/mammoth/html/nodes.pydeleted file mode 100644index 321aee24..00000000--- a/mineru/model/utils/docx/mammoth/html/nodes.py+++ /dev/null@@ -1,61 +0,0 @@-import cobble---class Node(object):- pass---class TextNode(Node):- value = cobble.field()---class Tag(object):- tag_names = cobble.field()- attributes = cobble.field()- collapsible = cobble.field()- separator = cobble.field()-- @property- def tag_name(self):- return self.tag_names[0]---class Element(Node):- tag = cobble.field()- children = cobble.field()-- @property- def tag_name(self):- return self.tag.tag_name-- @property- def tag_names(self):- return self.tag.tag_names-- @property- def attributes(self):- return self.tag.attributes-- @property- def collapsible(self):- return self.tag.collapsible-- @property- def separator(self):- return self.tag.separator-- _VOID_TAG_NAMES = set(["br", "hr", "img", "input"])-- def is_void(self):- return not self.children and self.tag_name in self._VOID_TAG_NAMES---class ForceWrite(Node):- pass---NodeVisitor = cobble.visitor(Node)diff --git a/mineru/model/utils/docx/mammoth/html_paths.py b/mineru/model/utils/docx/mammoth/html_paths.pydeleted file mode 100644index 4da5c058..00000000--- a/mineru/model/utils/docx/mammoth/html_paths.py+++ /dev/null@@ -1,58 +0,0 @@-import cobble--from . import html---def path(elements):- return HtmlPath(elements)---def element(names, attributes=None, class_names=None, fresh=None, separator=None):- if attributes is None:- attributes = {}- if class_names is None:- class_names = []- if fresh is None:- fresh = False- if class_names:- attributes["class"] = " ".join(class_names)-- return HtmlPathElement(html.tag(- tag_names=names,- attributes=attributes,- collapsible=not fresh,- separator=separator,- ))---class HtmlPath(object):- elements = cobble.field()-- def wrap(self, generate_nodes):- nodes = generate_nodes()-- for element in reversed(self.elements):- nodes = element.wrap_nodes(nodes)-- return nodes---class HtmlPathElement(object):- tag = cobble.field()-- def wrap(self, generate_nodes):- return self.wrap_nodes(generate_nodes())-- def wrap_nodes(self, nodes):- element = html.Element(self.tag, nodes)- return [element]--empty = path([])---class ignore(object):- @staticmethod- def wrap(generate_nodes):- return []diff --git a/mineru/model/utils/docx/mammoth/lists.py b/mineru/model/utils/docx/mammoth/lists.pydeleted file mode 100644index 90a6940d..00000000--- a/mineru/model/utils/docx/mammoth/lists.py+++ /dev/null@@ -1,40 +0,0 @@-import sys---def flatten(values):- return flat_map(lambda x: x, values)---def unique(values):- output = []- seen = set()- for value in values:- if value not in seen:- seen.add(value)- output.append(value)- return output---def flat_map(func, values):- return [- element- for value in values- for element in func(value)- ]---def find_index(predicate, values):- for index, value in enumerate(values):- if predicate(value):- return index---if sys.version_info[0] == 2:- map = map- filter = filter-else:- import builtins- def map(*args, **kwargs):- return list(builtins.map(*args, **kwargs))- def filter(*args, **kwargs):- return list(builtins.filter(*args, **kwargs))diff --git a/mineru/model/utils/docx/mammoth/office_xml.py b/mineru/model/utils/docx/mammoth/office_xml.pydeleted file mode 100644index ac8a6e20..00000000--- a/mineru/model/utils/docx/mammoth/office_xml.py+++ /dev/null@@ -1,48 +0,0 @@-from .lists import flat_map-from .xmlparser import parse_xml, XmlElement, parse_xml_str--_namespaces = [- # Transitional format- ("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main"),- ("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"),- ("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"),- ("a", "http://schemas.openxmlformats.org/drawingml/2006/main"),- ("pic", "http://schemas.openxmlformats.org/drawingml/2006/picture"),-- # Strict format- ("w", "http://purl.oclc.org/ooxml/wordprocessingml/main"),- ("r", "http://purl.oclc.org/ooxml/officeDocument/relationships"),- ("wp", "http://purl.oclc.org/ooxml/drawingml/wordprocessingDrawing"),- ("a", "http://purl.oclc.org/ooxml/drawingml/main"),- ("pic", "http://purl.oclc.org/ooxml/drawingml/picture"),-- # Common- ("content-types", "http://schemas.openxmlformats.org/package/2006/content-types"),- ("relationships", "http://schemas.openxmlformats.org/package/2006/relationships"),- ("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"),- ("v", "urn:schemas-microsoft-com:vml"),- ("office-word", "urn:schemas-microsoft-com:office:word"),-- # [MS-DOCX]: Word Extensions to the Office Open XML (.docx) File Format- # https://learn.microsoft.com/en-us/openspecs/office_standards/ms-docx/b839fe1f-e1ca-4fa6-8c26-5954d0abbccd- ("wordml", "http://schemas.microsoft.com/office/word/2010/wordml"),-]---def read(fileobj):- i = parse_xml(fileobj, _namespaces)- return _collapse_alternate_content(i)[0]--def read_str(xml_str):- i = parse_xml_str(xml_str, _namespaces)- return _collapse_alternate_content(i)[0]--def _collapse_alternate_content(node):- if isinstance(node, XmlElement):- if node.name == "mc:AlternateContent":- return node.find_child_or_null("mc:Fallback").children- else:- node.children = flat_map(_collapse_alternate_content, node.children)- return [node]- else:- return [node]diff --git a/mineru/model/utils/docx/mammoth/results.py b/mineru/model/utils/docx/mammoth/results.pydeleted file mode 100644index fb12ee33..00000000--- a/mineru/model/utils/docx/mammoth/results.py+++ /dev/null@@ -1,42 +0,0 @@-import collections--from .lists import unique---class Result(object):- def __init__(self, value, messages):- self.value = value- self.messages = unique(messages)-- def map(self, func):- return Result(func(self.value), self.messages)-- def bind(self, func):- result = func(self.value)- return Result(result.value, self.messages + result.messages)---Message = collections.namedtuple("Message", ["type", "message"])---def warning(message):- return Message("warning", message)---def success(value):- return Result(value, [])---def combine(results):- values = []- messages = []- for result in results:- values.append(result.value)- for message in result.messages:- messages.append(message)-- return Result(values, messages)---def map(func, *args):- return combine(args).map(lambda values: func(*values))diff --git a/mineru/model/utils/docx/mammoth/styles_xml.py b/mineru/model/utils/docx/mammoth/styles_xml.pydeleted file mode 100644index 31d0f2e0..00000000--- a/mineru/model/utils/docx/mammoth/styles_xml.py+++ /dev/null@@ -1,117 +0,0 @@-import collections---class Styles(object):- @staticmethod- def create(paragraph_styles=None, character_styles=None, table_styles=None, numbering_styles=None):- if paragraph_styles is None:- paragraph_styles = {}- if character_styles is None:- character_styles = {}- if table_styles is None:- table_styles = {}- if numbering_styles is None:- numbering_styles = {}-- return Styles(- paragraph_styles=paragraph_styles,- character_styles=character_styles,- table_styles=table_styles,- numbering_styles=numbering_styles,- )-- def __init__(self, paragraph_styles, character_styles, table_styles, numbering_styles):- self._paragraph_styles = paragraph_styles- self._character_styles = character_styles- self._table_styles = table_styles- self._numbering_styles = numbering_styles-- def find_paragraph_style_by_id(self, style_id):- return self._paragraph_styles.get(style_id)-- def find_character_style_by_id(self, style_id):- return self._character_styles.get(style_id)-- def find_table_style_by_id(self, style_id):- return self._table_styles.get(style_id)-- def find_numbering_style_by_id(self, style_id):- return self._numbering_styles.get(style_id)---Styles.EMPTY = Styles(- paragraph_styles={},- character_styles={},- table_styles={},- numbering_styles={},-)---def read_styles_xml_element(element):- paragraph_styles = {}- character_styles = {}- table_styles = {}- numbering_styles = {}- styles = {- "paragraph": paragraph_styles,- "character": character_styles,- "table": table_styles,- "numbering": numbering_styles,- }-- for style_element in element.find_children("w:style"):- element_type = style_element.attributes["w:type"]- if element_type == "numbering":- style = _read_numbering_style_element(style_element)- else:- style = _read_style_element(style_element)-- style_set = styles.get(element_type)-- # Per 17.7.4.17 style (Style Definition) of ECMA-376 4th edition Part 1:- #- # > If multiple style definitions each declare the same value for their- # > styleId, then the first such instance shall keep its current- # > identifier with all other instances being reassigned in any manner- # > desired.- #- # For the purpose of conversion, there's no point holding onto styles- # with reassigned style IDs, so we ignore such style definitions.-- if style_set is not None and style.style_id not in style_set:- style_set[style.style_id] = style-- return Styles(- paragraph_styles=paragraph_styles,- character_styles=character_styles,- table_styles=table_styles,- numbering_styles=numbering_styles,- )---Style = collections.namedtuple("Style", ["style_id", "name"])---def _read_style_element(element):- style_id = _read_style_id(element)- name = element.find_child_or_null("w:name").attributes.get("w:val")- return Style(style_id=style_id, name=name)---NumberingStyle = collections.namedtuple("NumberingStyle", ["style_id", "num_id"])---def _read_numbering_style_element(element):- style_id = _read_style_id(element)-- num_id = element \- .find_child_or_null("w:pPr") \- .find_child_or_null("w:numPr") \- .find_child_or_null("w:numId") \- .attributes.get("w:val")-- return NumberingStyle(style_id=style_id, num_id=num_id)---def _read_style_id(element):- return element.attributes["w:styleId"]diff --git a/mineru/model/utils/docx/mammoth/transforms.py b/mineru/model/utils/docx/mammoth/transforms.pydeleted file mode 100644index c03bace2..00000000--- a/mineru/model/utils/docx/mammoth/transforms.py+++ /dev/null@@ -1,56 +0,0 @@-from . import documents---def paragraph(transform_paragraph):- return element_of_type(documents.Paragraph, transform_paragraph)---def run(transform_run):- return element_of_type(documents.Run, transform_run)---def element_of_type(element_type, transform):- def transform_element(element):- if isinstance(element, element_type):- return transform(element)- else:- return element-- return _each_element(transform_element)---def _each_element(transform_element):- def transform_element_and_children(element):- if isinstance(element, (documents.HasChildren, documents.TableCellUnmerged)):- children = list(map(transform_element_and_children, element.children))- element = element.copy(children=children)-- return transform_element(element)-- return transform_element_and_children---def get_descendants_of_type(element, element_type):- return list(filter(- lambda descendant: isinstance(descendant, element_type),- get_descendants(element),- ))---def get_descendants(element):- descendants = []-- def visit(element):- descendants.append(element)-- _visit_descendants(element, visit)-- return descendants---def _visit_descendants(element, visit):- if isinstance(element, documents.HasChildren):- for child in element.children:- _visit_descendants(child, visit)- visit(child)-diff --git a/mineru/model/utils/docx/mammoth/uris.py b/mineru/model/utils/docx/mammoth/uris.pydeleted file mode 100644index 255dabe2..00000000--- a/mineru/model/utils/docx/mammoth/uris.py+++ /dev/null@@ -1,12 +0,0 @@-def uri_to_zip_entry_name(base, uri):- if uri.startswith("/"):- return uri[1:]- else:- return base + "/" + uri---def replace_fragment(uri, fragment):- hash_index = uri.find("#")- if hash_index != -1:- uri = uri[:hash_index]- return uri + "#" + fragmentdiff --git a/mineru/model/utils/docx/mammoth/writers/__init__.py b/mineru/model/utils/docx/mammoth/writers/__init__.pydeleted file mode 100644index 08ac3a88..00000000--- a/mineru/model/utils/docx/mammoth/writers/__init__.py+++ /dev/null@@ -1,19 +0,0 @@-from .html import HtmlWriter-from .markdown import MarkdownWriter---def writer(output_format=None):- if output_format is None:- output_format = "html"-- return _writers[output_format]()---def formats():- return _writers.keys()---_writers = {- "html": HtmlWriter,- "markdown": MarkdownWriter,-}diff --git a/mineru/model/utils/docx/mammoth/writers/abc.py b/mineru/model/utils/docx/mammoth/writers/abc.pydeleted file mode 100644index 48358221..00000000--- a/mineru/model/utils/docx/mammoth/writers/abc.py+++ /dev/null@@ -1,31 +0,0 @@-from __future__ import absolute_import--import abc---class Writer(object):- __metaclass__ = abc.ABCMeta-- @abc.abstractmethod- def text(self, text):- pass-- @abc.abstractmethod- def start(self, name, attributes=None):- pass-- @abc.abstractmethod- def end(self, name):- pass-- @abc.abstractmethod- def self_closing(self, name, attributes=None):- pass-- @abc.abstractmethod- def append(self, html):- pass-- @abc.abstractmethod- def as_string(self):- passdiff --git a/mineru/model/utils/docx/mammoth/writers/html.py b/mineru/model/utils/docx/mammoth/writers/html.pydeleted file mode 100644index 53eb9201..00000000--- a/mineru/model/utils/docx/mammoth/writers/html.py+++ /dev/null@@ -1,43 +0,0 @@-from __future__ import unicode_literals-from xml.sax.saxutils import escape--from .abc import Writer---class HtmlWriter(Writer):- def __init__(self):- self._fragments = []-- def text(self, text):- self._fragments.append(_escape_html(text))-- def start(self, name, attributes=None):- attribute_string = _generate_attribute_string(attributes)- self._fragments.append("<{0}{1}>".format(name, attribute_string))-- def end(self, name):- self._fragments.append("</{0}>".format(name))-- def self_closing(self, name, attributes=None):- attribute_string = _generate_attribute_string(attributes)- self._fragments.append("<{0}{1} />".format(name, attribute_string))-- def append(self, html):- self._fragments.append(html)-- def as_string(self):- return "".join(self._fragments)---def _escape_html(text):- return escape(text, {'"': """})---def _generate_attribute_string(attributes):- if attributes is None:- return ""- else:- return "".join(- ' {0}="{1}"'.format(key, _escape_html(attributes[key]))- for key in sorted(attributes)- )diff --git a/mineru/model/utils/docx/mammoth/writers/markdown.py b/mineru/model/utils/docx/mammoth/writers/markdown.pydeleted file mode 100644index 7c203c2e..00000000--- a/mineru/model/utils/docx/mammoth/writers/markdown.py+++ /dev/null@@ -1,203 +0,0 @@-from __future__ import unicode_literals--from .abc import Writer--import re---class _WriterOutput(object):- def __init__(self, start, end=None, generate_end=None, anchor_position=None):- if generate_end is None:- generate_end = _constant(end)-- self.start = start- self.generate_end = generate_end- self.anchor_position = anchor_position---def _constant(value):- def get():- return value-- return get---class _MarkdownState(object):- def __init__(self):- self._list_state_stack = []- self.list_state = None- self.list_item_has_closed = False-- def update_list_state(self, list_state):- self._list_state_stack.append(self.list_state)- self.list_state = list_state-- def pop_list_state(self):- self.list_state = self._list_state_stack.pop()---class _MarkdownListState(object):- def __init__(self, ordered, indentation):- self.ordered = ordered- self.count = 0- self.indentation = indentation---def _symmetric_wrapped(end):- return _Wrapped(end, end)---class _Wrapped(object):- def __init__(self, start, end):- self._start = start- self._end = end-- def __call__(self, attributes, markdown_state):- return _WriterOutput(self._start, self._end)---def _hyperlink(attributes, markdown_state):- href = attributes.get("href", "")- if href:- return _WriterOutput(- "[", "]({0})".format(href),- anchor_position="before",- )- else:- return _default_output---def _image(attributes, markdown_state):- src = attributes.get("src", "")- alt_text = attributes.get("alt", "")- if src or alt_text:- return _WriterOutput("".format(alt_text, src), "")- else:- return _default_output---def _list(ordered):- def call(attributes, markdown_state):- if markdown_state.list_state is None:- start = ""- end_text = "\n"- indentation = 0- else:- start = "\n"- end_text = ""- indentation = markdown_state.list_state.indentation + 1-- def generate_end():- markdown_state.pop_list_state()- return end_text-- markdown_state.update_list_state(_MarkdownListState(- ordered=ordered,- indentation=indentation,- ))-- return _WriterOutput(start, generate_end=generate_end)-- return call---def _list_item(attributes, markdown_state):- markdown_state.list_item_has_closed = False-- list_state = markdown_state.list_state or _MarkdownListState(ordered=False, indentation=0)- list_state.count += 1-- if list_state.ordered:- bullet = "{0}.".format(list_state.count)- else:- bullet = "-"-- def generate_end():- if markdown_state.list_item_has_closed:- return ""- else:- markdown_state.list_item_has_closed = True- return "\n"-- return _WriterOutput(- start=("\t" * list_state.indentation) + bullet + " ",- generate_end=generate_end- )---def _init_writers():- writers = {- "p": _Wrapped("", "\n\n"),- "br": _Wrapped("", " \n"),- "strong": _symmetric_wrapped("__"),- "em": _symmetric_wrapped("*"),- "a": _hyperlink,- "img": _image,- "ol": _list(ordered=True),- "ul": _list(ordered=False),- "li": _list_item,- }-- for level in range(1, 7):- writers["h{0}".format(level)] = _Wrapped("#" * level + " ", "\n\n")-- return writers---_writers = _init_writers()-_default_output = _WriterOutput("", "")--def _default_writer(attributes, markdown_state):- return _default_output---class MarkdownWriter(Writer):- def __init__(self):- self._fragments = []- self._element_stack = []- self._markdown_state = _MarkdownState()-- def text(self, text):- self._fragments.append(_escape_markdown(text))-- def start(self, name, attributes=None):- if attributes is None:- attributes = {}-- output = _writers.get(name, _default_writer)(attributes, self._markdown_state)- self._element_stack.append(output.generate_end)-- anchor_before_start = output.anchor_position == "before"- if anchor_before_start:- self._write_anchor(attributes)-- self._fragments.append(output.start)-- if not anchor_before_start:- self._write_anchor(attributes)---- def end(self, name):- end = self._element_stack.pop()- output = end()- self._fragments.append(output)-- def self_closing(self, name, attributes=None):- self.start(name, attributes)- self.end(name)-- def append(self, other):- self._fragments.append(other)-- def as_string(self):- return "".join(self._fragments)-- def _write_anchor(self, attributes):- html_id = attributes.get("id")- if html_id:- self._fragments.append('<a id="{0}"></a>'.format(html_id))---def _escape_markdown(value):- return re.sub(r"([\`\*_\{\}\[\]\(\)\#\+\-\.\!])", r"\\\1", re.sub("\\\\", "\\\\\\\\", value))diff --git a/mineru/model/utils/docx/mammoth/xmlparser.py b/mineru/model/utils/docx/mammoth/xmlparser.pydeleted file mode 100644index abbc0790..00000000--- a/mineru/model/utils/docx/mammoth/xmlparser.py+++ /dev/null@@ -1,167 +0,0 @@-import xml.dom.minidom--import cobble---class XmlElement(object):- name = cobble.field()- attributes = cobble.field()- children = cobble.field()-- def find_child_or_null(self, name):- return self.find_child(name) or null_xml_element-- def find_child(self, name):- for child in self.children:- if isinstance(child, XmlElement) and child.name == name:- return child--- def find_children(self, name):- return XmlElementList(filter(- lambda child: child.node_type == node_types.element and child.name == name,- self.children- ))---class XmlElementList(object):- def __init__(self, elements):- self._elements = elements-- def __iter__(self):- return iter(self._elements)-- def find_children(self, name):- children = []- for element in self._elements:- for child in element.find_children(name):- children.append(child)- return XmlElementList(children)---class NullXmlElement(object):- attributes = {}- children = []-- def find_child_or_null(self, name):- return self-- def find_child(self, name):- return None---null_xml_element = NullXmlElement()---class XmlText(object):- value = cobble.field()---def element(name, attributes=None, children=None):- return XmlElement(name, attributes or {}, children or [])--text = XmlText---class node_types(object):- element = 1- text = 3---XmlElement.node_type = node_types.element-XmlText.node_type = node_types.text----def parse_xml(fileobj, namespace_mapping=None):- if namespace_mapping is None:- namespace_prefixes = {}- else:- namespace_prefixes = dict((uri, prefix) for prefix, uri in namespace_mapping)-- document = xml.dom.minidom.parse(fileobj)-- def convert_node(node):- if node.nodeType == xml.dom.Node.ELEMENT_NODE:- return convert_element(node)- elif node.nodeType == xml.dom.Node.TEXT_NODE:- return XmlText(node.nodeValue)- else:- return None-- def convert_element(element):- converted_name = convert_name(element)-- converted_attributes = dict(- (convert_name(attribute), attribute.value)- for attribute in element.attributes.values()- if attribute.namespaceURI != "http://www.w3.org/2000/xmlns/"- )-- converted_children = []- for child_node in element.childNodes:- converted_child_node = convert_node(child_node)- if converted_child_node is not None:- converted_children.append(converted_child_node)-- return XmlElement(converted_name, converted_attributes, converted_children)-- def convert_name(node):- if node.namespaceURI is None:- return node.localName- else:- prefix = namespace_prefixes.get(node.namespaceURI)- if prefix is None:- return "{%s}%s" % (node.namespaceURI, node.localName)- else:- return "%s:%s" % (prefix, node.localName)-- return convert_node(document.documentElement)---def parse_xml_str(xml_str, namespace_mapping=None):- if namespace_mapping is None:- namespace_prefixes = {}- else:- namespace_prefixes = dict((uri, prefix) for prefix, uri in namespace_mapping)-- document = xml.dom.minidom.parseString(xml_str)-- def convert_node(node):- if node.nodeType == xml.dom.Node.ELEMENT_NODE:- return convert_element(node)- elif node.nodeType == xml.dom.Node.TEXT_NODE:- return XmlText(node.nodeValue)- else:- return None-- def convert_element(element):- converted_name = convert_name(element)-- converted_attributes = dict(- (convert_name(attribute), attribute.value)- for attribute in element.attributes.values()- if attribute.namespaceURI != "http://www.w3.org/2000/xmlns/"- )-- converted_children = []- for child_node in element.childNodes:- converted_child_node = convert_node(child_node)- if converted_child_node is not None:- converted_children.append(converted_child_node)-- return XmlElement(converted_name, converted_attributes, converted_children)-- def convert_name(node):- if node.namespaceURI is None:- return node.localName- else:- prefix = namespace_prefixes.get(node.namespaceURI)- if prefix is None:- return "{%s}%s" % (node.namespaceURI, node.localName)- else:- return "%s:%s" % (prefix, node.localName)-- return convert_node(document.documentElement)diff --git a/mineru/model/utils/docx/math/__init__.py b/mineru/model/utils/docx/math/__init__.pydeleted file mode 100644index e69de29b..00000000diff --git a/mineru/model/utils/docx/pre_process.py b/mineru/model/utils/docx/pre_process.pydeleted file mode 100644index d5102ce6..00000000--- a/mineru/model/utils/docx/pre_process.py+++ /dev/null@@ -1,169 +0,0 @@-import zipfile-from io import BytesIO-from typing import BinaryIO-from xml.etree import ElementTree as ET--from bs4 import BeautifulSoup, Tag--from .math.omml import OMML_NS, oMath2Latex--MATH_ROOT_TEMPLATE = "".join(- (- "<w:document ",- 'xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" ',- 'xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" ',- 'xmlns:o="urn:schemas-microsoft-com:office:office" ',- 'xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" ',- 'xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" ',- 'xmlns:v="urn:schemas-microsoft-com:vml" ',- 'xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" ',- 'xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" ',- 'xmlns:w10="urn:schemas-microsoft-com:office:word" ',- 'xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" ',- 'xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" ',- 'xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" ',- 'xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" ',- 'xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" ',- 'xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 wp14">',- "{0}</w:document>",- )-)---def _convert_omath_to_latex(tag: Tag) -> str:- """- Converts an OMML (Office Math Markup Language) tag to LaTeX format.-- Args:- tag (Tag): A BeautifulSoup Tag object representing the OMML element.-- Returns:- str: The LaTeX representation of the OMML element.- """- # Format the tag into a complete XML document string- math_root = ET.fromstring(MATH_ROOT_TEMPLATE.format(str(tag)))- # Find the 'oMath' element within the XML document- math_element = math_root.find(OMML_NS + "oMath")- # Convert the 'oMath' element to LaTeX using the oMath2Latex function- latex = oMath2Latex(math_element).latex- return latex---def _get_omath_tag_replacement(tag: Tag, block: bool = False) -> Tag:- """- Creates a replacement tag for an OMML (Office Math Markup Language) element.-- Args:- tag (Tag): A BeautifulSoup Tag object representing the "oMath" element.- block (bool, optional): If True, the LaTeX will be wrapped in double dollar signs for block mode. Defaults to False.-- Returns:- Tag: A BeautifulSoup Tag object representing the replacement element.- """- t_tag = Tag(name="w:t")- t_tag.string = (- f"$${_convert_omath_to_latex(tag)}$$"- if block- else f"${_convert_omath_to_latex(tag)}$"- )- r_tag = Tag(name="w:r")- r_tag.append(t_tag)- return r_tag---def _replace_equations(tag: Tag):- """- Replaces OMML (Office Math Markup Language) elements with their LaTeX equivalents.-- Args:- tag (Tag): A BeautifulSoup Tag object representing the OMML element. Could be either "oMathPara" or "oMath".-- Raises:- ValueError: If the tag is not supported.- """- if tag.name == "oMathPara":- # Create a new paragraph tag- p_tag = Tag(name="w:p")- # Replace each 'oMath' child tag with its LaTeX equivalent as block equations- for child_tag in tag.find_all("oMath"):- p_tag.append(_get_omath_tag_replacement(child_tag, block=True))- # Replace the original 'oMathPara' tag with the new paragraph tag- tag.replace_with(p_tag)- elif tag.name == "oMath":- # Replace the 'oMath' tag with its LaTeX equivalent as inline equation- tag.replace_with(_get_omath_tag_replacement(tag, block=False))- else:- raise ValueError(f"Not supported tag: {tag.name}")---def _pre_process_math(content: bytes) -> bytes:- """- Pre-processes the math content in a DOCX -> XML file by converting OMML (Office Math Markup Language) elements to LaTeX.- This preprocessed content can be directly replaced in the DOCX file -> XMLs.-- Args:- content (bytes): The XML content of the DOCX file as bytes.-- Returns:- bytes: The processed content with OMML elements replaced by their LaTeX equivalents, encoded as bytes.- """- soup = BeautifulSoup(content.decode(), features="xml")- for tag in soup.find_all("oMathPara"):- _replace_equations(tag)- for tag in soup.find_all("oMath"):- _replace_equations(tag)- return str(soup).encode()---def pre_process_docx(input_docx: BinaryIO) -> BinaryIO:- """- 预处理DOCX文件,执行指定的处理步骤。-- 处理过程包括:在内存中解压DOCX文件,转换特定的XML文件(如将OMML元素转换为LaTeX),- 然后将所有内容重新打包成一个新的DOCX文件,整个过程不写入磁盘。-- Args:- input_docx (BinaryIO): 表示DOCX文件的二进制输入流。-- Returns:- BinaryIO: 表示已处理DOCX文件的二进制输出流。- """- # 创建用于存储输出DOCX文件的BytesIO对象- output_docx = BytesIO()-- # 定义需要预处理的文件列表- pre_process_enable_files = [- "word/document.xml", # 主文档内容- "word/footnotes.xml", # 脚注- "word/endnotes.xml", # 尾注- ]-- # 读取输入的DOCX文件(ZIP格式)- with zipfile.ZipFile(input_docx, mode="r") as zip_input:- # 提取所有文件到内存字典中- files = {name: zip_input.read(name) for name in zip_input.namelist()}-- # 创建新的ZIP文件用于输出- with zipfile.ZipFile(output_docx, mode="w") as zip_output:- # 保留原始ZIP文件的注释- zip_output.comment = zip_input.comment-- # 遍历所有文件- for name, content in files.items():- # 检查文件是否需要预处理- if name in pre_process_enable_files:- try:- # 对指定文件执行数学公式预处理(OMML转LaTeX)- updated_content = _pre_process_math(content)- # 将处理后的内容写入输出文件- zip_output.writestr(name, updated_content)- except Exception:- # 如果处理过程中出现异常,保留原始内容- zip_output.writestr(name, content)- else:- # 不需要处理的文件直接复制- zip_output.writestr(name, content)-- # 将文件指针移到开头,准备返回- output_docx.seek(0)- return output_docxdiff --git a/pyproject.toml b/pyproject.tomlindex f1a5bfdc..f48971c7 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -43,6 +43,7 @@ dependencies = ["qwen-vl-utils>=0.0.14,<1","defusedxml>=0.7.1,<1","python-docx>=1.2.0,<2",+ "mammoth>=1.11.0,<2",][project.optional-dependencies]