Datasets:
Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- FinixDocBench_Eval_for_Markdown/examples/gt/sample_001.md +10 -0
- FinixDocBench_Eval_for_Markdown/examples/pred/sample_001.md +10 -0
- FinixDocBench_Eval_for_Markdown/finixdoc_md_eval/__init__.py +0 -0
- FinixDocBench_Eval_for_Markdown/finixdoc_md_eval/metrics/__init__.py +0 -0
- FinixDocBench_Eval_for_Markdown/finixdoc_md_eval/metrics/table_metric.py +260 -0
- FinixDocBench_Eval_for_Markdown/finixdoc_md_eval/omnidocbench_adapter.py +226 -0
- FinixDocBench_Eval_for_Markdown/finixdoc_md_eval/utils/__init__.py +0 -0
- FinixDocBench_Eval_for_Markdown/finixdoc_md_eval/utils/data_preprocess.py +452 -0
- FinixDocBench_Eval_for_Markdown/finixdoc_md_eval/utils/extract.py +571 -0
- FinixDocBench_Eval_for_Markdown/finixdoc_md_eval/utils/match.py +310 -0
- FinixDocBench_Eval_for_Markdown/finixdoc_md_eval/utils/match_quick.py +1292 -0
- FinixDocBench_Eval_for_Markdown/finixdoc_md_eval/utils/table_utils.py +100 -0
- track2_finixphoto_300/mds/00c07dff-e570-5c66-9caa-37b6254d859c.md +47 -0
- track2_finixphoto_300/mds/00cedd70-e693-42ac-855f-d8f9b0ccf8f3.md +61 -0
- track2_finixphoto_300/mds/00e93638-9af3-4bca-b249-c414440b54dd.md +53 -0
- track2_finixphoto_300/mds/0170086d-957e-4ec2-b505-92cece37d302.md +52 -0
- track2_finixphoto_300/mds/0428c7d7-8d44-403a-8f16-c244fd488f86.md +98 -0
- track2_finixphoto_300/mds/0704a982-8416-4d2f-a2b1-f10506301d50.md +25 -0
- track2_finixphoto_300/mds/0809dc84-f135-411e-9459-8d69bda2c15e.md +43 -0
- track2_finixphoto_300/mds/08605a96-3a7d-4fad-9f0a-bfb3e5105d39.md +35 -0
- track2_finixphoto_300/mds/09c2592b-a278-4bf9-99ba-4c7fbc91bb5d.md +76 -0
- track2_finixphoto_300/mds/0b270427-6cba-48f7-93cc-aab09ab25784.md +55 -0
- track2_finixphoto_300/mds/0b6a9275-725c-4f4b-873c-a20af0ed0ec8.md +53 -0
- track2_finixphoto_300/mds/0c84a961-ddfe-4c95-84c6-2cee1f9d7bff.md +46 -0
- track2_finixphoto_300/mds/0d3c3350-3db0-5dc3-8c69-03a8c4a10185.md +32 -0
- track2_finixphoto_300/mds/0f1638f7-bfc1-4d10-847a-c335659af13a.md +54 -0
- track2_finixphoto_300/mds/0ff98c5a-5d36-4bb7-bfa8-aa408d548f21.md +27 -0
- track2_finixphoto_300/mds/1290989e-ba23-46e9-adab-802a00fb3472.md +75 -0
- track2_finixphoto_300/mds/12adc3bc-a164-4791-94ce-7ecc9845d407.md +39 -0
- track2_finixphoto_300/mds/12e1b36e-6f63-52e0-9d2c-fb5660dca9a4.md +45 -0
- track2_finixphoto_300/mds/130a7f45-b7f6-4304-b276-5ebe82f3a1de.md +83 -0
- track2_finixphoto_300/mds/13eedc25-e64d-4110-9bd5-e39a8a7508c7.md +65 -0
- track2_finixphoto_300/mds/15fbe32f-5851-45ee-9247-9932d9cda3e2.md +55 -0
- track2_finixphoto_300/mds/16cd5c50-5086-5fbe-a1a6-7e7be304140a.md +15 -0
- track2_finixphoto_300/mds/1721a339-a34a-4f54-bc61-3c4ec1dcf09d.md +40 -0
- track2_finixphoto_300/mds/17431f4c-4db9-4ced-bee1-e8c24d8df3e1.md +53 -0
- track2_finixphoto_300/mds/1833ad18-dc1d-486b-8c59-7e9b89eb56f1.md +35 -0
- track2_finixphoto_300/mds/19b3a90a-8cb6-40c6-b30e-40860f27c8b8.md +58 -0
- track2_finixphoto_300/mds/19bccfb7-9af9-48f7-b0c6-a559afcf80d8.md +73 -0
- track2_finixphoto_300/mds/1a8ba629-13ba-4b18-bcc7-4eeb2b0866f3.md +47 -0
- track2_finixphoto_300/mds/1a9f3b5a-8234-430a-a723-ea082ecb77ee.md +56 -0
- track2_finixphoto_300/mds/1b6fdf72-97d5-4435-a9f3-1152d426aad0.md +55 -0
- track2_finixphoto_300/mds/1f61fb07-32c0-4a57-a725-458ef0d0d3f9.md +64 -0
- track2_finixphoto_300/mds/208198de-2044-50ca-8f1b-d3a7b588b352.md +65 -0
- track2_finixphoto_300/mds/2090cf59-a30e-47b0-81a9-489e8e6a6063.md +47 -0
- track2_finixphoto_300/mds/20a85e8b-2f46-595f-b3e7-01d34f606fac.md +65 -0
- track2_finixphoto_300/mds/213b444f-95ca-41a3-92df-2bd8a0374f83.md +77 -0
- track2_finixphoto_300/mds/23c733e1-ca08-41a9-a080-cb680f396da9.md +41 -0
- track2_finixphoto_300/mds/24605939-36d9-49ba-89f5-111934063fb1.md +34 -0
- track2_finixphoto_300/mds/27c01a18-e2eb-4735-852d-c367d44fdc82.md +61 -0
FinixDocBench_Eval_for_Markdown/examples/gt/sample_001.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Sample Insurance Clause
|
| 2 |
+
|
| 3 |
+
The policy covers accidental medical expenses during the insurance period.
|
| 4 |
+
|
| 5 |
+
<table>
|
| 6 |
+
<tr><td>Item</td><td>Limit</td></tr>
|
| 7 |
+
<tr><td>Medical</td><td>10000</td></tr>
|
| 8 |
+
</table>
|
| 9 |
+
|
| 10 |
+
Final note.
|
FinixDocBench_Eval_for_Markdown/examples/pred/sample_001.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Sample Insurance Clause
|
| 2 |
+
|
| 3 |
+
The policy covers accidental medical expense during the insurance period.
|
| 4 |
+
|
| 5 |
+
<table>
|
| 6 |
+
<tr><td>Item</td><td>Limit</td></tr>
|
| 7 |
+
<tr><td>Medical</td><td>9000</td></tr>
|
| 8 |
+
</table>
|
| 9 |
+
|
| 10 |
+
Final note.
|
FinixDocBench_Eval_for_Markdown/finixdoc_md_eval/__init__.py
ADDED
|
File without changes
|
FinixDocBench_Eval_for_Markdown/finixdoc_md_eval/metrics/__init__.py
ADDED
|
File without changes
|
FinixDocBench_Eval_for_Markdown/finixdoc_md_eval/metrics/table_metric.py
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2020 IBM
|
| 2 |
+
# Author: peter.zhong@au1.ibm.com
|
| 3 |
+
#
|
| 4 |
+
# This is free software; you can redistribute it and/or modify
|
| 5 |
+
# it under the terms of the Apache 2.0 License.
|
| 6 |
+
#
|
| 7 |
+
# This software is distributed in the hope that it will be useful,
|
| 8 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
# Apache 2.0 License for more details.
|
| 11 |
+
|
| 12 |
+
import Levenshtein
|
| 13 |
+
# import rapidfuzz.distance as distance
|
| 14 |
+
from apted import APTED, Config
|
| 15 |
+
from apted.helpers import Tree
|
| 16 |
+
from lxml import etree, html
|
| 17 |
+
from collections import deque
|
| 18 |
+
# from parallel import parallel_process
|
| 19 |
+
from tqdm import tqdm
|
| 20 |
+
|
| 21 |
+
class TableTree(Tree):
|
| 22 |
+
def __init__(self, tag, colspan=None, rowspan=None, content=None, *children):
|
| 23 |
+
self.tag = tag
|
| 24 |
+
self.colspan = colspan
|
| 25 |
+
self.rowspan = rowspan
|
| 26 |
+
self.content = content
|
| 27 |
+
self.children = list(children)
|
| 28 |
+
|
| 29 |
+
def bracket(self):
|
| 30 |
+
"""Show tree using brackets notation"""
|
| 31 |
+
if self.tag == 'td':
|
| 32 |
+
result = '"tag": %s, "colspan": %d, "rowspan": %d, "text": %s' % \
|
| 33 |
+
(self.tag, self.colspan, self.rowspan, self.content)
|
| 34 |
+
else:
|
| 35 |
+
result = '"tag": %s' % self.tag
|
| 36 |
+
for child in self.children:
|
| 37 |
+
result += child.bracket()
|
| 38 |
+
return "{{{}}}".format(result)
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
class CustomConfig(Config):
|
| 42 |
+
@staticmethod
|
| 43 |
+
def maximum(*sequences):
|
| 44 |
+
"""Get maximum possible value
|
| 45 |
+
"""
|
| 46 |
+
return max(map(len, sequences))
|
| 47 |
+
|
| 48 |
+
def normalized_distance(self, *sequences):
|
| 49 |
+
"""Get distance from 0 to 1
|
| 50 |
+
"""
|
| 51 |
+
return float(Levenshtein.distance(*sequences)) / self.maximum(*sequences)
|
| 52 |
+
|
| 53 |
+
def rename(self, node1, node2):
|
| 54 |
+
"""Compares attributes of trees"""
|
| 55 |
+
if (node1.tag != node2.tag) or (node1.colspan != node2.colspan) or (node1.rowspan != node2.rowspan):
|
| 56 |
+
return 1.
|
| 57 |
+
if node1.tag == 'td':
|
| 58 |
+
if node1.content or node2.content:
|
| 59 |
+
return self.normalized_distance(node1.content, node2.content)
|
| 60 |
+
return 0.
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
class TEDS(object):
|
| 64 |
+
''' Tree Edit Distance basead Similarity
|
| 65 |
+
'''
|
| 66 |
+
def __init__(self, structure_only=False, n_jobs=16, ignore_nodes=None):
|
| 67 |
+
assert isinstance(n_jobs, int) and (n_jobs >= 1), 'n_jobs must be an integer greather than 1'
|
| 68 |
+
self.structure_only = structure_only
|
| 69 |
+
self.n_jobs = n_jobs
|
| 70 |
+
self.ignore_nodes = ignore_nodes
|
| 71 |
+
self.__tokens__ = []
|
| 72 |
+
|
| 73 |
+
def tokenize(self, node):
|
| 74 |
+
''' Tokenizes table cells
|
| 75 |
+
'''
|
| 76 |
+
self.__tokens__.append('<%s>' % node.tag)
|
| 77 |
+
if node.text is not None:
|
| 78 |
+
self.__tokens__ += list(node.text)
|
| 79 |
+
for n in node.getchildren():
|
| 80 |
+
self.tokenize(n)
|
| 81 |
+
if node.tag != 'unk':
|
| 82 |
+
self.__tokens__.append('</%s>' % node.tag)
|
| 83 |
+
if node.tag != 'td' and node.tail is not None:
|
| 84 |
+
self.__tokens__ += list(node.tail)
|
| 85 |
+
|
| 86 |
+
def load_html_tree(self, node, parent=None):
|
| 87 |
+
''' Converts HTML tree to the format required by apted
|
| 88 |
+
'''
|
| 89 |
+
global __tokens__
|
| 90 |
+
if node.tag == 'td':
|
| 91 |
+
if self.structure_only:
|
| 92 |
+
cell = []
|
| 93 |
+
else:
|
| 94 |
+
self.__tokens__ = []
|
| 95 |
+
self.tokenize(node)
|
| 96 |
+
cell = self.__tokens__[1:-1].copy()
|
| 97 |
+
new_node = TableTree(node.tag,
|
| 98 |
+
int(node.attrib.get('colspan', '1')),
|
| 99 |
+
int(node.attrib.get('rowspan', '1')),
|
| 100 |
+
cell, *deque())
|
| 101 |
+
else:
|
| 102 |
+
new_node = TableTree(node.tag, None, None, None, *deque())
|
| 103 |
+
if parent is not None:
|
| 104 |
+
parent.children.append(new_node)
|
| 105 |
+
if node.tag != 'td':
|
| 106 |
+
for n in node.getchildren():
|
| 107 |
+
self.load_html_tree(n, new_node)
|
| 108 |
+
if parent is None:
|
| 109 |
+
return new_node
|
| 110 |
+
|
| 111 |
+
# def evaluate(self, pred, true):
|
| 112 |
+
# ''' Computes TEDS score between the prediction and the ground truth of a
|
| 113 |
+
# given sample
|
| 114 |
+
# '''
|
| 115 |
+
# if (not pred) or (not true):
|
| 116 |
+
# return 0.0
|
| 117 |
+
# parser = html.HTMLParser(remove_comments=True, encoding='utf-8')
|
| 118 |
+
# pred = html.fromstring(pred, parser=parser)
|
| 119 |
+
# true = html.fromstring(true, parser=parser)
|
| 120 |
+
# if pred.xpath('body/table') and true.xpath('body/table'):
|
| 121 |
+
# pred = pred.xpath('body/table')[0]
|
| 122 |
+
# true = true.xpath('body/table')[0]
|
| 123 |
+
# if self.ignore_nodes:
|
| 124 |
+
# etree.strip_tags(pred, *self.ignore_nodes)
|
| 125 |
+
# etree.strip_tags(true, *self.ignore_nodes)
|
| 126 |
+
# n_nodes_pred = len(pred.xpath(".//*"))
|
| 127 |
+
# n_nodes_true = len(true.xpath(".//*"))
|
| 128 |
+
# n_nodes = max(n_nodes_pred, n_nodes_true)
|
| 129 |
+
# tree_pred = self.load_html_tree(pred)
|
| 130 |
+
# tree_true = self.load_html_tree(true)
|
| 131 |
+
# distance = APTED(tree_pred, tree_true, CustomConfig()).compute_edit_distance()
|
| 132 |
+
# return 1.0 - (float(distance) / n_nodes)
|
| 133 |
+
# else:
|
| 134 |
+
# return 0.0
|
| 135 |
+
# def evaluate(self, pred, true):
|
| 136 |
+
# ''' Computes TEDS score between the prediction and the ground truth of a
|
| 137 |
+
# given sample
|
| 138 |
+
# '''
|
| 139 |
+
# from multiprocessing import Process, Queue
|
| 140 |
+
# import sys
|
| 141 |
+
|
| 142 |
+
# def _evaluate_inner(pred, true, queue):
|
| 143 |
+
# try:
|
| 144 |
+
# if (not pred) or (not true):
|
| 145 |
+
# queue.put(0.0)
|
| 146 |
+
# return
|
| 147 |
+
|
| 148 |
+
# parser = html.HTMLParser(remove_comments=True, encoding='utf-8')
|
| 149 |
+
# pred_doc = html.fromstring(pred, parser=parser)
|
| 150 |
+
# true_doc = html.fromstring(true, parser=parser)
|
| 151 |
+
|
| 152 |
+
# if pred_doc.xpath('body/table') and true_doc.xpath('body/table'):
|
| 153 |
+
# pred_table = pred_doc.xpath('body/table')[0]
|
| 154 |
+
# true_table = true_doc.xpath('body/table')[0]
|
| 155 |
+
# if self.ignore_nodes:
|
| 156 |
+
# etree.strip_tags(pred_table, *self.ignore_nodes)
|
| 157 |
+
# etree.strip_tags(true_table, *self.ignore_nodes)
|
| 158 |
+
# n_nodes_pred = len(pred_table.xpath(".//*"))
|
| 159 |
+
# n_nodes_true = len(true_table.xpath(".//*"))
|
| 160 |
+
# n_nodes = max(n_nodes_pred, n_nodes_true)
|
| 161 |
+
# if n_nodes == 0:
|
| 162 |
+
# queue.put(1.0)
|
| 163 |
+
# return
|
| 164 |
+
# tree_pred = self.load_html_tree(pred_table)
|
| 165 |
+
# tree_true = self.load_html_tree(true_table)
|
| 166 |
+
# distance = APTED(tree_pred, tree_true, CustomConfig()).compute_edit_distance()
|
| 167 |
+
# score = 1.0 - (float(distance) / n_nodes)
|
| 168 |
+
# queue.put(score)
|
| 169 |
+
# else:
|
| 170 |
+
# queue.put(0.0)
|
| 171 |
+
# except Exception:
|
| 172 |
+
# queue.put(0.0)
|
| 173 |
+
|
| 174 |
+
# # 超时时间(秒),可调整
|
| 175 |
+
# TIMEOUT_SECONDS = 60
|
| 176 |
+
|
| 177 |
+
# q = Queue()
|
| 178 |
+
# p = Process(target=_evaluate_inner, args=(pred, true, q))
|
| 179 |
+
# p.start()
|
| 180 |
+
# p.join(timeout=TIMEOUT_SECONDS)
|
| 181 |
+
|
| 182 |
+
# if p.is_alive():
|
| 183 |
+
# p.terminate()
|
| 184 |
+
# p.join()
|
| 185 |
+
# return 0.0
|
| 186 |
+
# else:
|
| 187 |
+
# if not q.empty():
|
| 188 |
+
# return q.get()
|
| 189 |
+
# else:
|
| 190 |
+
# return 0.0
|
| 191 |
+
|
| 192 |
+
def evaluate(self, pred, true):
|
| 193 |
+
try:
|
| 194 |
+
if (not pred) or (not true):
|
| 195 |
+
return 0.0
|
| 196 |
+
|
| 197 |
+
parser = html.HTMLParser(remove_comments=True, encoding='utf-8')
|
| 198 |
+
pred_doc = html.fromstring(pred, parser=parser)
|
| 199 |
+
true_doc = html.fromstring(true, parser=parser)
|
| 200 |
+
|
| 201 |
+
pred_tables = pred_doc.xpath('//table')
|
| 202 |
+
true_tables = true_doc.xpath('//table')
|
| 203 |
+
if not pred_tables or not true_tables:
|
| 204 |
+
return 0.0
|
| 205 |
+
|
| 206 |
+
pred_table = pred_tables[0]
|
| 207 |
+
true_table = true_tables[0]
|
| 208 |
+
|
| 209 |
+
if self.ignore_nodes:
|
| 210 |
+
etree.strip_tags(pred_table, *self.ignore_nodes)
|
| 211 |
+
etree.strip_tags(true_table, *self.ignore_nodes)
|
| 212 |
+
|
| 213 |
+
n_td_pred = len(pred_table.xpath(".//td"))
|
| 214 |
+
n_td_true = len(true_table.xpath(".//td"))
|
| 215 |
+
if n_td_pred > 50000 or n_td_true > 50000:
|
| 216 |
+
print(f"Skipping large table: pred={n_td_pred}, true={n_td_true}", flush=True)
|
| 217 |
+
return 0.0
|
| 218 |
+
|
| 219 |
+
n_nodes_pred = len(pred_table.xpath(".//*"))
|
| 220 |
+
n_nodes_true = len(true_table.xpath(".//*"))
|
| 221 |
+
n_nodes = max(n_nodes_pred, n_nodes_true)
|
| 222 |
+
if n_nodes == 0:
|
| 223 |
+
return 1.0
|
| 224 |
+
|
| 225 |
+
tree_pred = self.load_html_tree(pred_table)
|
| 226 |
+
tree_true = self.load_html_tree(true_table)
|
| 227 |
+
distance = APTED(tree_pred, tree_true, CustomConfig()).compute_edit_distance()
|
| 228 |
+
return 1.0 - (float(distance) / n_nodes)
|
| 229 |
+
except Exception:
|
| 230 |
+
return 0.0
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
def batch_evaluate(self, pred_json, true_json):
|
| 234 |
+
''' Computes TEDS score between the prediction and the ground truth of
|
| 235 |
+
a batch of samples
|
| 236 |
+
@params pred_json: {'FILENAME': 'HTML CODE', ...}
|
| 237 |
+
@params true_json: {'FILENAME': {'html': 'HTML CODE'}, ...}
|
| 238 |
+
@output: {'FILENAME': 'TEDS SCORE', ...}
|
| 239 |
+
'''
|
| 240 |
+
samples = true_json.keys()
|
| 241 |
+
# if self.n_jobs == 1:
|
| 242 |
+
scores = [self.evaluate(pred_json.get(filename, ''), true_json[filename]['html']) for filename in tqdm(samples)]
|
| 243 |
+
# else:
|
| 244 |
+
# inputs = [{'pred': pred_json.get(filename, ''), 'true': true_json[filename]['html']} for filename in samples]
|
| 245 |
+
# scores = parallel_process(inputs, self.evaluate, use_kwargs=True, n_jobs=self.n_jobs, front_num=1)
|
| 246 |
+
scores = dict(zip(samples, scores))
|
| 247 |
+
return scores
|
| 248 |
+
|
| 249 |
+
|
| 250 |
+
if __name__ == '__main__':
|
| 251 |
+
import json
|
| 252 |
+
import pprint
|
| 253 |
+
with open('sample_pred.json') as fp:
|
| 254 |
+
pred_json = json.load(fp)
|
| 255 |
+
with open('sample_gt.json') as fp:
|
| 256 |
+
true_json = json.load(fp)
|
| 257 |
+
teds = TEDS(n_jobs=4)
|
| 258 |
+
scores = teds.batch_evaluate(pred_json, true_json)
|
| 259 |
+
pp = pprint.PrettyPrinter()
|
| 260 |
+
pp.pprint(scores)
|
FinixDocBench_Eval_for_Markdown/finixdoc_md_eval/omnidocbench_adapter.py
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import math
|
| 2 |
+
import os
|
| 3 |
+
from collections import defaultdict
|
| 4 |
+
|
| 5 |
+
from .metrics.table_metric import TEDS
|
| 6 |
+
from .utils.extract import md_tex_filter
|
| 7 |
+
from .utils.match_quick import match_gt2pred_quick
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def _read_text(path):
|
| 11 |
+
with open(path, 'r', encoding='utf-8') as f:
|
| 12 |
+
return f.read()
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def _sequence_distance(a, b):
|
| 16 |
+
if a == b:
|
| 17 |
+
return 0
|
| 18 |
+
if a is None:
|
| 19 |
+
a = ''
|
| 20 |
+
if b is None:
|
| 21 |
+
b = ''
|
| 22 |
+
if len(a) < len(b):
|
| 23 |
+
a, b = b, a
|
| 24 |
+
if not b:
|
| 25 |
+
return len(a)
|
| 26 |
+
|
| 27 |
+
previous = list(range(len(b) + 1))
|
| 28 |
+
for i, ca in enumerate(a, 1):
|
| 29 |
+
current = [i]
|
| 30 |
+
for j, cb in enumerate(b, 1):
|
| 31 |
+
insert_cost = current[j - 1] + 1
|
| 32 |
+
delete_cost = previous[j] + 1
|
| 33 |
+
replace_cost = previous[j - 1] + (0 if ca == cb else 1)
|
| 34 |
+
current.append(min(insert_cost, delete_cost, replace_cost))
|
| 35 |
+
previous = current
|
| 36 |
+
return previous[-1]
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def _normalized_edit(a, b):
|
| 40 |
+
if a is None:
|
| 41 |
+
a = ''
|
| 42 |
+
if b is None:
|
| 43 |
+
b = ''
|
| 44 |
+
upper_len = max(len(a), len(b))
|
| 45 |
+
if upper_len == 0:
|
| 46 |
+
return 0.0, 0, 0
|
| 47 |
+
edit_num = _sequence_distance(a, b)
|
| 48 |
+
return edit_num / upper_len, edit_num, upper_len
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def _safe_mean(values, default=float('nan')):
|
| 52 |
+
values = [v for v in values if v is not None and not math.isnan(float(v))]
|
| 53 |
+
if not values:
|
| 54 |
+
return default
|
| 55 |
+
return sum(values) / len(values)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def _get_order_paired(order_match_s, img_name):
|
| 59 |
+
matched = [
|
| 60 |
+
(item['gt_position'], item['pred_position'])
|
| 61 |
+
for item in order_match_s
|
| 62 |
+
if item['gt_position'] != [''] and item['pred_position'] != ''
|
| 63 |
+
]
|
| 64 |
+
gt_idx_all = [item['gt_position'] for item in order_match_s if item['gt_position'] != ['']]
|
| 65 |
+
read_order_pred = [i[0] for i in sorted(matched, key=lambda x: x[1])]
|
| 66 |
+
read_order_gt = sum(gt_idx_all, [])
|
| 67 |
+
read_order_gt = [x for x in read_order_gt if x]
|
| 68 |
+
gt = sorted(read_order_gt)
|
| 69 |
+
pred = sum(read_order_pred, [])
|
| 70 |
+
pred = [x for x in pred if x]
|
| 71 |
+
if len(pred) > 0 or len(gt) > 0:
|
| 72 |
+
edit = _normalized_edit(gt, pred)[0]
|
| 73 |
+
return {
|
| 74 |
+
'gt': gt,
|
| 75 |
+
'pred': pred,
|
| 76 |
+
'img_id': img_name,
|
| 77 |
+
'edit': edit,
|
| 78 |
+
}
|
| 79 |
+
return {}
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
def _calculate_edit_dist(samples):
|
| 83 |
+
if not samples:
|
| 84 |
+
return float('nan')
|
| 85 |
+
|
| 86 |
+
grouped = defaultdict(lambda: {'edit': 0, 'upper': 0})
|
| 87 |
+
for sample in samples:
|
| 88 |
+
img_name = sample['img_id']
|
| 89 |
+
if not (img_name.endswith('.jpg') or img_name.endswith('.png')):
|
| 90 |
+
img_name = '_'.join(img_name.split('_')[:-1])
|
| 91 |
+
|
| 92 |
+
gt = sample.get('norm_gt') if sample.get('norm_gt') is not None else sample.get('gt', '')
|
| 93 |
+
pred = sample.get('norm_pred') if sample.get('norm_pred') is not None else sample.get('pred', '')
|
| 94 |
+
_, edit_num, upper_len = _normalized_edit(pred, gt)
|
| 95 |
+
if upper_len == 0:
|
| 96 |
+
continue
|
| 97 |
+
grouped[img_name]['edit'] += edit_num
|
| 98 |
+
grouped[img_name]['upper'] += upper_len
|
| 99 |
+
|
| 100 |
+
page_scores = [
|
| 101 |
+
val['edit'] / val['upper']
|
| 102 |
+
for val in grouped.values()
|
| 103 |
+
if val['upper'] > 0
|
| 104 |
+
]
|
| 105 |
+
return _safe_mean(page_scores)
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
def _missing_table_samples(gt_tables, img_name):
|
| 109 |
+
samples = []
|
| 110 |
+
for idx, item in enumerate(gt_tables):
|
| 111 |
+
content = str(item.get('content', ''))
|
| 112 |
+
samples.append({
|
| 113 |
+
'gt_idx': [idx],
|
| 114 |
+
'gt': content,
|
| 115 |
+
'pred_idx': [''],
|
| 116 |
+
'pred': '',
|
| 117 |
+
'gt_position': [item.get('order') if item.get('order') else item.get('position', [''])[0]],
|
| 118 |
+
'pred_position': '',
|
| 119 |
+
'norm_gt': content,
|
| 120 |
+
'norm_pred': '',
|
| 121 |
+
'gt_category_type': item.get('fine_category_type') or item.get('category_type', 'table'),
|
| 122 |
+
'pred_category_type': '',
|
| 123 |
+
'gt_attribute': [item.get('attribute', {})],
|
| 124 |
+
'edit': 1,
|
| 125 |
+
'img_id': img_name,
|
| 126 |
+
})
|
| 127 |
+
return samples
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
def _calculate_table_teds(table_samples):
|
| 131 |
+
if not table_samples:
|
| 132 |
+
return 100.0
|
| 133 |
+
|
| 134 |
+
teds = TEDS(structure_only=False)
|
| 135 |
+
scores = []
|
| 136 |
+
for sample in table_samples:
|
| 137 |
+
gt = sample.get('norm_gt') if sample.get('norm_gt') else sample.get('gt', '')
|
| 138 |
+
pred = sample.get('norm_pred') if sample.get('norm_pred') else sample.get('pred', '')
|
| 139 |
+
try:
|
| 140 |
+
score = teds.evaluate(pred, gt)
|
| 141 |
+
except Exception:
|
| 142 |
+
score = 0.0
|
| 143 |
+
scores.append(max(0.0, min(1.0, float(score))))
|
| 144 |
+
return _safe_mean(scores, default=0.0) * 100.0
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
def _clamp(value, low, high):
|
| 148 |
+
if value is None or math.isnan(float(value)):
|
| 149 |
+
return value
|
| 150 |
+
return max(low, min(high, float(value)))
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
def evaluate_md_dirs(gt_dir, pred_dir):
|
| 154 |
+
plain_text_match = []
|
| 155 |
+
html_table_match = []
|
| 156 |
+
latex_table_match = []
|
| 157 |
+
order_match = []
|
| 158 |
+
|
| 159 |
+
sample_names = sorted(name for name in os.listdir(gt_dir) if name.endswith('.md'))
|
| 160 |
+
for sample_name in sample_names:
|
| 161 |
+
img_name = sample_name[:-3] + '.jpg'
|
| 162 |
+
gt_content = _read_text(os.path.join(gt_dir, sample_name))
|
| 163 |
+
pred_path = os.path.join(pred_dir, sample_name)
|
| 164 |
+
pred_content = _read_text(pred_path) if os.path.exists(pred_path) else ''
|
| 165 |
+
|
| 166 |
+
gt_dataset = md_tex_filter(gt_content)
|
| 167 |
+
pred_dataset = md_tex_filter(pred_content)
|
| 168 |
+
|
| 169 |
+
plain_text_match_clean = []
|
| 170 |
+
if gt_dataset.get('text_all'):
|
| 171 |
+
plain_text_match_s = match_gt2pred_quick(
|
| 172 |
+
gt_dataset['text_all'],
|
| 173 |
+
pred_dataset.get('text_all', []),
|
| 174 |
+
'text',
|
| 175 |
+
img_name,
|
| 176 |
+
)
|
| 177 |
+
plain_text_match_clean = plain_text_match_s
|
| 178 |
+
plain_text_match.extend(plain_text_match_s)
|
| 179 |
+
|
| 180 |
+
if gt_dataset.get('latex_table'):
|
| 181 |
+
if pred_dataset.get('latex_table'):
|
| 182 |
+
table_match_s = match_gt2pred_quick(
|
| 183 |
+
gt_dataset['latex_table'],
|
| 184 |
+
pred_dataset['latex_table'],
|
| 185 |
+
'latex_table',
|
| 186 |
+
img_name,
|
| 187 |
+
)
|
| 188 |
+
latex_table_match.extend([x for x in table_match_s if x['gt_idx'] != ['']])
|
| 189 |
+
else:
|
| 190 |
+
latex_table_match.extend(_missing_table_samples(gt_dataset['latex_table'], img_name))
|
| 191 |
+
elif gt_dataset.get('html_table'):
|
| 192 |
+
if pred_dataset.get('html_table'):
|
| 193 |
+
table_match_s = match_gt2pred_quick(
|
| 194 |
+
gt_dataset['html_table'],
|
| 195 |
+
pred_dataset['html_table'],
|
| 196 |
+
'html_table',
|
| 197 |
+
img_name,
|
| 198 |
+
)
|
| 199 |
+
html_table_match.extend([x for x in table_match_s if x['gt_idx'] != ['']])
|
| 200 |
+
else:
|
| 201 |
+
html_table_match.extend(_missing_table_samples(gt_dataset['html_table'], img_name))
|
| 202 |
+
|
| 203 |
+
order_match_s = _get_order_paired(plain_text_match_clean, img_name)
|
| 204 |
+
if order_match_s:
|
| 205 |
+
order_match.append(order_match_s)
|
| 206 |
+
|
| 207 |
+
table_match = latex_table_match if latex_table_match else html_table_match
|
| 208 |
+
text_block_edit = _clamp(_calculate_edit_dist(plain_text_match), 0.0, 1.0)
|
| 209 |
+
reading_order_edit = _clamp(_calculate_edit_dist(order_match), 0.0, 1.0)
|
| 210 |
+
table_teds = _clamp(_calculate_table_teds(table_match), 0.0, 100.0)
|
| 211 |
+
|
| 212 |
+
if math.isnan(float(text_block_edit)):
|
| 213 |
+
text_block_edit = 0.0
|
| 214 |
+
if math.isnan(float(reading_order_edit)):
|
| 215 |
+
reading_order_edit = 0.0
|
| 216 |
+
|
| 217 |
+
overall = ((1 - text_block_edit) * 100.0 + (1 - reading_order_edit) * 100.0 + table_teds) / 3.0
|
| 218 |
+
overall = max(0.0, min(100.0, overall))
|
| 219 |
+
|
| 220 |
+
return {
|
| 221 |
+
'text_block_Edit_dist': text_block_edit,
|
| 222 |
+
'reading_order_Edit_dist': reading_order_edit,
|
| 223 |
+
'table_TEDS': table_teds,
|
| 224 |
+
'overall': overall,
|
| 225 |
+
'num_samples': len(sample_names),
|
| 226 |
+
}
|
FinixDocBench_Eval_for_Markdown/finixdoc_md_eval/utils/__init__.py
ADDED
|
File without changes
|
FinixDocBench_Eval_for_Markdown/finixdoc_md_eval/utils/data_preprocess.py
ADDED
|
@@ -0,0 +1,452 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
import unicodedata
|
| 3 |
+
from pylatexenc.latex2text import LatexNodes2Text
|
| 4 |
+
from bs4 import BeautifulSoup
|
| 5 |
+
import subprocess
|
| 6 |
+
import shutil
|
| 7 |
+
import uuid
|
| 8 |
+
import html
|
| 9 |
+
import os
|
| 10 |
+
|
| 11 |
+
def remove_markdown_fences(content):
|
| 12 |
+
content = re.sub(r'^```markdown\n?', '', content, flags=re.MULTILINE)
|
| 13 |
+
content = re.sub(r'^```html\n?', '', content, flags=re.MULTILINE)
|
| 14 |
+
content = re.sub(r'^```latex\n?', '', content, flags=re.MULTILINE)
|
| 15 |
+
content = re.sub(r'```\n?$', '', content, flags=re.MULTILINE)
|
| 16 |
+
return content
|
| 17 |
+
|
| 18 |
+
# Standardize all consecutive characters
|
| 19 |
+
def replace_repeated_chars(input_str):
|
| 20 |
+
input_str = re.sub(r'_{4,}', '____', input_str) # Replace more than 4 consecutive underscores with 4 underscores
|
| 21 |
+
input_str = re.sub(r' {4,}', ' ', input_str) # Replace more than 4 consecutive spaces with 4 spaces
|
| 22 |
+
return input_str
|
| 23 |
+
# return re.sub(r'([^a-zA-Z0-9])\1{10,}', r'\1\1\1\1', input_str) # For other consecutive symbols (except numbers and letters), replace more than 10 occurrences with 4
|
| 24 |
+
|
| 25 |
+
# Special Unicode handling
|
| 26 |
+
def fullwidth_to_halfwidth(s):
|
| 27 |
+
result = []
|
| 28 |
+
for char in s:
|
| 29 |
+
code = ord(char)
|
| 30 |
+
# Convert full-width space to half-width space
|
| 31 |
+
if code == 0x3000:
|
| 32 |
+
code = 0x0020
|
| 33 |
+
# Convert other full-width characters to half-width
|
| 34 |
+
elif 0xFF01 <= code <= 0xFF5E:
|
| 35 |
+
code -= 0xFEE0
|
| 36 |
+
result.append(chr(code))
|
| 37 |
+
return ''.join(result)
|
| 38 |
+
|
| 39 |
+
def find_special_unicode(s):
|
| 40 |
+
special_chars = {}
|
| 41 |
+
for char in s:
|
| 42 |
+
if ord(char) > 127: # Non-ASCII characters
|
| 43 |
+
# unicode_name = unicodedata.name(char, None)
|
| 44 |
+
unicode_name = unicodedata.category(char)
|
| 45 |
+
special_chars[char] = f'U+{ord(char):04X} ({unicode_name})'
|
| 46 |
+
return special_chars
|
| 47 |
+
|
| 48 |
+
# # Define dictionary for Unicode character replacements
|
| 49 |
+
# unicode_replacements = {
|
| 50 |
+
# "\u00A9": r"$\copyright$", # Copyright symbol © to latex
|
| 51 |
+
# "\u00AE": r"$^\circledR$", # Registered trademark ® to latex
|
| 52 |
+
# "\u2122": r"$^\text{TM}$", # Trademark ™ to latex
|
| 53 |
+
# "\u2018": "'", # Left single quote to straight quote
|
| 54 |
+
# "\u2019": "'", # Right single quote to straight quote
|
| 55 |
+
# "\u201C": "\"", # Left double quote to straight quote
|
| 56 |
+
# "\u201D": "\"", # Right double quote to straight quote
|
| 57 |
+
# "\u2013": "-", # En dash to hyphen
|
| 58 |
+
# "\u2014": "-", # Em dash to hyphen
|
| 59 |
+
# "\u2026": "...", # Unicode ellipsis to three dots
|
| 60 |
+
# "\u2103": r"$\textdegree C$", # ℃
|
| 61 |
+
# "\u03B1": r"$\alpha$", # α
|
| 62 |
+
# "\u03B2": r"$\beta$", # β
|
| 63 |
+
# "\u03A3": r"$\Sigma$", # Σ
|
| 64 |
+
# }
|
| 65 |
+
|
| 66 |
+
# # Use regex to replace Unicode characters
|
| 67 |
+
# def replace_unicode(match):
|
| 68 |
+
# char = match.group(0)
|
| 69 |
+
# return unicode_replacements.get(char, char)
|
| 70 |
+
|
| 71 |
+
inline_reg = re.compile(
|
| 72 |
+
r'\$(.*?)\$|'
|
| 73 |
+
r'\\\((.*?)\\\)',
|
| 74 |
+
)
|
| 75 |
+
|
| 76 |
+
def textblock2unicode(text):
|
| 77 |
+
inline_matches = inline_reg.finditer(text)
|
| 78 |
+
removal_positions = []
|
| 79 |
+
for match in inline_matches:
|
| 80 |
+
position = [match.start(), match.end()]
|
| 81 |
+
content = match.group(1) if match.group(1) is not None else match.group(2)
|
| 82 |
+
# print('-------- content-------', content)
|
| 83 |
+
# Remove escape characters \
|
| 84 |
+
clean_content = re.sub(r'\\([\\_&%^])', '', content)
|
| 85 |
+
|
| 86 |
+
try:
|
| 87 |
+
if any(char in clean_content for char in r'\^_'):
|
| 88 |
+
if clean_content.endswith('\\'):
|
| 89 |
+
clean_content += ' '
|
| 90 |
+
# inline_array.append(match.group(0))
|
| 91 |
+
unicode_content = LatexNodes2Text().latex_to_text(clean_content)
|
| 92 |
+
removal_positions.append((position[0], position[1], unicode_content))
|
| 93 |
+
except:
|
| 94 |
+
continue
|
| 95 |
+
|
| 96 |
+
# Remove inline formulas from original text
|
| 97 |
+
for start, end, unicode_content in sorted(removal_positions, reverse=True):
|
| 98 |
+
text = text[:start] + unicode_content.strip() + text[end:]
|
| 99 |
+
|
| 100 |
+
return text
|
| 101 |
+
|
| 102 |
+
def normalized_formula(text):
|
| 103 |
+
# Normalize math formulas before matching
|
| 104 |
+
filter_list = ['\\mathbf', '\\mathrm', '\\mathnormal', '\\mathit', '\\mathbb', '\\mathcal', '\\mathscr', '\\mathfrak', '\\mathsf', '\\mathtt',
|
| 105 |
+
'\\textbf', '\\text', '\\boldmath', '\\boldsymbol', '\\operatorname', '\\bm',
|
| 106 |
+
'\\symbfit', '\\mathbfcal', '\\symbf', '\\scriptscriptstyle', '\\notag',
|
| 107 |
+
'\\setlength', '\\coloneqq', '\\space', '\\thickspace', '\\thinspace', '\\medspace', '\\nobreakspace', '\\negmedspace',
|
| 108 |
+
'\\quad', '\\qquad', '\\enspace', '\\substackw', ' ', '$$', '\\left', '\\right', '\\displaystyle', '\\text']
|
| 109 |
+
# '\\left', '\\right', '{', '}', ' ']
|
| 110 |
+
|
| 111 |
+
# delimiter_filter
|
| 112 |
+
text = text.strip().strip('$').strip('\n')
|
| 113 |
+
pattern = re.compile(r"\\\[(.+?)(?<!\\)\\\]")
|
| 114 |
+
match = pattern.search(text)
|
| 115 |
+
|
| 116 |
+
if match:
|
| 117 |
+
text = match.group(1).strip()
|
| 118 |
+
|
| 119 |
+
tag_pattern = re.compile(r"\\tag\{.*?\}")
|
| 120 |
+
text = tag_pattern.sub('', text)
|
| 121 |
+
hspace_pattern = re.compile(r"\\hspace\{.*?\}")
|
| 122 |
+
text = hspace_pattern.sub('', text)
|
| 123 |
+
begin_pattern = re.compile(r"\\begin\{.*?\}")
|
| 124 |
+
text = begin_pattern.sub('', text)
|
| 125 |
+
end_pattern = re.compile(r"\\end\{.*?\}")
|
| 126 |
+
text = end_pattern.sub('', text)
|
| 127 |
+
col_sep = re.compile(r"\\arraycolsep.*?\}")
|
| 128 |
+
text = col_sep.sub('', text)
|
| 129 |
+
text = text.strip('.')
|
| 130 |
+
|
| 131 |
+
for filter_text in filter_list:
|
| 132 |
+
text = text.replace(filter_text, '')
|
| 133 |
+
|
| 134 |
+
# text = normalize_text(delimiter_filter(text))
|
| 135 |
+
# text = delimiter_filter(text)
|
| 136 |
+
text = text.lower()
|
| 137 |
+
return text
|
| 138 |
+
|
| 139 |
+
def normalized_html_table(text):
|
| 140 |
+
def process_table_html(md_i):
|
| 141 |
+
"""
|
| 142 |
+
pred_md format edit
|
| 143 |
+
"""
|
| 144 |
+
def process_table_html(html_content):
|
| 145 |
+
soup = BeautifulSoup(html_content, 'html.parser')
|
| 146 |
+
th_tags = soup.find_all('th')
|
| 147 |
+
for th in th_tags:
|
| 148 |
+
th.name = 'td'
|
| 149 |
+
thead_tags = soup.find_all('thead')
|
| 150 |
+
for thead in thead_tags:
|
| 151 |
+
thead.unwrap() # unwrap()会移除标签但保留其内容
|
| 152 |
+
math_tags = soup.find_all('math')
|
| 153 |
+
for math_tag in math_tags:
|
| 154 |
+
alttext = math_tag.get('alttext', '')
|
| 155 |
+
alttext = f'${alttext}$'
|
| 156 |
+
if alttext:
|
| 157 |
+
math_tag.replace_with(alttext)
|
| 158 |
+
span_tags = soup.find_all('span')
|
| 159 |
+
for span in span_tags:
|
| 160 |
+
span.unwrap()
|
| 161 |
+
return str(soup)
|
| 162 |
+
|
| 163 |
+
table_res=''
|
| 164 |
+
table_res_no_space=''
|
| 165 |
+
if '<table' in md_i.replace(" ","").replace("'",'"'):
|
| 166 |
+
md_i = process_table_html(md_i)
|
| 167 |
+
table_res = html.unescape(md_i).replace('\n', '')
|
| 168 |
+
table_res = unicodedata.normalize('NFKC', table_res).strip()
|
| 169 |
+
pattern = r'<table\b[^>]*>(.*)</table>'
|
| 170 |
+
tables = re.findall(pattern, table_res, re.DOTALL | re.IGNORECASE)
|
| 171 |
+
table_res = ''.join(tables)
|
| 172 |
+
# table_res = re.sub('<table.*?>','',table_res)
|
| 173 |
+
table_res = re.sub('( style=".*?")', "", table_res)
|
| 174 |
+
table_res = re.sub('( height=".*?")', "", table_res)
|
| 175 |
+
table_res = re.sub('( width=".*?")', "", table_res)
|
| 176 |
+
table_res = re.sub('( align=".*?")', "", table_res)
|
| 177 |
+
table_res = re.sub('( class=".*?")', "", table_res)
|
| 178 |
+
table_res = re.sub('</?tbody>',"",table_res)
|
| 179 |
+
|
| 180 |
+
table_res = re.sub(r'\s+', " ", table_res)
|
| 181 |
+
table_res_no_space = '<html><body><table border="1" >' + table_res.replace(' ','') + '</table></body></html>'
|
| 182 |
+
# table_res_no_space = re.sub(' (style=".*?")',"",table_res_no_space)
|
| 183 |
+
# table_res_no_space = re.sub(r'[ ]', " ", table_res_no_space)
|
| 184 |
+
table_res_no_space = re.sub('colspan="', ' colspan="', table_res_no_space)
|
| 185 |
+
table_res_no_space = re.sub('rowspan="', ' rowspan="', table_res_no_space)
|
| 186 |
+
table_res_no_space = re.sub('border="', ' border="', table_res_no_space)
|
| 187 |
+
|
| 188 |
+
table_res = '<html><body><table border="1" >' + table_res + '</table></body></html>'
|
| 189 |
+
# table_flow.append(table_res)
|
| 190 |
+
# table_flow_no_space.append(table_res_no_space)
|
| 191 |
+
|
| 192 |
+
return table_res, table_res_no_space
|
| 193 |
+
|
| 194 |
+
def clean_table(input_str,flag=True):
|
| 195 |
+
if flag:
|
| 196 |
+
input_str = input_str.replace('<sup>', '').replace('</sup>', '')
|
| 197 |
+
input_str = input_str.replace('<sub>', '').replace('</sub>', '')
|
| 198 |
+
input_str = input_str.replace('<span>', '').replace('</span>', '')
|
| 199 |
+
input_str = input_str.replace('<div>', '').replace('</div>', '')
|
| 200 |
+
input_str = input_str.replace('<p>', '').replace('</p>', '')
|
| 201 |
+
input_str = input_str.replace('<spandata-span-identity="">', '')
|
| 202 |
+
input_str = re.sub('<colgroup>.*?</colgroup>','',input_str)
|
| 203 |
+
return input_str
|
| 204 |
+
|
| 205 |
+
norm_text, _ = process_table_html(text)
|
| 206 |
+
norm_text = clean_table(norm_text)
|
| 207 |
+
return norm_text
|
| 208 |
+
|
| 209 |
+
def normalized_latex_table(text):
|
| 210 |
+
def latex_template(latex_code):
|
| 211 |
+
template = r'''
|
| 212 |
+
\documentclass[border=20pt]{article}
|
| 213 |
+
\usepackage{subcaption}
|
| 214 |
+
\usepackage{url}
|
| 215 |
+
\usepackage{graphicx}
|
| 216 |
+
\usepackage{caption}
|
| 217 |
+
\usepackage{multirow}
|
| 218 |
+
\usepackage{booktabs}
|
| 219 |
+
\usepackage{color}
|
| 220 |
+
\usepackage{colortbl}
|
| 221 |
+
\usepackage{xcolor,soul,framed}
|
| 222 |
+
\usepackage{fontspec}
|
| 223 |
+
\usepackage{amsmath,amssymb,mathtools,bm,mathrsfs,textcomp}
|
| 224 |
+
\setlength{\parindent}{0pt}''' + \
|
| 225 |
+
r'''
|
| 226 |
+
\begin{document}
|
| 227 |
+
''' + \
|
| 228 |
+
latex_code + \
|
| 229 |
+
r'''
|
| 230 |
+
\end{document}'''
|
| 231 |
+
|
| 232 |
+
return template
|
| 233 |
+
|
| 234 |
+
def process_table_latex(latex_code):
|
| 235 |
+
SPECIAL_STRINGS= [
|
| 236 |
+
['\\\\vspace\\{.*?\\}', ''],
|
| 237 |
+
['\\\\hspace\\{.*?\\}', ''],
|
| 238 |
+
['\\\\rule\\{.*?\\}\\{.*?\\}', ''],
|
| 239 |
+
['\\\\addlinespace\\[.*?\\]', ''],
|
| 240 |
+
['\\\\addlinespace', ''],
|
| 241 |
+
['\\\\renewcommand\\{\\\\arraystretch\\}\\{.*?\\}', ''],
|
| 242 |
+
['\\\\arraystretch\\{.*?\\}', ''],
|
| 243 |
+
['\\\\(row|column)?colors?\\{[^}]*\\}(\\{[^}]*\\}){0,2}', ''],
|
| 244 |
+
['\\\\color\\{.*?\\}', ''],
|
| 245 |
+
['\\\\textcolor\\{.*?\\}', ''],
|
| 246 |
+
['\\\\rowcolor(\\[.*?\\])?\\{.*?\\}', ''],
|
| 247 |
+
['\\\\columncolor(\\[.*?\\])?\\{.*?\\}', ''],
|
| 248 |
+
['\\\\cellcolor(\\[.*?\\])?\\{.*?\\}', ''],
|
| 249 |
+
['\\\\colorbox\\{.*?\\}', ''],
|
| 250 |
+
['\\\\(tiny|scriptsize|footnotesize|small|normalsize|large|Large|LARGE|huge|Huge)', ''],
|
| 251 |
+
[r'\s+', ' '],
|
| 252 |
+
['\\\\centering', ''],
|
| 253 |
+
['\\\\begin\\{table\\}\\[.*?\\]', '\\\\begin{table}'],
|
| 254 |
+
['\t', ''],
|
| 255 |
+
['@{}', ''],
|
| 256 |
+
['\\\\toprule(\\[.*?\\])?', '\\\\hline'],
|
| 257 |
+
['\\\\bottomrule(\\[.*?\\])?', '\\\\hline'],
|
| 258 |
+
['\\\\midrule(\\[.*?\\])?', '\\\\hline'],
|
| 259 |
+
['p\\{[^}]*\\}', 'l'],
|
| 260 |
+
['m\\{[^}]*\\}', 'c'],
|
| 261 |
+
['\\\\scalebox\\{[^}]*\\}\\{([^}]*)\\}', '\\1'],
|
| 262 |
+
['\\\\textbf\\{([^}]*)\\}', '\\1'],
|
| 263 |
+
['\\\\textit\\{([^}]*)\\}', '\\1'],
|
| 264 |
+
['\\\\cmidrule(\\[.*?\\])?\\(.*?\\)\\{([0-9]-[0-9])\\}', '\\\\cline{\\2}'],
|
| 265 |
+
['\\\\hline', ''],
|
| 266 |
+
[r'\\multicolumn\{1\}\{[^}]*\}\{((?:[^{}]|(?:\{[^{}]*\}))*)\}', r'\1']
|
| 267 |
+
]
|
| 268 |
+
pattern = r'\\begin\{tabular\}.*\\end\{tabular\}' # 注意这里不用 .*?
|
| 269 |
+
matches = re.findall(pattern, latex_code, re.DOTALL)
|
| 270 |
+
latex_code = ' '.join(matches)
|
| 271 |
+
|
| 272 |
+
for special_str in SPECIAL_STRINGS:
|
| 273 |
+
latex_code = re.sub(fr'{special_str[0]}', fr'{special_str[1]}', latex_code)
|
| 274 |
+
|
| 275 |
+
return latex_code
|
| 276 |
+
|
| 277 |
+
def convert_latex_to_html(latex_content, cache_dir='./temp'):
|
| 278 |
+
if not os.path.exists(cache_dir):
|
| 279 |
+
os.makedirs(cache_dir)
|
| 280 |
+
|
| 281 |
+
uuid_str = str(uuid.uuid1())
|
| 282 |
+
with open(f'{cache_dir}/{uuid_str}.tex', 'w') as f:
|
| 283 |
+
f.write(latex_template(latex_content))
|
| 284 |
+
|
| 285 |
+
cmd = ['latexmlc', '--quiet', '--nocomments', f'--log={cache_dir}/{uuid_str}.log',
|
| 286 |
+
f'{cache_dir}/{uuid_str}.tex', f'--dest={cache_dir}/{uuid_str}.html']
|
| 287 |
+
try:
|
| 288 |
+
subprocess.run(cmd, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 289 |
+
with open(f'{cache_dir}/{uuid_str}.html', 'r') as f:
|
| 290 |
+
html_content = f.read()
|
| 291 |
+
|
| 292 |
+
pattern = r'<table\b[^>]*>(.*)</table>'
|
| 293 |
+
tables = re.findall(pattern, html_content, re.DOTALL | re.IGNORECASE)
|
| 294 |
+
tables = [f'<table>{table}</table>' for table in tables]
|
| 295 |
+
html_content = '\n'.join(tables)
|
| 296 |
+
|
| 297 |
+
except Exception as e:
|
| 298 |
+
html_content = ''
|
| 299 |
+
|
| 300 |
+
shutil.rmtree(cache_dir)
|
| 301 |
+
return html_content
|
| 302 |
+
|
| 303 |
+
html_text = convert_latex_to_html(text)
|
| 304 |
+
normlized_tables = normalized_html_table(html_text)
|
| 305 |
+
return normlized_tables
|
| 306 |
+
|
| 307 |
+
|
| 308 |
+
def normalized_table(text, format='html'):
|
| 309 |
+
if format not in ['html', 'latex']:
|
| 310 |
+
raise ValueError('Invalid format: {}'.format(format))
|
| 311 |
+
else:
|
| 312 |
+
return globals()['normalized_{}_table'.format(format)](text)
|
| 313 |
+
|
| 314 |
+
|
| 315 |
+
def textblock_with_norm_formula(text):
|
| 316 |
+
inline_matches = inline_reg.finditer(text)
|
| 317 |
+
removal_positions = []
|
| 318 |
+
for match in inline_matches:
|
| 319 |
+
position = [match.start(), match.end()]
|
| 320 |
+
content = match.group(1) if match.group(1) is not None else match.group(2)
|
| 321 |
+
# print('-------- content-------', content)
|
| 322 |
+
|
| 323 |
+
norm_content = normalized_formula(content)
|
| 324 |
+
removal_positions.append((position[0], position[1], norm_content))
|
| 325 |
+
|
| 326 |
+
# Remove inline formulas from original text
|
| 327 |
+
for start, end, norm_content in sorted(removal_positions, reverse=True):
|
| 328 |
+
text = text[:start] + norm_content.strip() + text[end:]
|
| 329 |
+
|
| 330 |
+
return text
|
| 331 |
+
|
| 332 |
+
# def inline_filter_unicode(text):
|
| 333 |
+
# # Ensure text is string type
|
| 334 |
+
# if not isinstance(text, str):
|
| 335 |
+
# text = str(text)
|
| 336 |
+
|
| 337 |
+
# # Convert LaTeX content to Unicode representation
|
| 338 |
+
# text = LatexNodes2Text().latex_to_text(text)
|
| 339 |
+
|
| 340 |
+
# inline_array = []
|
| 341 |
+
# inline_matches = inline_reg.finditer(text)
|
| 342 |
+
|
| 343 |
+
# for match in inline_matches:
|
| 344 |
+
# position = [match.start(), match.end()]
|
| 345 |
+
# content = match.group(1) if match.group(1) is not None else match.group(2)
|
| 346 |
+
|
| 347 |
+
# # Remove escape characters \
|
| 348 |
+
# clean_content = re.sub(r'\\([\\_&%^])', '', content)
|
| 349 |
+
|
| 350 |
+
# if any(char in clean_content for char in r'\^_'):
|
| 351 |
+
# # inline_array.append(match.group(0))
|
| 352 |
+
# inline_array.append({
|
| 353 |
+
# 'category_type': 'equation_inline',
|
| 354 |
+
# 'position': position,
|
| 355 |
+
# 'content': match.group(0),
|
| 356 |
+
# })
|
| 357 |
+
# text = text.replace(match.group(0), '')
|
| 358 |
+
# # print('-----Found inline formula: ', match.group(0))
|
| 359 |
+
# else:
|
| 360 |
+
# text = text.replace(match.group(0), content)
|
| 361 |
+
# # # Add to inline_array
|
| 362 |
+
# # inline_array.append({
|
| 363 |
+
# # 'category_type': 'equation_inline',
|
| 364 |
+
# # 'position': position,
|
| 365 |
+
# # 'content': content,
|
| 366 |
+
# # })
|
| 367 |
+
|
| 368 |
+
# # # Remove matched formula from original text, can choose to replace with spaces or remove directly
|
| 369 |
+
# # text = text[:position[0]] + ' '*(position[1]-position[0]) + text[position[1]:]
|
| 370 |
+
|
| 371 |
+
# return text, inline_array
|
| 372 |
+
|
| 373 |
+
def inline_filter_unicode(text):
|
| 374 |
+
# Ensure text is string type
|
| 375 |
+
if not isinstance(text, str):
|
| 376 |
+
text = str(text)
|
| 377 |
+
|
| 378 |
+
# Replace inline formula boundary markers
|
| 379 |
+
#print('--------text-------',text)
|
| 380 |
+
placeholder = '__INLINE_FORMULA_BOUNDARY__'
|
| 381 |
+
text_copy = text.replace('$', placeholder).replace('\\(', placeholder).replace('\\)', placeholder)
|
| 382 |
+
#print('--------text_copy-------',text_copy)
|
| 383 |
+
# Convert LaTeX content to Unicode representation
|
| 384 |
+
text_copy = LatexNodes2Text().latex_to_text(text_copy)
|
| 385 |
+
#print('--------text_copy---unicode----',text_copy)
|
| 386 |
+
# Restore boundary markers
|
| 387 |
+
text_copy = text_copy.replace(placeholder, '$')
|
| 388 |
+
|
| 389 |
+
inline_array = []
|
| 390 |
+
inline_matches = inline_reg.finditer(text_copy)
|
| 391 |
+
# Record positions of inline formulas to be removed
|
| 392 |
+
removal_positions = []
|
| 393 |
+
|
| 394 |
+
for match in inline_matches:
|
| 395 |
+
position = [match.start(), match.end()]
|
| 396 |
+
content = match.group(1) if match.group(1) is not None else match.group(2)
|
| 397 |
+
print('-------- content-------', content)
|
| 398 |
+
# Remove escape characters \
|
| 399 |
+
clean_content = re.sub(r'\\([\\_&%^])', '', content)
|
| 400 |
+
|
| 401 |
+
if any(char in clean_content for char in r'\^_'):
|
| 402 |
+
# inline_array.append(match.group(0))
|
| 403 |
+
inline_array.append({
|
| 404 |
+
'category_type': 'equation_inline',
|
| 405 |
+
'position': position,
|
| 406 |
+
'content': content,
|
| 407 |
+
})
|
| 408 |
+
removal_positions.append((position[0], position[1]))
|
| 409 |
+
|
| 410 |
+
# Remove inline formulas from original text
|
| 411 |
+
for start, end in sorted(removal_positions, reverse=True):
|
| 412 |
+
text = text[:start] + text[end:]
|
| 413 |
+
|
| 414 |
+
return text, inline_array
|
| 415 |
+
|
| 416 |
+
def inline_filter(text):
|
| 417 |
+
# Ensure text is string type
|
| 418 |
+
if not isinstance(text, str):
|
| 419 |
+
text = str(text)
|
| 420 |
+
|
| 421 |
+
inline_array = []
|
| 422 |
+
inline_matches = inline_reg.finditer(text)
|
| 423 |
+
|
| 424 |
+
for match in inline_matches:
|
| 425 |
+
position = [match.start(), match.end()]
|
| 426 |
+
content = match.group(1) if match.group(1) is not None else match.group(2)
|
| 427 |
+
# print('inline_content: ', content)
|
| 428 |
+
|
| 429 |
+
# Remove escape characters \
|
| 430 |
+
clean_content = re.sub(r'\\([\\_&%^])', '', content)
|
| 431 |
+
|
| 432 |
+
if any(char in clean_content for char in r'\^_'):
|
| 433 |
+
# inline_array.append(match.group(0))
|
| 434 |
+
inline_array.append({
|
| 435 |
+
'category_type': 'equation_inline',
|
| 436 |
+
'position': position,
|
| 437 |
+
'content': match.group(0),
|
| 438 |
+
})
|
| 439 |
+
text = text.replace(match.group(0), '')
|
| 440 |
+
# print('-----Found inline formula: ', match.group(0))
|
| 441 |
+
else:
|
| 442 |
+
text = text.replace(match.group(0), content)
|
| 443 |
+
|
| 444 |
+
return text, inline_array
|
| 445 |
+
|
| 446 |
+
# Text OCR quality check processing:
|
| 447 |
+
def clean_string(input_string):
|
| 448 |
+
# Use regex to keep Chinese characters, English letters and numbers
|
| 449 |
+
# input_string = input_string.replace('\\t', '').replace('\\n', '').replace('\t', '').replace('\n', '').replace('/t', '').replace('/n', '')
|
| 450 |
+
input_string = input_string.replace('\\t', '').replace('\\n', '').replace('\t', '').replace('\n', '').replace('/t', '').replace('/n', '')
|
| 451 |
+
cleaned_string = re.sub(r'[^\w\u4e00-\u9fff]', '', input_string) # 只保留中英文和数字
|
| 452 |
+
return cleaned_string
|
FinixDocBench_Eval_for_Markdown/finixdoc_md_eval/utils/extract.py
ADDED
|
@@ -0,0 +1,571 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
import os
|
| 3 |
+
import json
|
| 4 |
+
import copy
|
| 5 |
+
#from modules.table_utils import convert_markdown_to_html #end
|
| 6 |
+
from .table_utils import convert_markdown_to_html
|
| 7 |
+
import re
|
| 8 |
+
import unicodedata
|
| 9 |
+
from bs4 import BeautifulSoup
|
| 10 |
+
from pylatexenc.latexencode import unicode_to_latex
|
| 11 |
+
from pylatexenc.latex2text import LatexNodes2Text
|
| 12 |
+
from pylatexenc.latexwalker import LatexWalker, LatexEnvironmentNode, LatexCharsNode, LatexGroupNode, LatexMacroNode, LatexSpecialsNode
|
| 13 |
+
from collections import defaultdict
|
| 14 |
+
import pdb
|
| 15 |
+
from .data_preprocess import remove_markdown_fences, replace_repeated_chars, textblock_with_norm_formula, textblock2unicode
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def extract_tabular(text):
|
| 19 |
+
begin_pattern = r'\\begin{tabular}'
|
| 20 |
+
end_pattern = r'\\end{tabular}'
|
| 21 |
+
|
| 22 |
+
tabulars = []
|
| 23 |
+
positions = []
|
| 24 |
+
current_pos = 0
|
| 25 |
+
stack = []
|
| 26 |
+
|
| 27 |
+
while current_pos < len(text):
|
| 28 |
+
begin_match = re.search(begin_pattern, text[current_pos:])
|
| 29 |
+
end_match = re.search(end_pattern, text[current_pos:])
|
| 30 |
+
|
| 31 |
+
if not begin_match and not end_match:
|
| 32 |
+
break
|
| 33 |
+
|
| 34 |
+
if begin_match and (not end_match or begin_match.start() < end_match.start()):
|
| 35 |
+
stack.append(current_pos + begin_match.start())
|
| 36 |
+
current_pos += begin_match.start() + len(end_pattern)
|
| 37 |
+
elif end_match:
|
| 38 |
+
if stack:
|
| 39 |
+
start_pos = stack.pop()
|
| 40 |
+
if not stack:
|
| 41 |
+
end_pos = current_pos + end_match.start() + len(end_pattern)
|
| 42 |
+
tabular_code = text[start_pos:end_pos]
|
| 43 |
+
tabulars.append(tabular_code)
|
| 44 |
+
positions.append((start_pos, end_pos))
|
| 45 |
+
current_pos += end_match.start() + len(end_pattern)
|
| 46 |
+
else:
|
| 47 |
+
current_pos += 1
|
| 48 |
+
|
| 49 |
+
if stack:
|
| 50 |
+
new_start = stack[0] + len(begin_pattern)
|
| 51 |
+
new_tabulars, new_positions = extract_tabular(text[new_start:])
|
| 52 |
+
new_positions = [(start + new_start, end + new_start) for start, end in new_positions]
|
| 53 |
+
tabulars.extend(new_tabulars)
|
| 54 |
+
positions.extend(new_positions)
|
| 55 |
+
|
| 56 |
+
return tabulars, positions
|
| 57 |
+
|
| 58 |
+
# math reg
|
| 59 |
+
# r'\\begin{equation\*?}(.*?)\\end{equation\*?}|'
|
| 60 |
+
# r'\\begin{align\*?}(.*?)\\end{align\*?}|'
|
| 61 |
+
# r'\\begin{gather\*?}(.*?)\\end{gather\*?}|'
|
| 62 |
+
display_reg = re.compile(
|
| 63 |
+
# r'\\begin{equation\*?}(.*?)\\end{equation\*?}|'
|
| 64 |
+
# r'\\begin{align\*?}(.*?)\\end{align\*?}|'
|
| 65 |
+
# r'\\begin{gather\*?}(.*?)\\end{gather\*?}|'
|
| 66 |
+
# r'\\begin{array\*?}(.*?)\\end{array\*?}|'
|
| 67 |
+
r'\$\$(.*?)\$\$|'
|
| 68 |
+
r'\\\[(.*?)\\\]|'
|
| 69 |
+
r'\$(.*?)\$|'
|
| 70 |
+
r'\\\((.*?)\\\)',
|
| 71 |
+
re.DOTALL
|
| 72 |
+
)
|
| 73 |
+
|
| 74 |
+
# inline_reg = re.compile(
|
| 75 |
+
# r'(?<!\$)\$(?!\$)(.*?)(?<!\$)\$(?!\$)|'
|
| 76 |
+
# r'\\\((.*?)\\\)',
|
| 77 |
+
# )
|
| 78 |
+
inline_reg = re.compile(
|
| 79 |
+
r'\$(.*?)\$|'
|
| 80 |
+
r'\\\((.*?)\\\)',
|
| 81 |
+
)
|
| 82 |
+
|
| 83 |
+
# table
|
| 84 |
+
table_reg = re.compile(
|
| 85 |
+
r'\\begin{table\*?}(.*?)\\end{table\*?}|'
|
| 86 |
+
r'\\begin{tabular\*?}(.*?)\\end{tabular\*?}',
|
| 87 |
+
re.DOTALL
|
| 88 |
+
)
|
| 89 |
+
md_table_reg = re.compile(
|
| 90 |
+
r'\|\s*.*?\s*\|\n',
|
| 91 |
+
re.DOTALL)
|
| 92 |
+
html_table_reg = re.compile(
|
| 93 |
+
r'(<table.*?</table>)',
|
| 94 |
+
re.DOTALL
|
| 95 |
+
)
|
| 96 |
+
|
| 97 |
+
# title
|
| 98 |
+
title_reg = re.compile(
|
| 99 |
+
r'^\s*#.*$',
|
| 100 |
+
re.MULTILINE)
|
| 101 |
+
|
| 102 |
+
# img
|
| 103 |
+
img_pattern = r'!\[.*?\]\(.*?\)'
|
| 104 |
+
|
| 105 |
+
# code block
|
| 106 |
+
code_block_reg = re.compile(
|
| 107 |
+
r'```(\w+)\n(.*?)```',
|
| 108 |
+
re.DOTALL
|
| 109 |
+
)
|
| 110 |
+
|
| 111 |
+
def md_tex_filter(content):
|
| 112 |
+
'''
|
| 113 |
+
Input: 1 page md or tex content - String
|
| 114 |
+
Output: text, display, inline, table, title, code - list
|
| 115 |
+
'''
|
| 116 |
+
content = re.sub(img_pattern, '', content) # remove image
|
| 117 |
+
content = remove_markdown_fences(content) # remove markdown fences
|
| 118 |
+
content = replace_repeated_chars(content) # replace all consecutive characters
|
| 119 |
+
content = content.replace('<html>', '').replace('</html>', '').replace('<body>', '').replace('</body>', '')
|
| 120 |
+
|
| 121 |
+
# # 使用正则表达式对unicode进行替换
|
| 122 |
+
# special_unicode = ''.join(unicode_replacements.keys())
|
| 123 |
+
# content = re.sub(f'[{special_unicode}]', replace_unicode, content)
|
| 124 |
+
|
| 125 |
+
# content = fullwidth_to_halfwidth(content) # fullwidth to halfwidth, TODO: GT also needs this operation
|
| 126 |
+
|
| 127 |
+
# # pylatexenc's unicode to latex
|
| 128 |
+
# content = unicode_to_latex(content, unknown_char_warning=False)
|
| 129 |
+
# markdown_table_content[i, j] = LatexNodes2Text().latex_to_text(content_str)
|
| 130 |
+
# content_ori = copy.deepcopy(content)
|
| 131 |
+
|
| 132 |
+
# print('--------------After pre_process: \n', content)
|
| 133 |
+
|
| 134 |
+
pred_all = []
|
| 135 |
+
# deal with inline formula
|
| 136 |
+
# content_new, inline_array = inline_filter_unicode(content)
|
| 137 |
+
# #print('------------inline_array----------------',inline_array)
|
| 138 |
+
# for inline_item in inline_array:
|
| 139 |
+
# inline_item['content'] = inline_to_unicode(inline_item['content'])
|
| 140 |
+
# #print('------------inline_array_unicode----------------',inline_item['content'])
|
| 141 |
+
# pred_all.append({
|
| 142 |
+
# 'category_type': 'text_all',
|
| 143 |
+
# 'position': inline_item['position'],
|
| 144 |
+
# 'content': inline_item['content'],
|
| 145 |
+
# 'fine_category_type': 'equation_inline'
|
| 146 |
+
# })
|
| 147 |
+
|
| 148 |
+
# extract latex table
|
| 149 |
+
latex_table_array, table_positions = extract_tex_table(content)
|
| 150 |
+
for latex_table, position in zip(latex_table_array, table_positions):
|
| 151 |
+
position = [position[0], position[0]+len(latex_table)] # !!!
|
| 152 |
+
pred_all.append({
|
| 153 |
+
'category_type': 'latex_table',
|
| 154 |
+
'position': position,
|
| 155 |
+
'content': latex_table
|
| 156 |
+
})
|
| 157 |
+
content = content[:position[0]] + ' '*(position[1]-position[0]) + content[position[1]:] # replace latex table with space
|
| 158 |
+
|
| 159 |
+
# print('--------After latex table: \n', content)
|
| 160 |
+
# print('-------latex_table_array: \n', latex_table_array)
|
| 161 |
+
|
| 162 |
+
# extract html table
|
| 163 |
+
html_table_array, table_positions = extract_html_table(content)
|
| 164 |
+
for html_table, position in zip(html_table_array, table_positions):
|
| 165 |
+
position = [position[0], position[0]+len(html_table)]
|
| 166 |
+
pred_all.append({
|
| 167 |
+
'category_type': 'html_table',
|
| 168 |
+
'position': position,
|
| 169 |
+
'content': html_table
|
| 170 |
+
})
|
| 171 |
+
content = content[:position[0]] + ' '*(position[1]-position[0]) + content[position[1]:] # replace html table with space
|
| 172 |
+
# html_table_array = []
|
| 173 |
+
# html_table_matches = html_table_reg.finditer(content)
|
| 174 |
+
# if html_table_matches:
|
| 175 |
+
# for match in html_table_matches:
|
| 176 |
+
# matched = match.group(0)
|
| 177 |
+
# position = [match.start(), match.end()]
|
| 178 |
+
# html_table_array.append(matched.strip())
|
| 179 |
+
# # content = content.replace(matched, ' '*len(matched)) # replace html table with space
|
| 180 |
+
# content = content[:position[0]] + ' '*(position[1]-position[0]) + content[position[1]:] # replace html table with space
|
| 181 |
+
# pred_all.append({
|
| 182 |
+
# 'category_type': 'html_table',
|
| 183 |
+
# 'position': position,
|
| 184 |
+
# 'content': matched.strip()
|
| 185 |
+
# })
|
| 186 |
+
|
| 187 |
+
# print('--------------After html table: \n', content)
|
| 188 |
+
# # extract tables in latex and html
|
| 189 |
+
# table_array = []
|
| 190 |
+
# table_matches = table_reg.finditer(content)
|
| 191 |
+
# tables = ""
|
| 192 |
+
# for match in table_matches:
|
| 193 |
+
# matched = match.group(0)
|
| 194 |
+
# if matched:
|
| 195 |
+
# tables += matched
|
| 196 |
+
# tables += "\n\n"
|
| 197 |
+
# table_array.append(matched)
|
| 198 |
+
# content = content.replace(matched, '')
|
| 199 |
+
|
| 200 |
+
# extract interline formula
|
| 201 |
+
display_matches = display_reg.finditer(content)
|
| 202 |
+
content_copy = content
|
| 203 |
+
for match in display_matches:
|
| 204 |
+
matched = match.group(0)
|
| 205 |
+
if matched:
|
| 206 |
+
# single_line = ''.join(matched.split())
|
| 207 |
+
single_line = ' '.join(matched.strip().split('\n'))
|
| 208 |
+
position = [match.start(), match.end()]
|
| 209 |
+
# replace $$ with \[\]
|
| 210 |
+
dollar_pattern = re.compile(r'\$\$(.*?)\$\$|\$(.*?)\$|\\\((.*?)\\\)', re.DOTALL)
|
| 211 |
+
sub_match = dollar_pattern.search(single_line)
|
| 212 |
+
if sub_match is None:
|
| 213 |
+
# pass
|
| 214 |
+
content = content[:position[0]] + ' '*(position[1]-position[0]) + content[position[1]:]
|
| 215 |
+
pred_all.append({
|
| 216 |
+
'category_type': 'equation_isolated',
|
| 217 |
+
'position': position,
|
| 218 |
+
'content': single_line
|
| 219 |
+
})
|
| 220 |
+
elif sub_match.group(1):
|
| 221 |
+
single_line = re.sub(dollar_pattern, r'\\[\1\\]', single_line)
|
| 222 |
+
content = content[:position[0]] + ' '*(position[1]-position[0]) + content[position[1]:] # replace equation with space
|
| 223 |
+
pred_all.append({
|
| 224 |
+
'category_type': 'equation_isolated',
|
| 225 |
+
'position': position,
|
| 226 |
+
'content': single_line
|
| 227 |
+
})
|
| 228 |
+
else:
|
| 229 |
+
# start, end = match.span()
|
| 230 |
+
# char_before = content_copy[start-1] if start > 0 else '\n'
|
| 231 |
+
# char_after = content_copy[end] if end < len(content_copy) else '\n'
|
| 232 |
+
# if char_before == '\n' or char_after == '\n':
|
| 233 |
+
# single_line = re.sub(dollar_pattern, r'\\[\2\3\\]', single_line)
|
| 234 |
+
# pred_all.append({
|
| 235 |
+
# 'category_type': 'equation_isolated',
|
| 236 |
+
# 'position': position,
|
| 237 |
+
# 'content': single_line,
|
| 238 |
+
# 'fine_category_type': 'equation_inline'
|
| 239 |
+
# })
|
| 240 |
+
single_line = re.sub(dollar_pattern, r'\\[\2\3\\]', single_line)
|
| 241 |
+
pred_all.append({
|
| 242 |
+
'category_type': 'equation_isolated',
|
| 243 |
+
'position': position,
|
| 244 |
+
'content': single_line,
|
| 245 |
+
'fine_category_type': 'equation_inline'
|
| 246 |
+
})
|
| 247 |
+
# single_line = re.sub(dollar_pattern, r'\\[\1\2\3\\]', single_line)
|
| 248 |
+
# print('single_line: ', single_line)
|
| 249 |
+
# content = content.replace(matched, ' '*len(matched))
|
| 250 |
+
# pred_all.append({
|
| 251 |
+
# 'category_type': 'equation_isolated',
|
| 252 |
+
# 'position': position,
|
| 253 |
+
# 'content': single_line
|
| 254 |
+
# })
|
| 255 |
+
# print('-----Found display formula: ', matched)
|
| 256 |
+
|
| 257 |
+
# print('-------------After display: \n', content)
|
| 258 |
+
# extract md table with ||
|
| 259 |
+
md_table_mathces = md_table_reg.findall(content+'\n')
|
| 260 |
+
if len(md_table_mathces) >= 2:
|
| 261 |
+
# print("md table found!")
|
| 262 |
+
# print("content:", content)
|
| 263 |
+
content = convert_markdown_to_html(content)
|
| 264 |
+
# print('----------content after converting md table to html:', content)
|
| 265 |
+
html_table_matches = html_table_reg.finditer(content)
|
| 266 |
+
if html_table_matches:
|
| 267 |
+
for match in html_table_matches:
|
| 268 |
+
matched = match.group(0)
|
| 269 |
+
position = [match.start(), match.end()]
|
| 270 |
+
# content = content.replace(match, '')
|
| 271 |
+
# print('content after removing the md table:', content)
|
| 272 |
+
content = content[:position[0]] + ' '*(position[1]-position[0]) + content[position[1]:] # replace md table with space
|
| 273 |
+
pred_all.append({
|
| 274 |
+
'category_type': 'html_table',
|
| 275 |
+
'position': position,
|
| 276 |
+
'content': matched.strip(),
|
| 277 |
+
'fine_category_type': 'md2html_table'
|
| 278 |
+
})
|
| 279 |
+
# print('---------After md table: \n', content)
|
| 280 |
+
|
| 281 |
+
# extract code blocks
|
| 282 |
+
code_matches = code_block_reg.finditer(content)
|
| 283 |
+
if code_matches:
|
| 284 |
+
for match in code_matches:
|
| 285 |
+
position = [match.start(), match.end()]
|
| 286 |
+
language = match.group(1)
|
| 287 |
+
code = match.group(2).strip()
|
| 288 |
+
# content = content.replace(match.group(0), '')
|
| 289 |
+
content = content[:position[0]] + ' '*(position[1]-position[0]) + content[position[1]:] # replace code block with space
|
| 290 |
+
pred_all.append({
|
| 291 |
+
'category_type': 'text_all',
|
| 292 |
+
'position': position,
|
| 293 |
+
'content': code,
|
| 294 |
+
'language': language,
|
| 295 |
+
'fine_category_type': 'code'
|
| 296 |
+
})
|
| 297 |
+
|
| 298 |
+
# print('-------After code block: \n', content)
|
| 299 |
+
|
| 300 |
+
# # Extract titles: Do not extract titles, as some models do not wrap code blocks, causing all comments to be treated as titles
|
| 301 |
+
# title_matches = title_reg.finditer(content)
|
| 302 |
+
# if title_matches:
|
| 303 |
+
# for match in title_matches:
|
| 304 |
+
# position = [match.start(), match.end()]
|
| 305 |
+
# matched = match.group(0)
|
| 306 |
+
# matched = matched.replace("#", "").strip()
|
| 307 |
+
# # content = content.replace(match, '')
|
| 308 |
+
# # print('content after removing the titles:', content)
|
| 309 |
+
# if matched:
|
| 310 |
+
# # print('Add title: ', matched)
|
| 311 |
+
# content = content[:position[0]] + ' '*(position[1]-position[0]) + content[position[1]:]
|
| 312 |
+
# pred_all.append({
|
| 313 |
+
# 'category_type': 'text_all',
|
| 314 |
+
# 'position': position,
|
| 315 |
+
# 'content': matched,
|
| 316 |
+
# 'fine_category_type': 'title'
|
| 317 |
+
# })
|
| 318 |
+
|
| 319 |
+
# print('----------After title: \n', content)
|
| 320 |
+
|
| 321 |
+
# # Delete extracted content
|
| 322 |
+
# extracted_position = [_['position'] for _ in pred_all]
|
| 323 |
+
# for start, end in sorted(extracted_position, reverse=True):
|
| 324 |
+
# content = content[:start] + content[end:]
|
| 325 |
+
|
| 326 |
+
# print('----------After delete extracted: \n', content)
|
| 327 |
+
|
| 328 |
+
# Remove latex style
|
| 329 |
+
content = re.sub(r'\\title\{(.*?)\}', r'\1', content)
|
| 330 |
+
content = re.sub(r'\\title\s*\{\s*(.*?)\s*\}', r'\1', content, flags=re.DOTALL)
|
| 331 |
+
content = re.sub(r'\\text\s*\{\s*(.*?)\s*\}', r'\1', content, flags=re.DOTALL)
|
| 332 |
+
content = re.sub(r'\\section\*?\{(.*?)\}', r'\1', content)
|
| 333 |
+
content = re.sub(r'\\section\*?\{\s*(.*?)\s*\}', r'\1', content, flags=re.DOTALL)
|
| 334 |
+
|
| 335 |
+
# extract texts
|
| 336 |
+
res = content.split('\n\n')
|
| 337 |
+
if len(res) == 1:
|
| 338 |
+
res = content.split('\n') # some models do not use double newlines, so use single newlines to split
|
| 339 |
+
|
| 340 |
+
content_position = 0
|
| 341 |
+
for text in res:
|
| 342 |
+
position = [content_position, content_position+len(text)]
|
| 343 |
+
content_position += len(text)
|
| 344 |
+
text = text.strip()
|
| 345 |
+
text = text.strip('\n')
|
| 346 |
+
# print('ori_text: ', text)
|
| 347 |
+
text = '\n'.join([_.strip() for _ in text.split('\n') if _.strip()]) # avoid some single newline content with many spaces
|
| 348 |
+
# print('after strip text: ', text)
|
| 349 |
+
|
| 350 |
+
if text: # Check if the stripped text is not empty
|
| 351 |
+
if text.startswith('<table') and text.endswith('</table>'):
|
| 352 |
+
pred_all.append({
|
| 353 |
+
'category_type': 'html_table',
|
| 354 |
+
'position': position,
|
| 355 |
+
'content': text,
|
| 356 |
+
})
|
| 357 |
+
# elif text.startswith('#') and '\n' not in text:
|
| 358 |
+
# text = text.replace('#', '').strip()
|
| 359 |
+
# if text:
|
| 360 |
+
# # print('Add title: ', matched)
|
| 361 |
+
# pred_all.append({
|
| 362 |
+
# 'category_type': 'text_all',
|
| 363 |
+
# 'position': position,
|
| 364 |
+
# 'content': text,
|
| 365 |
+
# 'fine_category_type': 'title'
|
| 366 |
+
# })
|
| 367 |
+
elif text.startswith('$') and text.endswith('$'):
|
| 368 |
+
if text.replace('$', '').strip():
|
| 369 |
+
pred_all.append({
|
| 370 |
+
'category_type': 'equation_isolated',
|
| 371 |
+
'position': position,
|
| 372 |
+
'content': text.strip(),
|
| 373 |
+
})
|
| 374 |
+
else:
|
| 375 |
+
text = text.strip()
|
| 376 |
+
if text:
|
| 377 |
+
pred_all.append({
|
| 378 |
+
'category_type': 'text_all',
|
| 379 |
+
'position': position,
|
| 380 |
+
'content': text,
|
| 381 |
+
'fine_category_type': 'text_block'
|
| 382 |
+
})
|
| 383 |
+
# if '$' in text:
|
| 384 |
+
# for formula in re.findall(r'\$(.*?)\$', text):
|
| 385 |
+
# formula_array.append(formula)
|
| 386 |
+
|
| 387 |
+
pred_dataset = defaultdict(list)
|
| 388 |
+
pred_all = sorted(pred_all, key=lambda x: x['position'][0])
|
| 389 |
+
for item in pred_all:
|
| 390 |
+
pred_dataset[item['category_type']].append(item)
|
| 391 |
+
# pdb.set_trace()
|
| 392 |
+
return pred_dataset
|
| 393 |
+
|
| 394 |
+
|
| 395 |
+
# def replace_or_extract(match):
|
| 396 |
+
# content = match.group(1) if match.group(1) is not None else match.group(2)
|
| 397 |
+
|
| 398 |
+
# if any(char in content for char in r'\^_'):
|
| 399 |
+
# inline_array.append(match.group(0))
|
| 400 |
+
# return ''
|
| 401 |
+
# else:
|
| 402 |
+
# return content
|
| 403 |
+
|
| 404 |
+
# extract inline math equations in text
|
| 405 |
+
# def inline_filter(text):
|
| 406 |
+
|
| 407 |
+
# inline_array = []
|
| 408 |
+
# inline_matches = inline_reg.finditer(text)
|
| 409 |
+
# for match in inline_matches:
|
| 410 |
+
# content = match.group(1) if match.group(1) is not None else match.group(2)
|
| 411 |
+
|
| 412 |
+
# # remove \\, \_, \&, \%, \^
|
| 413 |
+
# clean_content = re.sub(r'\\([\\_&%^])', '', content)
|
| 414 |
+
|
| 415 |
+
# if any(char in clean_content for char in r'\^_'):
|
| 416 |
+
# inline_array.append(match.group(0))
|
| 417 |
+
# text = text.replace(match.group(0), '')
|
| 418 |
+
# else:
|
| 419 |
+
# text = text.replace(match.group(0), content)
|
| 420 |
+
|
| 421 |
+
# return text, inline_array
|
| 422 |
+
|
| 423 |
+
# def extract_tex_table(content):
|
| 424 |
+
# tables = []
|
| 425 |
+
# positions = []
|
| 426 |
+
|
| 427 |
+
# walker = LatexWalker(content)
|
| 428 |
+
# nodes, _, _ = walker.get_latex_nodes()
|
| 429 |
+
# if nodes is None:
|
| 430 |
+
# return tables, positions
|
| 431 |
+
|
| 432 |
+
# for node in nodes:
|
| 433 |
+
# if isinstance(node, LatexEnvironmentNode) and (
|
| 434 |
+
# node.environmentname == 'tabular' or node.environmentname == 'table'):
|
| 435 |
+
# # table_latex = extract_node_content(node)
|
| 436 |
+
# table_latex = content[node.pos:node.pos_end]
|
| 437 |
+
# tables.append(table_latex)
|
| 438 |
+
# start_pos = node.pos
|
| 439 |
+
# end_pos = get_node_end_pos(node)
|
| 440 |
+
# positions.append((start_pos, end_pos))
|
| 441 |
+
|
| 442 |
+
# return tables, positions
|
| 443 |
+
|
| 444 |
+
def extract_tex_table(content):
|
| 445 |
+
tables = []
|
| 446 |
+
tables_positions = []
|
| 447 |
+
|
| 448 |
+
pattern = r'\\begin{table}(.*?)\\end{table}'
|
| 449 |
+
for match in re.finditer(pattern, content, re.DOTALL):
|
| 450 |
+
start_pos = match.start()
|
| 451 |
+
end_pos = match.end()
|
| 452 |
+
table_content = match.group(0)
|
| 453 |
+
tables.append(table_content)
|
| 454 |
+
tables_positions.append((start_pos, end_pos))
|
| 455 |
+
content = content[:start_pos] + ' '*(end_pos-start_pos) + content[end_pos:]
|
| 456 |
+
|
| 457 |
+
tabulars, tabular_positions = extract_tabular(content)
|
| 458 |
+
all_tables = tables + tabulars
|
| 459 |
+
all_positions = tables_positions + tabular_positions
|
| 460 |
+
|
| 461 |
+
all_result = sorted([[pos, table]for pos, table in zip(all_positions, all_tables)], key=lambda x: x[0][0])
|
| 462 |
+
all_tables = [x[1] for x in all_result]
|
| 463 |
+
all_positions = [x[0] for x in all_result]
|
| 464 |
+
|
| 465 |
+
return all_tables, all_positions
|
| 466 |
+
|
| 467 |
+
# def extract_html_table(content):
|
| 468 |
+
# soup = BeautifulSoup(content, 'html.parser')
|
| 469 |
+
# all_tables = soup.find_all('table')
|
| 470 |
+
# tables = []
|
| 471 |
+
# positions = []
|
| 472 |
+
|
| 473 |
+
# for table in all_tables:
|
| 474 |
+
# if table.find_parent('table') is None:
|
| 475 |
+
# table_str = str(table)
|
| 476 |
+
# start_pos = content.find(table_str)
|
| 477 |
+
# end_pos = start_pos + len(table_str)
|
| 478 |
+
|
| 479 |
+
# tables.append(table_str)
|
| 480 |
+
# positions.append((start_pos, end_pos))
|
| 481 |
+
# return tables, positions
|
| 482 |
+
|
| 483 |
+
def extract_html_table(text):
|
| 484 |
+
begin_pattern = r'<table(?:[^>]*)>'
|
| 485 |
+
end_pattern = r'</table>'
|
| 486 |
+
|
| 487 |
+
tabulars = []
|
| 488 |
+
positions = []
|
| 489 |
+
current_pos = 0
|
| 490 |
+
stack = []
|
| 491 |
+
|
| 492 |
+
while current_pos < len(text):
|
| 493 |
+
begin_match = re.search(begin_pattern, text[current_pos:])
|
| 494 |
+
end_match = re.search(end_pattern, text[current_pos:])
|
| 495 |
+
|
| 496 |
+
if not begin_match and not end_match:
|
| 497 |
+
break
|
| 498 |
+
|
| 499 |
+
if begin_match and (not end_match or begin_match.start() < end_match.start()):
|
| 500 |
+
stack.append(current_pos + begin_match.start())
|
| 501 |
+
current_pos += begin_match.start() + len(end_pattern)
|
| 502 |
+
elif end_match:
|
| 503 |
+
if stack:
|
| 504 |
+
start_pos = stack.pop()
|
| 505 |
+
if not stack:
|
| 506 |
+
end_pos = current_pos + end_match.start() + len(end_pattern)
|
| 507 |
+
tabular_code = text[start_pos:end_pos]
|
| 508 |
+
tabulars.append(tabular_code)
|
| 509 |
+
positions.append((start_pos, end_pos))
|
| 510 |
+
current_pos += end_match.start() + len(end_pattern)
|
| 511 |
+
else:
|
| 512 |
+
current_pos += 1
|
| 513 |
+
|
| 514 |
+
if stack:
|
| 515 |
+
new_start = stack[0] + len(begin_pattern)
|
| 516 |
+
new_tabulars, new_positions = extract_html_table(text[new_start:])
|
| 517 |
+
new_positions = [(start + new_start, end + new_start) for start, end in new_positions]
|
| 518 |
+
tabulars.extend(new_tabulars)
|
| 519 |
+
positions.extend(new_positions)
|
| 520 |
+
|
| 521 |
+
return tabulars, positions
|
| 522 |
+
|
| 523 |
+
|
| 524 |
+
def extract_node_content(node):
|
| 525 |
+
""" Recursively extract content from LatexEnvironmentNode and rebuild LaTeX table representation """
|
| 526 |
+
if isinstance(node, LatexCharsNode):
|
| 527 |
+
return node.chars # Use chars attribute
|
| 528 |
+
elif isinstance(node, LatexGroupNode):
|
| 529 |
+
return "{" + "".join(extract_node_content(n) for n in node.nodelist) + "}"
|
| 530 |
+
elif isinstance(node, LatexMacroNode):
|
| 531 |
+
# Extract macro command and its arguments
|
| 532 |
+
macro_content = "\\" + node.macroname
|
| 533 |
+
if node.nodeargs:
|
| 534 |
+
macro_content += "".join([extract_node_content(arg) for arg in node.nodeargs])
|
| 535 |
+
return macro_content
|
| 536 |
+
elif isinstance(node, LatexEnvironmentNode):
|
| 537 |
+
# Extract environment, preserve environment name and arguments
|
| 538 |
+
content = "\\begin{" + node.environmentname + "}"
|
| 539 |
+
if node.nodeargd and node.nodeargd.argnlist:
|
| 540 |
+
# content += "".join("{" + extract_node_content(arg) + "}" for arg in node.nodeargd)
|
| 541 |
+
# content += "".join("{" + extract_node_content(node.nodeargd) + "}")
|
| 542 |
+
content += "{" + extract_node_content(node.nodeargd.argnlist[0]) + "}"
|
| 543 |
+
if node.nodelist:
|
| 544 |
+
content += "".join(extract_node_content(n) for n in node.nodelist)
|
| 545 |
+
content += "\\end{" + node.environmentname + "}"
|
| 546 |
+
return content
|
| 547 |
+
elif isinstance(node, LatexSpecialsNode): # Changed to LatexSpecialsNode
|
| 548 |
+
return node.specials_chars
|
| 549 |
+
else:
|
| 550 |
+
return ""
|
| 551 |
+
|
| 552 |
+
def get_node_end_pos(node):
|
| 553 |
+
"""Recursively determine the end position of a node"""
|
| 554 |
+
if hasattr(node, 'nodelist') and node.nodelist:
|
| 555 |
+
# If the node has child nodes, recursively find the end position of the last child node
|
| 556 |
+
return get_node_end_pos(node.nodelist[-1])
|
| 557 |
+
elif hasattr(node, 'pos_end'):
|
| 558 |
+
# If the node has pos_end attribute, return it directly
|
| 559 |
+
return node.pos_end
|
| 560 |
+
else:
|
| 561 |
+
# If there are no child nodes, assume the node ends at the last character of its content
|
| 562 |
+
return node.pos + len(str(node))
|
| 563 |
+
|
| 564 |
+
def remove_tex_table(content):
|
| 565 |
+
tables, positions = extract_tex_table(content)
|
| 566 |
+
|
| 567 |
+
# Delete in reverse order by position to avoid affecting unprocessed start positions
|
| 568 |
+
for start, end in sorted(positions, reverse=True):
|
| 569 |
+
content = content[:start] + content[end:] # Remove table content
|
| 570 |
+
|
| 571 |
+
return content
|
FinixDocBench_Eval_for_Markdown/finixdoc_md_eval/utils/match.py
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from scipy.optimize import linear_sum_assignment
|
| 2 |
+
import Levenshtein
|
| 3 |
+
import numpy as np
|
| 4 |
+
import re
|
| 5 |
+
import sys
|
| 6 |
+
import pdb
|
| 7 |
+
from .data_preprocess import textblock_with_norm_formula, normalized_formula, textblock2unicode, clean_string
|
| 8 |
+
import re
|
| 9 |
+
from bs4 import BeautifulSoup
|
| 10 |
+
from copy import deepcopy
|
| 11 |
+
|
| 12 |
+
def get_pred_category_type(pred_idx, pred_items):
|
| 13 |
+
if pred_items[pred_idx].get('fine_category_type'):
|
| 14 |
+
pred_pred_category_type = pred_items[pred_idx]['fine_category_type']
|
| 15 |
+
else:
|
| 16 |
+
pred_pred_category_type = pred_items[pred_idx]['category_type']
|
| 17 |
+
return pred_pred_category_type
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def compute_edit_distance_matrix_new(gt_lines, matched_lines):
|
| 21 |
+
try:
|
| 22 |
+
distance_matrix = np.zeros((len(gt_lines), len(matched_lines)))
|
| 23 |
+
for i, gt_line in enumerate(gt_lines):
|
| 24 |
+
for j, matched_line in enumerate(matched_lines):
|
| 25 |
+
if len(gt_line) == 0 and len(matched_line) == 0:
|
| 26 |
+
distance_matrix[i][j] = 0
|
| 27 |
+
else:
|
| 28 |
+
distance_matrix[i][j] = Levenshtein.distance(gt_line, matched_line) / max(len(matched_line), len(gt_line))
|
| 29 |
+
return distance_matrix
|
| 30 |
+
except ZeroDivisionError:
|
| 31 |
+
raise
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
## 混合匹配here 0403
|
| 35 |
+
def get_gt_pred_lines(gt_mix,pred_dataset_mix,line_type):
|
| 36 |
+
|
| 37 |
+
norm_html_lines,gt_lines,pred_lines,norm_gt_lines,norm_pred_lines,gt_cat_list = [],[],[],[],[],[]
|
| 38 |
+
if line_type in ['html_table','latex_table']:
|
| 39 |
+
for item in gt_mix:
|
| 40 |
+
if item.get('fine_category_type'):
|
| 41 |
+
gt_cat_list.append(item['fine_category_type'])
|
| 42 |
+
else:
|
| 43 |
+
gt_cat_list.append(item['category_type'])
|
| 44 |
+
if item.get('content'):
|
| 45 |
+
gt_lines.append(str(item['content']))
|
| 46 |
+
norm_html_lines.append(str(item['content']))
|
| 47 |
+
elif line_type == 'text':
|
| 48 |
+
gt_lines.append(str(item['text']))
|
| 49 |
+
elif line_type == 'html_table':
|
| 50 |
+
gt_lines.append(str(item['html']))
|
| 51 |
+
elif line_type == 'formula':
|
| 52 |
+
gt_lines.append(str(item['latex']))
|
| 53 |
+
elif line_type == 'latex_table':
|
| 54 |
+
try:
|
| 55 |
+
gt_lines.append(str(item['latex']))
|
| 56 |
+
except:
|
| 57 |
+
print(item)
|
| 58 |
+
gt_lines.append("")
|
| 59 |
+
norm_html_lines.append(str(item['html']))
|
| 60 |
+
|
| 61 |
+
pred_lines = [str(item['content']) for item in pred_dataset_mix]
|
| 62 |
+
if line_type == 'formula':
|
| 63 |
+
norm_gt_lines = [normalized_formula(_) for _ in gt_lines]
|
| 64 |
+
norm_pred_lines = [normalized_formula(_) for _ in pred_lines]
|
| 65 |
+
elif line_type == 'text':
|
| 66 |
+
norm_gt_lines = [clean_string(textblock2unicode(_)) for _ in gt_lines]
|
| 67 |
+
norm_pred_lines = [clean_string(textblock2unicode(_)) for _ in pred_lines]
|
| 68 |
+
else:
|
| 69 |
+
norm_gt_lines = gt_lines
|
| 70 |
+
norm_pred_lines = pred_lines
|
| 71 |
+
if line_type == 'latex_table':
|
| 72 |
+
gt_lines = norm_html_lines
|
| 73 |
+
|
| 74 |
+
else:
|
| 75 |
+
for item in pred_dataset_mix:
|
| 76 |
+
# text
|
| 77 |
+
if item['category_type'] == 'text_all':
|
| 78 |
+
pred_lines.append(str(item['content']))
|
| 79 |
+
norm_pred_lines.append(clean_string(textblock2unicode(str(item['content']))))
|
| 80 |
+
# formula
|
| 81 |
+
elif item['category_type']=='equation_isolated':
|
| 82 |
+
pred_lines.append(str(item['content']))
|
| 83 |
+
norm_pred_lines.append(normalized_formula(str(item['content'])))
|
| 84 |
+
# table
|
| 85 |
+
else:
|
| 86 |
+
pred_lines.append(str(item['content']))
|
| 87 |
+
norm_pred_lines.append(str(item['content']))
|
| 88 |
+
|
| 89 |
+
for item in gt_mix:
|
| 90 |
+
if item.get('content'):
|
| 91 |
+
gt_lines.append(str(item['content']))
|
| 92 |
+
if item['category_type'] == 'text_all':
|
| 93 |
+
norm_gt_lines.append(clean_string(textblock2unicode(str(item['content']))))
|
| 94 |
+
else:
|
| 95 |
+
norm_gt_lines.append(item['content'])
|
| 96 |
+
|
| 97 |
+
norm_html_lines.append(str(item['content']))
|
| 98 |
+
|
| 99 |
+
if item.get('fine_category_type'):
|
| 100 |
+
gt_cat_list.append(item['fine_category_type'])
|
| 101 |
+
else:
|
| 102 |
+
gt_cat_list.append(item['category_type'])
|
| 103 |
+
# text
|
| 104 |
+
elif item['category_type'] in ['text_block', 'title', 'code_txt', 'code_txt_caption', 'reference', 'equation_caption','figure_caption', 'figure_footnote', 'table_caption', 'table_footnote', 'code_algorithm', 'code_algorithm_caption','header', 'footer', 'page_footnote', 'page_number']:
|
| 105 |
+
gt_lines.append(str(item['text']))
|
| 106 |
+
norm_gt_lines.append(clean_string(textblock2unicode(str(item['text']))))
|
| 107 |
+
|
| 108 |
+
if item.get('fine_category_type'):
|
| 109 |
+
gt_cat_list.append(item['fine_category_type'])
|
| 110 |
+
else:
|
| 111 |
+
gt_cat_list.append(item['category_type'])
|
| 112 |
+
|
| 113 |
+
# formula
|
| 114 |
+
elif item['category_type'] == 'equation_isolated':
|
| 115 |
+
gt_lines.append(str(item['latex']))
|
| 116 |
+
norm_gt_lines.append(normalized_formula(str(item['latex'])))
|
| 117 |
+
|
| 118 |
+
if item.get('fine_category_type'):
|
| 119 |
+
gt_cat_list.append(item['fine_category_type'])
|
| 120 |
+
else:
|
| 121 |
+
gt_cat_list.append(item['category_type'])
|
| 122 |
+
# table
|
| 123 |
+
# elif item['category_type'] == 'table':
|
| 124 |
+
# gt_lines.append(str(item['html']))
|
| 125 |
+
# norm_gt_lines.append(str(item['html']))
|
| 126 |
+
|
| 127 |
+
# if item.get('fine_category_type'):
|
| 128 |
+
# gt_cat_list.append(item['fine_category_type'])
|
| 129 |
+
# else:
|
| 130 |
+
# gt_cat_list.append(item['category_type'])
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
filtered_lists = [(a, b, c) for a, b, c in zip(gt_lines, norm_gt_lines, gt_cat_list) if a and b]
|
| 134 |
+
|
| 135 |
+
# decompress to three lists
|
| 136 |
+
if filtered_lists:
|
| 137 |
+
gt_lines_c, norm_gt_lines_c, gt_cat_list_c = zip(*filtered_lists)
|
| 138 |
+
|
| 139 |
+
# convert to lists
|
| 140 |
+
gt_lines_c = list(gt_lines_c)
|
| 141 |
+
norm_gt_lines_c = list(norm_gt_lines_c)
|
| 142 |
+
gt_cat_list_c = list(gt_cat_list_c)
|
| 143 |
+
else:
|
| 144 |
+
gt_lines_c = []
|
| 145 |
+
norm_gt_lines_c = []
|
| 146 |
+
gt_cat_list_c = []
|
| 147 |
+
|
| 148 |
+
# pred's empty values
|
| 149 |
+
filtered_lists = [(a, b) for a, b in zip(pred_lines, norm_pred_lines) if a and b]
|
| 150 |
+
|
| 151 |
+
# decompress to two lists
|
| 152 |
+
if filtered_lists:
|
| 153 |
+
pred_lines_c, norm_pred_lines_c = zip(*filtered_lists)
|
| 154 |
+
|
| 155 |
+
# convert to lists
|
| 156 |
+
pred_lines_c = list(pred_lines_c)
|
| 157 |
+
norm_pred_lines_c = list(norm_pred_lines_c)
|
| 158 |
+
else:
|
| 159 |
+
pred_lines_c = []
|
| 160 |
+
norm_pred_lines_c = []
|
| 161 |
+
|
| 162 |
+
return gt_lines_c, norm_gt_lines_c, gt_cat_list_c, pred_lines_c, norm_pred_lines_c, gt_mix, pred_dataset_mix
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
def match_gt2pred_simple(gt_items, pred_items, line_type, img_name):
|
| 166 |
+
|
| 167 |
+
gt_lines, norm_gt_lines, gt_cat_list, pred_lines, norm_pred_lines, gt_items, pred_items = get_gt_pred_lines(gt_items, pred_items,line_type)
|
| 168 |
+
match_list = []
|
| 169 |
+
|
| 170 |
+
if not norm_gt_lines: # not matched pred should be concatenate
|
| 171 |
+
pred_idx_list = range(len(norm_pred_lines))
|
| 172 |
+
match_list.append({
|
| 173 |
+
'gt_idx': [""],
|
| 174 |
+
'gt': "",
|
| 175 |
+
'pred_idx': pred_idx_list,
|
| 176 |
+
'pred': ''.join(pred_lines[_] for _ in pred_idx_list),
|
| 177 |
+
'gt_position': [""],
|
| 178 |
+
'pred_position': pred_items[pred_idx_list[0]]['position'][0], # get the first pred's position
|
| 179 |
+
'norm_gt': "",
|
| 180 |
+
'norm_pred': ''.join(norm_pred_lines[_] for _ in pred_idx_list),
|
| 181 |
+
'gt_category_type': "",
|
| 182 |
+
'pred_category_type': get_pred_category_type(pred_idx_list[0], pred_items), # get the first pred's category
|
| 183 |
+
'gt_attribute': [{}],
|
| 184 |
+
'edit': 1,
|
| 185 |
+
'img_id': img_name
|
| 186 |
+
})
|
| 187 |
+
return match_list,None
|
| 188 |
+
elif not norm_pred_lines: # not matched gt should be separated
|
| 189 |
+
for gt_idx in range(len(norm_gt_lines)):
|
| 190 |
+
match_list.append({
|
| 191 |
+
'gt_idx': [gt_idx],
|
| 192 |
+
'gt': gt_lines[gt_idx],
|
| 193 |
+
'pred_idx': [""],
|
| 194 |
+
'pred': "",
|
| 195 |
+
'gt_position': [gt_items[gt_idx].get('order') if gt_items[gt_idx].get('order') else gt_items[gt_idx].get('position', [""])[0]],
|
| 196 |
+
'pred_position': "",
|
| 197 |
+
'norm_gt': norm_gt_lines[gt_idx],
|
| 198 |
+
'norm_pred': "",
|
| 199 |
+
'gt_category_type': gt_cat_list[gt_idx],
|
| 200 |
+
'pred_category_type': "",
|
| 201 |
+
'gt_attribute': [gt_items[gt_idx].get("attribute", {})],
|
| 202 |
+
'edit': 1,
|
| 203 |
+
'img_id': img_name
|
| 204 |
+
})
|
| 205 |
+
return match_list,None
|
| 206 |
+
|
| 207 |
+
cost_matrix = compute_edit_distance_matrix_new(norm_gt_lines, norm_pred_lines)
|
| 208 |
+
|
| 209 |
+
row_ind, col_ind = linear_sum_assignment(cost_matrix)
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
for gt_idx in range(len(norm_gt_lines)):
|
| 213 |
+
if gt_idx in row_ind:
|
| 214 |
+
row_i = list(row_ind).index(gt_idx)
|
| 215 |
+
pred_idx = int(col_ind[row_i])
|
| 216 |
+
pred_line = pred_lines[pred_idx]
|
| 217 |
+
norm_pred_line = norm_pred_lines[pred_idx]
|
| 218 |
+
edit = cost_matrix[gt_idx][pred_idx]
|
| 219 |
+
else:
|
| 220 |
+
pred_idx = ""
|
| 221 |
+
pred_line = ""
|
| 222 |
+
norm_pred_line = ""
|
| 223 |
+
edit = 1
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
match_list.append({
|
| 227 |
+
'gt_idx': [gt_idx],
|
| 228 |
+
'gt': gt_lines[gt_idx],
|
| 229 |
+
'norm_gt': norm_gt_lines[gt_idx],
|
| 230 |
+
'gt_category_type': gt_cat_list[gt_idx],
|
| 231 |
+
'gt_position': [gt_items[gt_idx].get('order') if gt_items[gt_idx].get('order') else gt_items[gt_idx].get('position', [""])[0]],
|
| 232 |
+
'gt_attribute': [gt_items[gt_idx].get("attribute", {})],
|
| 233 |
+
'pred_idx': [pred_idx],
|
| 234 |
+
'pred': pred_line,
|
| 235 |
+
'norm_pred': norm_pred_line,
|
| 236 |
+
'pred_category_type': get_pred_category_type(pred_idx, pred_items) if pred_idx else "",
|
| 237 |
+
'pred_position': pred_items[pred_idx]['position'][0] if pred_idx else "",
|
| 238 |
+
'edit': edit,
|
| 239 |
+
'img_id': img_name
|
| 240 |
+
})
|
| 241 |
+
|
| 242 |
+
pred_idx_list = [pred_idx for pred_idx in range(len(norm_pred_lines)) if pred_idx not in col_ind] # get not matched preds
|
| 243 |
+
if pred_idx_list:
|
| 244 |
+
if line_type in ['html_table', 'latex_table']:
|
| 245 |
+
unmatch_table_pred = []
|
| 246 |
+
for i in pred_idx_list:
|
| 247 |
+
original_item = pred_items[i]
|
| 248 |
+
soup = BeautifulSoup(original_item.get('content'),'html.parser')
|
| 249 |
+
text_block = [re.sub(r'\$\\cdot\$','',item.string).strip() for item in soup.findAll('td') if item.string]
|
| 250 |
+
for concatenate_text in text_block:
|
| 251 |
+
new_item = deepcopy(original_item)
|
| 252 |
+
new_item['content'] = concatenate_text
|
| 253 |
+
new_item['category_type'] = 'text_all'
|
| 254 |
+
unmatch_table_pred.append(new_item)
|
| 255 |
+
return match_list, unmatch_table_pred
|
| 256 |
+
|
| 257 |
+
else:
|
| 258 |
+
match_list.append({
|
| 259 |
+
'gt_idx': [""],
|
| 260 |
+
'gt': "",
|
| 261 |
+
'pred_idx': pred_idx_list,
|
| 262 |
+
'pred': ''.join(pred_lines[_] for _ in pred_idx_list),
|
| 263 |
+
'gt_position': [""],
|
| 264 |
+
'pred_position': pred_items[pred_idx_list[0]]['position'][0], # get the first pred's position
|
| 265 |
+
'norm_gt': "",
|
| 266 |
+
'norm_pred': ''.join(norm_pred_lines[_] for _ in pred_idx_list),
|
| 267 |
+
'gt_category_type': "",
|
| 268 |
+
'pred_category_type': get_pred_category_type(pred_idx_list[0], pred_items), # get the first pred's category
|
| 269 |
+
'gt_attribute': [{}],
|
| 270 |
+
'edit': 1,
|
| 271 |
+
'img_id': img_name
|
| 272 |
+
})
|
| 273 |
+
return match_list,None
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
def match_gt2pred_no_split(gt_items, pred_items, line_type, img_name):
|
| 277 |
+
# directly concatenate gt and pred by position
|
| 278 |
+
gt_lines, norm_gt_lines, gt_cat_list, pred_lines, norm_pred_lines = get_gt_pred_lines(gt_items, pred_items)
|
| 279 |
+
gt_line_with_position = []
|
| 280 |
+
for gt_line, norm_gt_line, gt_item in zip(gt_lines, norm_gt_lines, gt_items):
|
| 281 |
+
gt_position = gt_item['order'] if gt_item.get('order') else gt_item.get('position', [""])[0]
|
| 282 |
+
if gt_position:
|
| 283 |
+
gt_line_with_position.append((gt_position, gt_line, norm_gt_line))
|
| 284 |
+
sorted_gt_lines = sorted(gt_line_with_position, key=lambda x: x[0])
|
| 285 |
+
gt = '\n\n'.join([_[1] for _ in sorted_gt_lines])
|
| 286 |
+
norm_gt = '\n\n'.join([_[2] for _ in sorted_gt_lines])
|
| 287 |
+
pred_line_with_position = [(pred_item['position'], pred_line, pred_norm_line) for pred_line, pred_norm_line, pred_item in zip(pred_lines, norm_pred_lines, pred_items)]
|
| 288 |
+
sorted_pred_lines = sorted(pred_line_with_position, key=lambda x: x[0])
|
| 289 |
+
pred = '\n\n'.join([_[1] for _ in sorted_pred_lines])
|
| 290 |
+
norm_pred = '\n\n'.join([_[2] for _ in sorted_pred_lines])
|
| 291 |
+
# edit = Levenshtein.distance(norm_gt, norm_pred)/max(len(norm_gt), len(norm_pred))
|
| 292 |
+
if norm_gt or norm_pred:
|
| 293 |
+
return [{
|
| 294 |
+
'gt_idx': [0],
|
| 295 |
+
'gt': gt,
|
| 296 |
+
'norm_gt': norm_gt,
|
| 297 |
+
'gt_category_type': "text_merge",
|
| 298 |
+
'gt_position': [""],
|
| 299 |
+
'gt_attribute': [{}],
|
| 300 |
+
'pred_idx': [0],
|
| 301 |
+
'pred': pred,
|
| 302 |
+
'norm_pred': norm_pred,
|
| 303 |
+
'pred_category_type': "text_merge",
|
| 304 |
+
'pred_position': "",
|
| 305 |
+
# 'edit': edit,
|
| 306 |
+
'img_id': img_name
|
| 307 |
+
}]
|
| 308 |
+
else:
|
| 309 |
+
return []
|
| 310 |
+
|
FinixDocBench_Eval_for_Markdown/finixdoc_md_eval/utils/match_quick.py
ADDED
|
@@ -0,0 +1,1292 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from scipy.optimize import linear_sum_assignment
|
| 2 |
+
# from rapidfuzz.distance import Levenshtein
|
| 3 |
+
import Levenshtein
|
| 4 |
+
from collections import defaultdict
|
| 5 |
+
import copy
|
| 6 |
+
from .match import compute_edit_distance_matrix_new, get_gt_pred_lines, get_pred_category_type
|
| 7 |
+
import pdb
|
| 8 |
+
import numpy as np
|
| 9 |
+
from collections import Counter
|
| 10 |
+
from Levenshtein import distance as Levenshtein_distance
|
| 11 |
+
|
| 12 |
+
import re
|
| 13 |
+
from copy import deepcopy
|
| 14 |
+
from typing import List, Dict, Any
|
| 15 |
+
|
| 16 |
+
# ARRAY_RE = re.compile(
|
| 17 |
+
# r'\\begin\{array\}\{[^}]*\}(.*?)\\end\{array\}', re.S
|
| 18 |
+
# )
|
| 19 |
+
|
| 20 |
+
# def split_gt_equation_arrays(data: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
| 21 |
+
# """
|
| 22 |
+
# 拆分带 \\begin{array} … \\end{array} 的 GT 字典条目。
|
| 23 |
+
|
| 24 |
+
# - 仅针对 category_type == 'equation_isolated' 且 latex 含 array。
|
| 25 |
+
# - 每行公式拆出一个新条目:
|
| 26 |
+
# * 更新 'latex'
|
| 27 |
+
# * 若存在 line_with_spans,则同步替换其内部 latex
|
| 28 |
+
# * 'order' 由 7 --> 7.1, 7.2, …
|
| 29 |
+
# """
|
| 30 |
+
# output = []
|
| 31 |
+
|
| 32 |
+
# for item in data:
|
| 33 |
+
# # 只处理满足条件的字典
|
| 34 |
+
# if (item.get("category_type") == "equation_isolated" and
|
| 35 |
+
# "\\begin{array" in item.get("latex", "")):
|
| 36 |
+
|
| 37 |
+
# # 抽取 array 内部内容
|
| 38 |
+
# match = ARRAY_RE.search(item["latex"])
|
| 39 |
+
# if match:
|
| 40 |
+
# body = match.group(1) # 去掉 array 外壳
|
| 41 |
+
# # 按 LaTeX 行分隔符 \\\\ 拆分
|
| 42 |
+
# lines = [ln.strip() for ln in re.split(r'\\\\', body) if ln.strip()]
|
| 43 |
+
|
| 44 |
+
# base_order = float(item["order"]) # 7 -> 7.0,可兼容 float/int
|
| 45 |
+
|
| 46 |
+
# for idx, line in enumerate(lines, start=1):
|
| 47 |
+
# new_item = deepcopy(item)
|
| 48 |
+
# new_item["latex"] = f"\\[{line}\\]"
|
| 49 |
+
# new_item["order"] = round(base_order + idx / 10, 1)
|
| 50 |
+
# output.append(new_item)
|
| 51 |
+
# continue # 跳过把原 item 加入
|
| 52 |
+
# # 其它情况不修改
|
| 53 |
+
# output.append(item)
|
| 54 |
+
|
| 55 |
+
# return output
|
| 56 |
+
|
| 57 |
+
# def _wrap(line: str) -> str:
|
| 58 |
+
# """给单行公式重新包 \\[ ... \\]"""
|
| 59 |
+
# return f"\\[{line.strip()}\\]"
|
| 60 |
+
|
| 61 |
+
# def split_equation_arrays(data: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
| 62 |
+
# """
|
| 63 |
+
# 处理 category_type == 'equation_isolated' 且含 \\begin{array} … 的条目:
|
| 64 |
+
# * 拆分多行公式
|
| 65 |
+
# * 重新包装 content
|
| 66 |
+
# * **重计算 position / positions**
|
| 67 |
+
# """
|
| 68 |
+
# out: List[Dict[str, Any]] = []
|
| 69 |
+
|
| 70 |
+
# for item in data:
|
| 71 |
+
# if (item.get("category_type") == "equation_isolated" and
|
| 72 |
+
# "\\begin{array" in item.get("content", "")):
|
| 73 |
+
|
| 74 |
+
# content = item["content"]
|
| 75 |
+
# m = ARRAY_RE.search(content)
|
| 76 |
+
# if not m:
|
| 77 |
+
# out.append(item)
|
| 78 |
+
# continue
|
| 79 |
+
|
| 80 |
+
# body = m.group(1)
|
| 81 |
+
# lines = [ln.strip() for ln in re.split(r'\\\\', body) if ln.strip()]
|
| 82 |
+
|
| 83 |
+
# # 全局起始字符索引
|
| 84 |
+
# pos_key = "position" if "position" in item else "positions"
|
| 85 |
+
# global_start = item[pos_key][0]
|
| 86 |
+
|
| 87 |
+
# # array 正文在原 content 内的起点
|
| 88 |
+
# body_start_in_content = m.start(1)
|
| 89 |
+
|
| 90 |
+
# search_from = 0 # 在 body 中的游标
|
| 91 |
+
# for ln in lines:
|
| 92 |
+
# # 在 body 中找到当前行的偏移
|
| 93 |
+
# idx_in_body = body.find(ln, search_from)
|
| 94 |
+
# if idx_in_body == -1:
|
| 95 |
+
# # 不太可能发生;保守处理
|
| 96 |
+
# idx_in_body = search_from
|
| 97 |
+
# search_from = idx_in_body + len(ln) # 更新游标
|
| 98 |
+
|
| 99 |
+
# # 计算全局索引
|
| 100 |
+
# line_start_global = global_start + body_start_in_content + idx_in_body
|
| 101 |
+
# line_end_global = line_start_global + len(ln) - 1
|
| 102 |
+
|
| 103 |
+
# new_item = deepcopy(item)
|
| 104 |
+
# new_item["content"] = _wrap(ln)
|
| 105 |
+
# new_item[pos_key] = [line_start_global, line_end_global]
|
| 106 |
+
|
| 107 |
+
# out.append(new_item)
|
| 108 |
+
|
| 109 |
+
# # 拆分完成,不保留原条目
|
| 110 |
+
# continue
|
| 111 |
+
|
| 112 |
+
# # 其它条目直接加入
|
| 113 |
+
# out.append(item)
|
| 114 |
+
|
| 115 |
+
# return out
|
| 116 |
+
|
| 117 |
+
ARRAY_RE = re.compile(
|
| 118 |
+
r'\\begin\{array\}\{(?P<spec>[^}]*)\}(?P<body>.*?)\\end\{array\}',
|
| 119 |
+
re.S
|
| 120 |
+
)
|
| 121 |
+
|
| 122 |
+
def is_all_l(spec: str) -> bool:
|
| 123 |
+
"""检查是否为单列array格式,用于排除矩阵等多列格式。这个函数只拆分单列的array"""
|
| 124 |
+
spec = re.sub(r'\s+|\|', '', spec) # 删空白与竖线
|
| 125 |
+
spec = re.sub(r'@{[^}]*}', '', spec) # 删 @{…} 修饰
|
| 126 |
+
spec = re.sub(r'!{[^}]*}', '', spec) # 删 !{…} 修饰
|
| 127 |
+
# 检查是否为单列基本对齐格式:l, c, r
|
| 128 |
+
return bool(spec) and len(spec) == 1 and spec in {'l', 'c', 'r'}
|
| 129 |
+
|
| 130 |
+
# def is_all_l(spec: str) -> bool:
|
| 131 |
+
# """忽略空格 / 竖线 / @{…} 之后,判断列格式是否只剩基本对齐格式。这个函数会将多行多列的array按行拆分"""
|
| 132 |
+
# spec = re.sub(r'\s+|\|', '', spec) # 删空白与竖线
|
| 133 |
+
# spec = re.sub(r'@{[^}]*}', '', spec) # 删 @{…} 修饰
|
| 134 |
+
# spec = re.sub(r'!{[^}]*}', '', spec) # 删 !{…} 修饰
|
| 135 |
+
# # 检查是否只包含基本对齐格式:l, c, r
|
| 136 |
+
# return bool(spec) and set(spec) <= {'l', 'c', 'r'}
|
| 137 |
+
|
| 138 |
+
def split_gt_equation_arrays(data: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
| 139 |
+
"""
|
| 140 |
+
拆分带 \\begin{array} … \\end{array} 的 GT 字典条目。
|
| 141 |
+
|
| 142 |
+
- 仅针对 category_type == 'equation_isolated' 且 latex 含 array。
|
| 143 |
+
- 每行公式拆出一个新条目:
|
| 144 |
+
* 更新 'latex'
|
| 145 |
+
* 若存在 line_with_spans,则同步替换其内部 latex
|
| 146 |
+
* 'order' 由 7 --> 7.1, 7.2, …
|
| 147 |
+
"""
|
| 148 |
+
output = []
|
| 149 |
+
|
| 150 |
+
for item in data:
|
| 151 |
+
# 只处理满足条件的字典
|
| 152 |
+
if (item.get("category_type") == "equation_isolated" and
|
| 153 |
+
"\\begin{array" in item.get("latex", "")):
|
| 154 |
+
|
| 155 |
+
# 抽取 array 内部内容
|
| 156 |
+
match = ARRAY_RE.search(item["latex"])
|
| 157 |
+
if match:
|
| 158 |
+
|
| 159 |
+
spec = match.group("spec")
|
| 160 |
+
if not is_all_l(spec):
|
| 161 |
+
# 若列里混有 r / c / p{…} 等,直接保留原条目
|
| 162 |
+
output.append(item)
|
| 163 |
+
continue
|
| 164 |
+
|
| 165 |
+
body = match.group("body")
|
| 166 |
+
# body = match.group(1) # 去掉 array 外壳
|
| 167 |
+
# 按 LaTeX 行分隔符 \\\\ 拆分
|
| 168 |
+
lines = [ln.strip() for ln in re.split(r'\\\\', body) if ln.strip()]
|
| 169 |
+
|
| 170 |
+
base_order = float(item["order"]) # 7 -> 7.0,可兼容 float/int
|
| 171 |
+
|
| 172 |
+
for idx, line in enumerate(lines, start=1):
|
| 173 |
+
new_item = deepcopy(item)
|
| 174 |
+
new_item["latex"] = f"\\[{line}\\]"
|
| 175 |
+
new_item["order"] = round(base_order + idx / 10, 1)
|
| 176 |
+
output.append(new_item)
|
| 177 |
+
continue # 跳过把原 item 加入
|
| 178 |
+
# 其它情况不修改
|
| 179 |
+
output.append(item)
|
| 180 |
+
|
| 181 |
+
return output
|
| 182 |
+
|
| 183 |
+
def _wrap(line: str) -> str:
|
| 184 |
+
"""给单行公式重新包 \\[ ... \\]"""
|
| 185 |
+
return f"\\[{line.strip()}\\]"
|
| 186 |
+
|
| 187 |
+
def split_equation_arrays(data: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
| 188 |
+
"""
|
| 189 |
+
处理 category_type == 'equation_isolated' 且含 \\begin{array} … 的条目:
|
| 190 |
+
* 拆分多行公式
|
| 191 |
+
* 重新包装 content
|
| 192 |
+
* **重计算 position / positions**
|
| 193 |
+
"""
|
| 194 |
+
out: List[Dict[str, Any]] = []
|
| 195 |
+
|
| 196 |
+
for item in data:
|
| 197 |
+
if (item.get("category_type") == "equation_isolated" and
|
| 198 |
+
"\\begin{array" in item.get("content", "")):
|
| 199 |
+
|
| 200 |
+
content = item["content"]
|
| 201 |
+
m = ARRAY_RE.search(content)
|
| 202 |
+
if not m:
|
| 203 |
+
out.append(item)
|
| 204 |
+
continue
|
| 205 |
+
|
| 206 |
+
if not is_all_l(m.group('spec')):
|
| 207 |
+
out.append(item)
|
| 208 |
+
continue
|
| 209 |
+
|
| 210 |
+
# body = m.group(1)
|
| 211 |
+
body = m.group('body')
|
| 212 |
+
lines = [ln.strip() for ln in re.split(r'\\\\', body) if ln.strip()]
|
| 213 |
+
|
| 214 |
+
# 全局起始字符索引
|
| 215 |
+
pos_key = "position" if "position" in item else "positions"
|
| 216 |
+
global_start = item[pos_key][0]
|
| 217 |
+
|
| 218 |
+
# array 正文在原 content 内的起点
|
| 219 |
+
# body_start_in_content = m.start(1)
|
| 220 |
+
body_start_in_content = m.start('body')
|
| 221 |
+
|
| 222 |
+
search_from = 0 # 在 body 中的游标
|
| 223 |
+
for ln in lines:
|
| 224 |
+
# 在 body 中找到当前行的偏移
|
| 225 |
+
idx_in_body = body.find(ln, search_from)
|
| 226 |
+
if idx_in_body == -1:
|
| 227 |
+
# 不太可能发生;保守处理
|
| 228 |
+
idx_in_body = search_from
|
| 229 |
+
search_from = idx_in_body + len(ln) # 更新游标
|
| 230 |
+
|
| 231 |
+
# 计算全局索引
|
| 232 |
+
line_start_global = global_start + body_start_in_content + idx_in_body
|
| 233 |
+
line_end_global = line_start_global + len(ln) - 1
|
| 234 |
+
|
| 235 |
+
new_item = deepcopy(item)
|
| 236 |
+
new_item["content"] = _wrap(ln)
|
| 237 |
+
new_item[pos_key] = [line_start_global, line_end_global]
|
| 238 |
+
|
| 239 |
+
out.append(new_item)
|
| 240 |
+
|
| 241 |
+
# 拆分完成,不保留原条目
|
| 242 |
+
continue
|
| 243 |
+
|
| 244 |
+
# 其它条目直接加入
|
| 245 |
+
out.append(item)
|
| 246 |
+
|
| 247 |
+
return out
|
| 248 |
+
|
| 249 |
+
def sort_by_position_skip_inline(items: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
| 250 |
+
"""
|
| 251 |
+
先按 position[0] 从小到大排序;
|
| 252 |
+
若 fine_category_type == 'equation_inline',则统一放到最后,
|
| 253 |
+
并保持它们在原列表中的相对顺序(稳定排序)。
|
| 254 |
+
"""
|
| 255 |
+
# enumerate 保留原始顺序索引,用于 equation_inline “并列时” 的稳定性
|
| 256 |
+
return sorted(
|
| 257 |
+
enumerate(items),
|
| 258 |
+
key=lambda pair: (
|
| 259 |
+
pair[1].get('fine_category_type') == 'equation_inline', # False < True
|
| 260 |
+
pair[1]['position'][0], # 位置起点
|
| 261 |
+
pair[0] # 原序号,确保稳定
|
| 262 |
+
)
|
| 263 |
+
)
|
| 264 |
+
def match_gt2pred_quick(gt_items, pred_items, line_type, img_name):
|
| 265 |
+
# ========== 降级匹配阈值检测 ==========
|
| 266 |
+
# 当 pred_items 过多且远超 gt_items 时,降级为整体匹配,避免 O(m*n) 复杂度过高
|
| 267 |
+
MAX_PRED_ITEMS = 50000 # pred项数超过此值触发检查
|
| 268 |
+
RATIO_THRESHOLD = 100 # pred/gt 比例超过此值则降级
|
| 269 |
+
MAX_TOTAL_LENGTH = 10000000 # 内容总长度超过此值也降级
|
| 270 |
+
MAX_SINGLE_ITEM_LENGTH = 10000000 # 单个项内容超过此值也降级(针对大表格)
|
| 271 |
+
|
| 272 |
+
gt_count = len(gt_items)
|
| 273 |
+
pred_count = len(pred_items)
|
| 274 |
+
|
| 275 |
+
# 计算内容总长度
|
| 276 |
+
def get_item_content(item):
|
| 277 |
+
content = item.get('content')
|
| 278 |
+
if content is None:
|
| 279 |
+
content = item.get('text', '')
|
| 280 |
+
return str(content) if content else ''
|
| 281 |
+
|
| 282 |
+
gt_total_len = sum(len(get_item_content(item)) for item in gt_items)
|
| 283 |
+
pred_total_len = sum(len(get_item_content(item)) for item in pred_items)
|
| 284 |
+
|
| 285 |
+
# 计算单个项最大长度(针对大表格)
|
| 286 |
+
gt_max_len = max((len(get_item_content(item)) for item in gt_items), default=0)
|
| 287 |
+
pred_max_len = max((len(get_item_content(item)) for item in pred_items), default=0)
|
| 288 |
+
|
| 289 |
+
# 判断是否需要降级:项数过多 或 内容过大
|
| 290 |
+
need_downgrade = False
|
| 291 |
+
downgrade_reason = ""
|
| 292 |
+
|
| 293 |
+
if pred_count > MAX_PRED_ITEMS and gt_count > 0 and pred_count > RATIO_THRESHOLD * gt_count:
|
| 294 |
+
need_downgrade = True
|
| 295 |
+
downgrade_reason = f"pred_items({pred_count})/gt_items({gt_count})={pred_count/gt_count:.1f}"
|
| 296 |
+
elif gt_total_len > MAX_TOTAL_LENGTH or pred_total_len > MAX_TOTAL_LENGTH:
|
| 297 |
+
need_downgrade = True
|
| 298 |
+
downgrade_reason = f"content_too_large(gt_len={gt_total_len},pred_len={pred_total_len})"
|
| 299 |
+
elif gt_max_len > MAX_SINGLE_ITEM_LENGTH or pred_max_len > MAX_SINGLE_ITEM_LENGTH:
|
| 300 |
+
# 单个项内容过大(针对大表格导致的慢速编辑距离计算)
|
| 301 |
+
need_downgrade = True
|
| 302 |
+
downgrade_reason = f"single_item_too_large(gt_max={gt_max_len},pred_max={pred_max_len})"
|
| 303 |
+
|
| 304 |
+
if need_downgrade:
|
| 305 |
+
# 判断是否为表格类型
|
| 306 |
+
is_table_type = line_type in ['html_table', 'latex_table']
|
| 307 |
+
|
| 308 |
+
if is_table_type:
|
| 309 |
+
# 表格类型:不允许随意拼接,直接给低分
|
| 310 |
+
# 如果 GT 和 Pred 数量相同,尝试一一配对;否则 TEDS=0
|
| 311 |
+
print(f"[DOWNGRADE-TABLE] {img_name}: {downgrade_reason}, TEDS=0")
|
| 312 |
+
|
| 313 |
+
gt_positions = []
|
| 314 |
+
for item in gt_items:
|
| 315 |
+
pos = item.get('order')
|
| 316 |
+
if pos is None:
|
| 317 |
+
pos = item.get('position', [''])[0] if item.get('position') else ''
|
| 318 |
+
gt_positions.append(pos)
|
| 319 |
+
|
| 320 |
+
pred_positions = []
|
| 321 |
+
for item in pred_items:
|
| 322 |
+
pos = item.get('order')
|
| 323 |
+
if pos is None:
|
| 324 |
+
pos = item.get('position', [''])[0] if item.get('position') else ''
|
| 325 |
+
pred_positions.append(pos)
|
| 326 |
+
|
| 327 |
+
gt_category = gt_items[0].get('fine_category_type') or gt_items[0].get('category_type', line_type) if gt_items else line_type
|
| 328 |
+
pred_category = pred_items[0].get('fine_category_type') or pred_items[0].get('category_type', line_type) if pred_items else line_type
|
| 329 |
+
|
| 330 |
+
# 对于表格,返回一个 TEDS=0 的结果
|
| 331 |
+
gt_all = '\n'.join([get_item_content(item) for item in gt_items])
|
| 332 |
+
pred_all = '\n'.join([get_item_content(item) for item in pred_items])
|
| 333 |
+
|
| 334 |
+
return [{
|
| 335 |
+
'gt_idx': list(range(gt_count)),
|
| 336 |
+
'gt': gt_all,
|
| 337 |
+
'pred_idx': list(range(pred_count)),
|
| 338 |
+
'pred': pred_all,
|
| 339 |
+
'gt_position': gt_positions,
|
| 340 |
+
'pred_position': pred_positions[0] if pred_positions else "",
|
| 341 |
+
'norm_gt': gt_all,
|
| 342 |
+
'norm_pred': pred_all,
|
| 343 |
+
'gt_category_type': gt_category,
|
| 344 |
+
'pred_category_type': pred_category,
|
| 345 |
+
'gt_attribute': [item.get('attribute', {}) for item in gt_items],
|
| 346 |
+
'edit': 1.0, # edit 距离给最大值(表示完全不同)
|
| 347 |
+
'TEDS': 0.0, # TEDS 分数直接给 0
|
| 348 |
+
'img_id': img_name,
|
| 349 |
+
'downgrade': True,
|
| 350 |
+
'downgrade_reason': downgrade_reason
|
| 351 |
+
}]
|
| 352 |
+
else:
|
| 353 |
+
# 非表格类型:拼接后计算 edit_distance
|
| 354 |
+
gt_positions = []
|
| 355 |
+
for item in gt_items:
|
| 356 |
+
pos = item.get('order')
|
| 357 |
+
if pos is None:
|
| 358 |
+
pos = item.get('position', [''])[0] if item.get('position') else ''
|
| 359 |
+
gt_positions.append(pos)
|
| 360 |
+
|
| 361 |
+
pred_positions = []
|
| 362 |
+
for item in pred_items:
|
| 363 |
+
pos = item.get('order')
|
| 364 |
+
if pos is None:
|
| 365 |
+
pos = item.get('position', [''])[0] if item.get('position') else ''
|
| 366 |
+
pred_positions.append(pos)
|
| 367 |
+
|
| 368 |
+
gt_all = '\n'.join([get_item_content(item) for item in gt_items])
|
| 369 |
+
pred_all = '\n'.join([get_item_content(item) for item in pred_items])
|
| 370 |
+
|
| 371 |
+
if not gt_all and not pred_all:
|
| 372 |
+
edit = 0.0
|
| 373 |
+
elif not gt_all or not pred_all:
|
| 374 |
+
edit = 1.0
|
| 375 |
+
else:
|
| 376 |
+
edit_distance = Levenshtein_distance(gt_all, pred_all)
|
| 377 |
+
edit = edit_distance / max(len(gt_all), len(pred_all))
|
| 378 |
+
|
| 379 |
+
gt_category = gt_items[0].get('fine_category_type') or gt_items[0].get('category_type', line_type) if gt_items else line_type
|
| 380 |
+
pred_category = pred_items[0].get('fine_category_type') or pred_items[0].get('category_type', line_type) if pred_items else line_type
|
| 381 |
+
|
| 382 |
+
print(f"[DOWNGRADE] {img_name}: {downgrade_reason}, edit={edit:.4f}")
|
| 383 |
+
|
| 384 |
+
return [{
|
| 385 |
+
'gt_idx': list(range(gt_count)),
|
| 386 |
+
'gt': gt_all,
|
| 387 |
+
'pred_idx': list(range(pred_count)),
|
| 388 |
+
'pred': pred_all,
|
| 389 |
+
'gt_position': gt_positions,
|
| 390 |
+
'pred_position': pred_positions[0] if pred_positions else "",
|
| 391 |
+
'norm_gt': gt_all,
|
| 392 |
+
'norm_pred': pred_all,
|
| 393 |
+
'gt_category_type': gt_category,
|
| 394 |
+
'pred_category_type': pred_category,
|
| 395 |
+
'gt_attribute': [item.get('attribute', {}) for item in gt_items],
|
| 396 |
+
'edit': edit,
|
| 397 |
+
'img_id': img_name,
|
| 398 |
+
'downgrade': True,
|
| 399 |
+
'downgrade_reason': downgrade_reason
|
| 400 |
+
}]
|
| 401 |
+
# ========== 降级匹配检测结束 ==========
|
| 402 |
+
|
| 403 |
+
gt_items = split_gt_equation_arrays(gt_items)
|
| 404 |
+
|
| 405 |
+
# pred_items = sorted(pred_items, key=lambda x: x['position'][0])
|
| 406 |
+
pred_items = [pair[1] for pair in sort_by_position_skip_inline(pred_items)]
|
| 407 |
+
|
| 408 |
+
pred_items = split_equation_arrays(pred_items)
|
| 409 |
+
|
| 410 |
+
# gt_lines, norm_gt_lines, gt_cat_list, pred_lines, norm_pred_lines= get_gt_pred_lines(gt_items, pred_items, line_type)
|
| 411 |
+
gt_lines, norm_gt_lines, gt_cat_list, pred_lines, norm_pred_lines, gt_items, pred_items = get_gt_pred_lines(gt_items, pred_items, None)
|
| 412 |
+
all_gt_indices = set(range(len(norm_gt_lines)))
|
| 413 |
+
all_pred_indices = set(range(len(norm_pred_lines)))
|
| 414 |
+
|
| 415 |
+
if not norm_gt_lines:
|
| 416 |
+
match_list = []
|
| 417 |
+
for pred_idx in range(len(norm_pred_lines)):
|
| 418 |
+
match_list.append({
|
| 419 |
+
'gt_idx': [""],
|
| 420 |
+
'gt': "",
|
| 421 |
+
'pred_idx': [pred_idx],
|
| 422 |
+
'pred': pred_lines[pred_idx],
|
| 423 |
+
'gt_position': [""],
|
| 424 |
+
'pred_position': pred_items[pred_idx]['position'][0],
|
| 425 |
+
'norm_gt': "",
|
| 426 |
+
'norm_pred': norm_pred_lines[pred_idx],
|
| 427 |
+
'gt_category_type': "",
|
| 428 |
+
'pred_category_type': get_pred_category_type(pred_idx, pred_items),
|
| 429 |
+
'gt_attribute': [{}],
|
| 430 |
+
'edit': 1,
|
| 431 |
+
'img_id': img_name
|
| 432 |
+
})
|
| 433 |
+
return match_list
|
| 434 |
+
elif not norm_pred_lines:
|
| 435 |
+
match_list = []
|
| 436 |
+
for gt_idx in range(len(norm_gt_lines)):
|
| 437 |
+
match_list.append({
|
| 438 |
+
'gt_idx': [gt_idx],
|
| 439 |
+
'gt': gt_lines[gt_idx],
|
| 440 |
+
'pred_idx': [""],
|
| 441 |
+
'pred': "",
|
| 442 |
+
'gt_position': [gt_items[gt_idx].get('order') if gt_items[gt_idx].get('order') else gt_items[gt_idx].get('position', [""])[0]],
|
| 443 |
+
'pred_position': "",
|
| 444 |
+
'norm_gt': norm_gt_lines[gt_idx],
|
| 445 |
+
'norm_pred': "",
|
| 446 |
+
'gt_category_type': gt_cat_list[gt_idx],
|
| 447 |
+
'pred_category_type': "",
|
| 448 |
+
'gt_attribute': [gt_items[gt_idx].get("attribute", {})],
|
| 449 |
+
'edit': 1,
|
| 450 |
+
'img_id': img_name
|
| 451 |
+
})
|
| 452 |
+
return match_list
|
| 453 |
+
elif len(norm_gt_lines) == 1 and len(norm_pred_lines) == 1:
|
| 454 |
+
edit_distance = Levenshtein_distance(norm_gt_lines[0], norm_pred_lines[0])
|
| 455 |
+
normalized_edit_distance = edit_distance / max(len(norm_gt_lines[0]), len(norm_pred_lines[0]))
|
| 456 |
+
return [{
|
| 457 |
+
'gt_idx': [0],
|
| 458 |
+
'gt': gt_lines[0],
|
| 459 |
+
'pred_idx': [0],
|
| 460 |
+
'pred': pred_lines[0],
|
| 461 |
+
'gt_position': [gt_items[0].get('order') if gt_items[0].get('order') else gt_items[0].get('position', [""])[0]],
|
| 462 |
+
'pred_position': pred_items[0]['position'][0],
|
| 463 |
+
'norm_gt': norm_gt_lines[0],
|
| 464 |
+
'norm_pred': norm_pred_lines[0],
|
| 465 |
+
'gt_category_type': gt_cat_list[0],
|
| 466 |
+
'pred_category_type': get_pred_category_type(0, pred_items),
|
| 467 |
+
'gt_attribute': [gt_items[0].get("attribute", {})],
|
| 468 |
+
'edit': normalized_edit_distance,
|
| 469 |
+
'img_id': img_name
|
| 470 |
+
}]
|
| 471 |
+
|
| 472 |
+
# match category ignore first
|
| 473 |
+
ignores = ['figure_caption', 'figure_footnote', 'table_caption', 'table_footnote', 'code_algorithm',
|
| 474 |
+
'code_algorithm_caption', 'header', 'footer', 'page_footnote', 'page_number', 'equation_caption']
|
| 475 |
+
|
| 476 |
+
ignore_gt_lines = []
|
| 477 |
+
ignores_ori_gt_lines= []
|
| 478 |
+
ignores_gt_items = []
|
| 479 |
+
ignore_gt_idxs = []
|
| 480 |
+
ignores_gt_cat_list = []
|
| 481 |
+
|
| 482 |
+
no_ignores_gt_lines = []
|
| 483 |
+
no_ignores_ori_gt_lines = []
|
| 484 |
+
no_ignores_gt_idxs = []
|
| 485 |
+
no_ignores_gt_items = []
|
| 486 |
+
no_ignores_gt_cat_list = []
|
| 487 |
+
|
| 488 |
+
for i, line in enumerate(norm_gt_lines):
|
| 489 |
+
if gt_cat_list[i] in ignores:
|
| 490 |
+
ignore_gt_lines.append(line)
|
| 491 |
+
ignores_ori_gt_lines.append(gt_lines[i])
|
| 492 |
+
ignores_gt_items.append(gt_items[i])
|
| 493 |
+
ignore_gt_idxs.append(i)
|
| 494 |
+
ignores_gt_cat_list.append(gt_cat_list[i])
|
| 495 |
+
else:
|
| 496 |
+
no_ignores_gt_lines.append(line)
|
| 497 |
+
no_ignores_ori_gt_lines.append(gt_lines[i])
|
| 498 |
+
no_ignores_gt_items.append(gt_items[i])
|
| 499 |
+
no_ignores_gt_cat_list.append(gt_cat_list[i])
|
| 500 |
+
no_ignores_gt_idxs.append(i)
|
| 501 |
+
|
| 502 |
+
# print("-------------ignore_gt_lines-------------------")
|
| 503 |
+
# for idx, line in zip(ignore_idx,ignore_gt_lines):
|
| 504 |
+
# print(f"{gt_cat_list[idx]}: {line}")
|
| 505 |
+
|
| 506 |
+
# print("-------------no_ignores_gt_lines-------------------")
|
| 507 |
+
# for line in no_ignores_gt_lines:
|
| 508 |
+
# print(line)
|
| 509 |
+
|
| 510 |
+
ignore_pred_idxs = []
|
| 511 |
+
ignore_pred_lines = []
|
| 512 |
+
ignores_pred_items = []
|
| 513 |
+
ignores_ori_pred_lines = []
|
| 514 |
+
|
| 515 |
+
merged_ignore_results = []
|
| 516 |
+
|
| 517 |
+
if len(ignore_gt_lines) > 0:
|
| 518 |
+
|
| 519 |
+
ignore_matches_dict = {}
|
| 520 |
+
|
| 521 |
+
ignore_matrix = compute_edit_distance_matrix_new(ignore_gt_lines, norm_pred_lines)
|
| 522 |
+
# print("-------------ignore_matrix-------------")
|
| 523 |
+
# print(ignore_matrix)
|
| 524 |
+
|
| 525 |
+
ignores_gt_indices = set(range(len(ignore_gt_lines)))
|
| 526 |
+
ignores_pred_indices = set(range(len(ignore_pred_lines)))
|
| 527 |
+
|
| 528 |
+
ignore_matches = np.argwhere(ignore_matrix < 0.25)
|
| 529 |
+
# print("-------------ignore_matches-------------")
|
| 530 |
+
# print(ignore_matches)
|
| 531 |
+
if len(ignore_matches) > 0:
|
| 532 |
+
ignore_pred_idxs = [_[1] for _ in ignore_matches]
|
| 533 |
+
ignore_gt_matched_idxs = [ignore_gt_idxs[_[0]] for _ in ignore_matches]
|
| 534 |
+
# print("-------------ignore_pred_idxs-------------")
|
| 535 |
+
# print(ignore_pred_idxs)
|
| 536 |
+
# print("-------------ignore_gt_matched_idxs-------------")
|
| 537 |
+
# print(ignore_gt_matched_idxs)
|
| 538 |
+
|
| 539 |
+
for i in ignore_pred_idxs:
|
| 540 |
+
ignore_pred_lines.append(norm_pred_lines[i])
|
| 541 |
+
ignores_ori_pred_lines.append(pred_lines[i])
|
| 542 |
+
ignores_pred_items.append(pred_items[i])
|
| 543 |
+
# print("-------------ignore_pred_lines-------------")
|
| 544 |
+
# for i in ignore_pred_lines:
|
| 545 |
+
# print(i)
|
| 546 |
+
|
| 547 |
+
ignores_gt_indices = set(range(len(ignore_gt_lines)))
|
| 548 |
+
ignores_pred_indices = set(range(len(ignore_pred_lines)))
|
| 549 |
+
|
| 550 |
+
for idx, i in enumerate(ignore_matches):
|
| 551 |
+
ignore_matches_dict[i[0]] = {
|
| 552 |
+
'pred_indices': [idx],
|
| 553 |
+
'edit_distance': ignore_matrix[i[0]][i[1]]
|
| 554 |
+
}
|
| 555 |
+
# print("-------------ignore_matches_dict-------------")
|
| 556 |
+
# print(ignore_matches_dict)
|
| 557 |
+
|
| 558 |
+
ignore_final_matches = merge_matches(ignore_matches_dict, {})
|
| 559 |
+
# print("-------------ignore_final_matches-------------")
|
| 560 |
+
# print(ignore_final_matches)
|
| 561 |
+
|
| 562 |
+
recalculate_edit_distances(ignore_final_matches, {}, ignore_gt_lines, ignore_pred_lines)
|
| 563 |
+
# print("-------------recalculate_ignore_final_matches-------------")
|
| 564 |
+
# print(ignore_final_matches)
|
| 565 |
+
|
| 566 |
+
converted_ignore_results = convert_final_matches(ignore_final_matches, ignore_gt_lines, ignore_pred_lines)
|
| 567 |
+
# print("-------------converted_ignore_results-------------")
|
| 568 |
+
# for i in converted_ignore_results:
|
| 569 |
+
# print(i)
|
| 570 |
+
|
| 571 |
+
merged_ignore_results = merge_duplicates_add_unmatched(converted_ignore_results, ignore_gt_lines, ignore_pred_lines, ignores_ori_gt_lines, ignores_ori_pred_lines, ignores_gt_indices, ignores_pred_indices)
|
| 572 |
+
|
| 573 |
+
for entry in merged_ignore_results:
|
| 574 |
+
entry['gt_idx'] = [entry['gt_idx']] if not isinstance(entry['gt_idx'], list) else entry['gt_idx']
|
| 575 |
+
entry['pred_idx'] = [entry['pred_idx']] if not isinstance(entry['pred_idx'], list) else entry['pred_idx']
|
| 576 |
+
entry['gt_position'] = [ignores_gt_items[_].get('order') if ignores_gt_items[_].get('order') else ignores_gt_items[_].get('position', [""])[0] for _ in entry['gt_idx']] if entry['gt_idx'] != [""] else [""]
|
| 577 |
+
entry['pred_position'] = ignores_pred_items[entry['pred_idx'][0]]['position'][0] if entry['pred_idx'] != [""] else ""
|
| 578 |
+
entry['gt'] = ''.join([ignores_ori_gt_lines[_] for _ in entry['gt_idx']]) if entry['gt_idx'] != [""] else ""
|
| 579 |
+
entry['pred'] = ''.join([ignores_ori_pred_lines[_] for _ in entry['pred_idx']]) if entry['pred_idx'] != [""] else ""
|
| 580 |
+
entry['norm_gt'] = ''.join([ignore_gt_lines[_] for _ in entry['gt_idx']]) if entry['gt_idx'] != [""] else ""
|
| 581 |
+
entry['norm_pred'] = ''.join([ignore_pred_lines[_] for _ in entry['pred_idx']]) if entry['pred_idx'] != [""] else ""
|
| 582 |
+
|
| 583 |
+
if entry['gt_idx'] != [""]:
|
| 584 |
+
ignore_type = ['figure_caption', 'figure_footnote', 'table_caption', 'table_footnote', 'code_algorithm', 'code_algorithm_caption', 'header', 'footer', 'page_footnote', 'page_number', 'equation_caption']
|
| 585 |
+
gt_cagegory_clean = [ignores_gt_cat_list[_] for _ in entry['gt_idx'] if ignores_gt_cat_list[_] not in ignore_type]
|
| 586 |
+
if gt_cagegory_clean:
|
| 587 |
+
entry['gt_category_type'] = Counter(gt_cagegory_clean).most_common(1)[0][0]
|
| 588 |
+
else:
|
| 589 |
+
entry['gt_category_type'] = Counter([ignores_gt_cat_list[_] for _ in entry['gt_idx']]).most_common(1)[0][0]
|
| 590 |
+
else:
|
| 591 |
+
entry['gt_category_type'] = ""
|
| 592 |
+
entry['pred_category_type'] = get_pred_category_type(entry['pred_idx'][0], ignores_pred_items) if entry['pred_idx'] != [""] else ""
|
| 593 |
+
if entry['pred_category_type'] == 'equation_inline':
|
| 594 |
+
merged_ignore_results.remove(entry)
|
| 595 |
+
entry['pred_category_type'] = get_pred_category_type(entry['pred_idx'][0], ignores_pred_items) if entry['pred_idx'] != [""] else ""
|
| 596 |
+
entry['gt_attribute'] = [ignores_gt_items[_].get("attribute", {}) for _ in entry['gt_idx']] if entry['gt_idx'] != [""] else [{}]
|
| 597 |
+
entry['img_id'] = img_name
|
| 598 |
+
|
| 599 |
+
for entry in merged_ignore_results:
|
| 600 |
+
if isinstance(entry['gt_idx'], list) and entry['gt_idx'] != [""]:
|
| 601 |
+
gt_idx = []
|
| 602 |
+
for i in entry['gt_idx']:
|
| 603 |
+
gt_idx.append(ignore_gt_idxs[i])
|
| 604 |
+
entry['gt_idx'] = gt_idx
|
| 605 |
+
if isinstance(entry['pred_idx'], list) and entry['pred_idx'] != [""]:
|
| 606 |
+
pred_idx = []
|
| 607 |
+
for i in entry['pred_idx']:
|
| 608 |
+
pred_idx.append(int(ignore_pred_idxs[i]))
|
| 609 |
+
entry['pred_idx'] = pred_idx
|
| 610 |
+
|
| 611 |
+
# print("-------------merged_ignore_results-------------")
|
| 612 |
+
# for i in merged_ignore_results:
|
| 613 |
+
# print(i)
|
| 614 |
+
|
| 615 |
+
no_ignores_pred_lines = []
|
| 616 |
+
no_ignores_ori_pred_lines = []
|
| 617 |
+
no_ignores_pred_indices = []
|
| 618 |
+
no_ignores_pred_items = []
|
| 619 |
+
no_ignore_pred_idxs = []
|
| 620 |
+
|
| 621 |
+
for idx, line in enumerate(norm_pred_lines):
|
| 622 |
+
if not idx in ignore_pred_idxs:
|
| 623 |
+
no_ignores_pred_lines.append(line)
|
| 624 |
+
no_ignores_ori_pred_lines.append(pred_lines[idx])
|
| 625 |
+
# no_ignores_pred_indices.append(idx)
|
| 626 |
+
no_ignores_pred_items.append(pred_items[idx])
|
| 627 |
+
no_ignore_pred_idxs.append(idx)
|
| 628 |
+
|
| 629 |
+
# initialize new indices for lines without ignore categories
|
| 630 |
+
no_ignores_gt_indices = set(range(len(no_ignores_gt_lines)))
|
| 631 |
+
no_ignores_pred_indices = set(range(len(no_ignores_pred_lines)))
|
| 632 |
+
|
| 633 |
+
# exclude ignore categories
|
| 634 |
+
cost_matrix = compute_edit_distance_matrix_new(no_ignores_gt_lines, no_ignores_pred_lines)
|
| 635 |
+
# print("-------------cost matrix-------------")
|
| 636 |
+
# print(cost_matrix)
|
| 637 |
+
|
| 638 |
+
matched_col_idx, row_ind, cost_list = cal_final_match(cost_matrix, no_ignores_gt_lines, no_ignores_pred_lines)
|
| 639 |
+
# print("-------------matched_col_idx-------------")
|
| 640 |
+
# print(matched_col_idx)
|
| 641 |
+
|
| 642 |
+
# print("-------------gt_row_ind-------------")
|
| 643 |
+
# print(row_ind)
|
| 644 |
+
|
| 645 |
+
# print("-------------cost_list-------------")
|
| 646 |
+
# print(cost_list)
|
| 647 |
+
|
| 648 |
+
gt_lens_dict, pred_lens_dict = initialize_indices(no_ignores_gt_lines, no_ignores_pred_lines)
|
| 649 |
+
# print("-------------gt_lens_dict-------------")
|
| 650 |
+
# print(gt_lens_dict)
|
| 651 |
+
|
| 652 |
+
# print("-------------pred_lens_dict-------------")
|
| 653 |
+
# print(pred_lens_dict)
|
| 654 |
+
|
| 655 |
+
matches, unmatched_gt_indices, unmatched_pred_indices = process_matches(matched_col_idx, row_ind, cost_list, no_ignores_gt_lines, no_ignores_pred_lines, no_ignores_ori_pred_lines)
|
| 656 |
+
|
| 657 |
+
# print("-------------matches-------------")
|
| 658 |
+
# print(matches)
|
| 659 |
+
|
| 660 |
+
# print("-------------unmatched_gt_indices-------------")
|
| 661 |
+
# print(unmatched_gt_indices)
|
| 662 |
+
|
| 663 |
+
# print("-------------unmatched_pred_indices-------------")
|
| 664 |
+
# print(unmatched_pred_indices)
|
| 665 |
+
|
| 666 |
+
matching_dict = fuzzy_match_unmatched_items(unmatched_gt_indices, no_ignores_gt_lines, no_ignores_pred_lines)
|
| 667 |
+
# print("-------------matching_dict-------------")
|
| 668 |
+
# print(matching_dict)
|
| 669 |
+
|
| 670 |
+
final_matches = merge_matches(matches, matching_dict)
|
| 671 |
+
# print("-------------final_matches-------------")
|
| 672 |
+
# print(final_matches)
|
| 673 |
+
|
| 674 |
+
recalculate_edit_distances(final_matches, gt_lens_dict, no_ignores_gt_lines, no_ignores_pred_lines)
|
| 675 |
+
# print("-------------recalculate_edit_distances-------------")
|
| 676 |
+
# print(final_matches)
|
| 677 |
+
|
| 678 |
+
converted_results = convert_final_matches(final_matches, no_ignores_gt_lines, no_ignores_pred_lines)
|
| 679 |
+
# print("-------------converted_results-------------")
|
| 680 |
+
# print(converted_results)
|
| 681 |
+
|
| 682 |
+
merged_results = merge_duplicates_add_unmatched(converted_results, no_ignores_gt_lines, no_ignores_pred_lines, no_ignores_ori_gt_lines, no_ignores_ori_pred_lines, no_ignores_gt_indices, no_ignores_pred_indices)
|
| 683 |
+
|
| 684 |
+
for entry in merged_results:
|
| 685 |
+
if entry['gt_idx'] != [""]:
|
| 686 |
+
ignore_type = ['figure_caption', 'figure_footnote', 'table_caption', 'table_footnote', 'code_algorithm', 'code_algorithm_caption', 'header', 'footer', 'page_footnote', 'page_number', 'equation_caption']
|
| 687 |
+
gt_cagegory_clean = [no_ignores_gt_cat_list[_] for _ in entry['gt_idx'] if no_ignores_gt_cat_list[_] not in ignore_type]
|
| 688 |
+
if gt_cagegory_clean:
|
| 689 |
+
entry['gt_category_type'] = Counter(gt_cagegory_clean).most_common(1)[0][0]
|
| 690 |
+
else:
|
| 691 |
+
entry['gt_category_type'] = Counter([no_ignores_gt_cat_list[_] for _ in entry['gt_idx']]).most_common(1)[0][0]
|
| 692 |
+
else:
|
| 693 |
+
entry['gt_category_type'] = ""
|
| 694 |
+
entry['pred_category_type'] = get_pred_category_type(entry['pred_idx'][0], no_ignores_pred_items) if entry['pred_idx'] != [""] else ""
|
| 695 |
+
if entry['pred_category_type'] == 'equation_inline':
|
| 696 |
+
merged_results.remove(entry)
|
| 697 |
+
|
| 698 |
+
|
| 699 |
+
entry['gt_idx'] = [entry['gt_idx']] if not isinstance(entry['gt_idx'], list) else entry['gt_idx']
|
| 700 |
+
entry['pred_idx'] = [entry['pred_idx']] if not isinstance(entry['pred_idx'], list) else entry['pred_idx']
|
| 701 |
+
entry['gt_position'] = [no_ignores_gt_items[_].get('order') if no_ignores_gt_items[_].get('order') else no_ignores_gt_items[_].get('position', [""])[0] for _ in entry['gt_idx']] if entry['gt_idx'] != [""] else [""]
|
| 702 |
+
entry['pred_position'] = no_ignores_pred_items[entry['pred_idx'][0]]['position'][0] if entry['pred_idx'] != [""] else ""
|
| 703 |
+
# 0507 多行公式拼接修改
|
| 704 |
+
if entry['gt_category_type'] == 'equation_isolated' and len(entry['gt_idx']) > 1:
|
| 705 |
+
mutli_formula = ' \\\\ '.join(['{'+no_ignores_ori_gt_lines[_].strip('$$').strip('\n')+'}' for _ in entry['gt_idx']]) if entry['gt_idx'] != [""] else ""
|
| 706 |
+
mutli_formula = '\\\\begin{array}{l} ' + mutli_formula + ' \\\\end{array}'
|
| 707 |
+
entry['gt'] = mutli_formula
|
| 708 |
+
else:
|
| 709 |
+
entry['gt'] = ''.join([no_ignores_ori_gt_lines[_] for _ in entry['gt_idx']]) if entry['gt_idx'] != [""] else ""
|
| 710 |
+
|
| 711 |
+
entry['pred_category_type'] = get_pred_category_type(entry['pred_idx'][0], no_ignores_pred_items) if entry['pred_idx'] != [""] else ""
|
| 712 |
+
entry['gt_attribute'] = [no_ignores_gt_items[_].get("attribute", {}) for _ in entry['gt_idx']] if entry['gt_idx'] != [""] else [{}]
|
| 713 |
+
entry['img_id'] = img_name
|
| 714 |
+
|
| 715 |
+
# 0724 多行公式拼接修改pred
|
| 716 |
+
if 'equation' in entry['pred_category_type'] and len(entry['pred_idx']) > 1:
|
| 717 |
+
mutli_formula = ' \\\\ '.join(['{'+no_ignores_ori_pred_lines[_].strip('$$').strip('\n')+'}' for _ in entry['pred_idx']]) if entry['pred_idx'] != [""] else ""
|
| 718 |
+
mutli_formula = '\\\\begin{array}{l} ' + mutli_formula + ' \\\\end{array}'
|
| 719 |
+
entry['pred'] = mutli_formula
|
| 720 |
+
else:
|
| 721 |
+
entry['pred'] = ''.join([no_ignores_ori_pred_lines[_] for _ in entry['pred_idx']]) if entry['pred_idx'] != [""] else ""
|
| 722 |
+
|
| 723 |
+
entry['norm_gt'] = ''.join([no_ignores_gt_lines[_] for _ in entry['gt_idx']]) if entry['gt_idx'] != [""] else ""
|
| 724 |
+
entry['norm_pred'] = ''.join([no_ignores_pred_lines[_] for _ in entry['pred_idx']]) if entry['pred_idx'] != [""] else ""
|
| 725 |
+
|
| 726 |
+
|
| 727 |
+
# print("-------------merged_results-------------")
|
| 728 |
+
# for i in merged_results:
|
| 729 |
+
# print(i)
|
| 730 |
+
for entry in merged_results:
|
| 731 |
+
if isinstance(entry['gt_idx'], list) and entry['gt_idx'] != [""]:
|
| 732 |
+
gt_idx = []
|
| 733 |
+
for i in entry['gt_idx']:
|
| 734 |
+
gt_idx.append(no_ignores_gt_idxs[i])
|
| 735 |
+
entry['gt_idx'] = gt_idx
|
| 736 |
+
if isinstance(entry['pred_idx'], list) and entry['pred_idx'] != [""]:
|
| 737 |
+
pred_idx = []
|
| 738 |
+
for i in entry['pred_idx']:
|
| 739 |
+
pred_idx.append(int(no_ignore_pred_idxs[i]))
|
| 740 |
+
entry['pred_idx'] = pred_idx
|
| 741 |
+
|
| 742 |
+
if len(merged_ignore_results) > 0:
|
| 743 |
+
merged_results.extend(merged_ignore_results)
|
| 744 |
+
# for i in merged_ignore_results:
|
| 745 |
+
# merged_results.append(i)
|
| 746 |
+
|
| 747 |
+
return merged_results
|
| 748 |
+
|
| 749 |
+
# cost_matrix = compute_edit_distance_matrix_new(norm_gt_lines, norm_pred_lines)
|
| 750 |
+
|
| 751 |
+
# matched_col_idx, row_ind, cost_list = cal_final_match(cost_matrix, norm_gt_lines, norm_pred_lines)
|
| 752 |
+
|
| 753 |
+
# gt_lens_dict, pred_lens_dict = initialize_indices(norm_gt_lines, norm_pred_lines)
|
| 754 |
+
|
| 755 |
+
# matches, unmatched_gt_indices, unmatched_pred_indices = process_matches(matched_col_idx, row_ind, cost_list, norm_gt_lines, norm_pred_lines, pred_lines)
|
| 756 |
+
|
| 757 |
+
# matching_dict = fuzzy_match_unmatched_items(unmatched_gt_indices, norm_gt_lines, norm_pred_lines)
|
| 758 |
+
|
| 759 |
+
# final_matches = merge_matches(matches, matching_dict)
|
| 760 |
+
|
| 761 |
+
# recalculate_edit_distances(final_matches, gt_lens_dict, norm_gt_lines, norm_pred_lines)
|
| 762 |
+
|
| 763 |
+
# converted_results = convert_final_matches(final_matches, norm_gt_lines, norm_pred_lines)
|
| 764 |
+
|
| 765 |
+
# merged_results = merge_duplicates_add_unmatched(converted_results, norm_gt_lines, norm_pred_lines, gt_lines, pred_lines, all_gt_indices, all_pred_indices)
|
| 766 |
+
|
| 767 |
+
# for entry in merged_results:
|
| 768 |
+
# entry['gt_idx'] = [entry['gt_idx']] if not isinstance(entry['gt_idx'], list) else entry['gt_idx']
|
| 769 |
+
# entry['pred_idx'] = [entry['pred_idx']] if not isinstance(entry['pred_idx'], list) else entry['pred_idx']
|
| 770 |
+
# entry['gt_position'] = [gt_items[_].get('order') if gt_items[_].get('order') else gt_items[_].get('position', [""])[0] for _ in entry['gt_idx']] if entry['gt_idx'] != [""] else [""]
|
| 771 |
+
# entry['pred_position'] = pred_items[entry['pred_idx'][0]]['position'][0] if entry['pred_idx'] != [""] else ""
|
| 772 |
+
# entry['gt'] = ''.join([gt_lines[_] for _ in entry['gt_idx']]) if entry['gt_idx'] != [""] else ""
|
| 773 |
+
# entry['pred'] = ''.join([pred_lines[_] for _ in entry['pred_idx']]) if entry['pred_idx'] != [""] else ""
|
| 774 |
+
# entry['norm_gt'] = ''.join([norm_gt_lines[_] for _ in entry['gt_idx']]) if entry['gt_idx'] != [""] else ""
|
| 775 |
+
# entry['norm_pred'] = ''.join([norm_pred_lines[_] for _ in entry['pred_idx']]) if entry['pred_idx'] != [""] else ""
|
| 776 |
+
|
| 777 |
+
# if entry['gt_idx'] != [""]:
|
| 778 |
+
# ignore_type = ['figure_caption', 'figure_footnote', 'table_caption', 'table_footnote', 'code_algorithm', 'code_algorithm_caption', 'header', 'footer', 'page_footnote', 'page_number', 'equation_caption']
|
| 779 |
+
# gt_cagegory_clean = [gt_cat_list[_] for _ in entry['gt_idx'] if gt_cat_list[_] not in ignore_type]
|
| 780 |
+
# if gt_cagegory_clean:
|
| 781 |
+
# entry['gt_category_type'] = Counter(gt_cagegory_clean).most_common(1)[0][0]
|
| 782 |
+
# else:
|
| 783 |
+
# entry['gt_category_type'] = Counter([gt_cat_list[_] for _ in entry['gt_idx']]).most_common(1)[0][0]
|
| 784 |
+
# else:
|
| 785 |
+
# entry['gt_category_type'] = ""
|
| 786 |
+
# entry['pred_category_type'] = get_pred_category_type(entry['pred_idx'][0], pred_items) if entry['pred_idx'] != [""] else ""
|
| 787 |
+
# entry['gt_attribute'] = [gt_items[_].get("attribute", {}) for _ in entry['gt_idx']] if entry['gt_idx'] != [""] else [{}]
|
| 788 |
+
# entry['img_id'] = img_name
|
| 789 |
+
|
| 790 |
+
# return merged_results
|
| 791 |
+
|
| 792 |
+
|
| 793 |
+
def merge_duplicates_add_unmatched(converted_results, norm_gt_lines, norm_pred_lines, gt_lines, pred_lines, all_gt_indices, all_pred_indices):
|
| 794 |
+
merged_results = []
|
| 795 |
+
processed_pred = set()
|
| 796 |
+
processed_gt = set()
|
| 797 |
+
|
| 798 |
+
for entry in converted_results:
|
| 799 |
+
pred_idx = tuple(entry['pred_idx']) if isinstance(entry['pred_idx'], list) else (entry['pred_idx'],)
|
| 800 |
+
if pred_idx not in processed_pred and pred_idx != ("",):
|
| 801 |
+
merged_entry = {
|
| 802 |
+
'gt_idx': [entry['gt_idx']],
|
| 803 |
+
'gt': entry['gt'],
|
| 804 |
+
'pred_idx': entry['pred_idx'],
|
| 805 |
+
'pred': entry['pred'],
|
| 806 |
+
'edit': entry['edit']
|
| 807 |
+
}
|
| 808 |
+
for other_entry in converted_results:
|
| 809 |
+
other_pred_idx = tuple(other_entry['pred_idx']) if isinstance(other_entry['pred_idx'], list) else (other_entry['pred_idx'],)
|
| 810 |
+
if other_pred_idx == pred_idx and other_entry is not entry:
|
| 811 |
+
merged_entry['gt_idx'].append(other_entry['gt_idx'])
|
| 812 |
+
merged_entry['gt'] += other_entry['gt']
|
| 813 |
+
processed_gt.add(other_entry['gt_idx'])
|
| 814 |
+
merged_results.append(merged_entry)
|
| 815 |
+
processed_pred.add(pred_idx)
|
| 816 |
+
processed_gt.add(entry['gt_idx'])
|
| 817 |
+
|
| 818 |
+
# for entry in converted_results:
|
| 819 |
+
# if entry['gt_idx'] not in processed_gt:
|
| 820 |
+
# merged_results.append(entry)
|
| 821 |
+
|
| 822 |
+
for gt_idx in range(len(norm_gt_lines)):
|
| 823 |
+
if gt_idx not in processed_gt:
|
| 824 |
+
merged_results.append({
|
| 825 |
+
'gt_idx': [gt_idx],
|
| 826 |
+
'gt': gt_lines[gt_idx],
|
| 827 |
+
'pred_idx': [""],
|
| 828 |
+
'pred': "",
|
| 829 |
+
'edit': 1
|
| 830 |
+
})
|
| 831 |
+
return merged_results
|
| 832 |
+
|
| 833 |
+
|
| 834 |
+
|
| 835 |
+
|
| 836 |
+
def formula_format(formula_matches, img_name):
|
| 837 |
+
return [
|
| 838 |
+
{
|
| 839 |
+
"gt": item["gt"],
|
| 840 |
+
"pred": item["pred"],
|
| 841 |
+
"img_id": f"{img_name}_{i}"
|
| 842 |
+
}
|
| 843 |
+
for i, item in enumerate(formula_matches)
|
| 844 |
+
]
|
| 845 |
+
|
| 846 |
+
|
| 847 |
+
def merge_lists_with_sublists(main_list, sub_lists):
|
| 848 |
+
main_list_final = list(copy.deepcopy(main_list))
|
| 849 |
+
for sub_list in sub_lists:
|
| 850 |
+
pop_idx = main_list_final.index(sub_list[0])
|
| 851 |
+
for _ in sub_list:
|
| 852 |
+
main_list_final.pop(pop_idx)
|
| 853 |
+
main_list_final.insert(pop_idx, sub_list)
|
| 854 |
+
return main_list_final
|
| 855 |
+
|
| 856 |
+
|
| 857 |
+
def sub_pred_fuzzy_matching(gt, pred):
|
| 858 |
+
|
| 859 |
+
min_d = float('inf')
|
| 860 |
+
# pos = -1
|
| 861 |
+
|
| 862 |
+
gt_len = len(gt)
|
| 863 |
+
pred_len = len(pred)
|
| 864 |
+
|
| 865 |
+
if gt_len >= pred_len and pred_len > 0:
|
| 866 |
+
for i in range(gt_len - pred_len + 1):
|
| 867 |
+
sub = gt[i:i + pred_len]
|
| 868 |
+
dist = Levenshtein_distance(sub, pred)/pred_len
|
| 869 |
+
if dist < min_d:
|
| 870 |
+
min_d = dist
|
| 871 |
+
pos = i
|
| 872 |
+
|
| 873 |
+
return min_d
|
| 874 |
+
else:
|
| 875 |
+
return False
|
| 876 |
+
|
| 877 |
+
def sub_gt_fuzzy_matching(pred, gt):
|
| 878 |
+
|
| 879 |
+
min_d = float('inf')
|
| 880 |
+
pos = ""
|
| 881 |
+
matched_sub = ""
|
| 882 |
+
gt_len = len(gt)
|
| 883 |
+
pred_len = len(pred)
|
| 884 |
+
|
| 885 |
+
if pred_len >= gt_len and gt_len > 0:
|
| 886 |
+
for i in range(pred_len - gt_len + 1):
|
| 887 |
+
sub = pred[i:i + gt_len]
|
| 888 |
+
dist = Levenshtein.distance(sub, gt) /gt_len
|
| 889 |
+
if dist < min_d:
|
| 890 |
+
min_d = dist
|
| 891 |
+
pos = i
|
| 892 |
+
matched_sub = sub
|
| 893 |
+
return min_d, pos, gt_len, matched_sub
|
| 894 |
+
else:
|
| 895 |
+
return 1, "", gt_len, ""
|
| 896 |
+
|
| 897 |
+
|
| 898 |
+
def get_final_subset(subset_certain, subset_certain_cost):
|
| 899 |
+
if not subset_certain or not subset_certain_cost:
|
| 900 |
+
return []
|
| 901 |
+
|
| 902 |
+
subset_turple = sorted([(a, b) for a, b in zip(subset_certain, subset_certain_cost)], key=lambda x: x[0][0])
|
| 903 |
+
|
| 904 |
+
group_list = defaultdict(list)
|
| 905 |
+
group_idx = 0
|
| 906 |
+
group_list[group_idx].append(subset_turple[0])
|
| 907 |
+
|
| 908 |
+
for item in subset_turple[1:]:
|
| 909 |
+
overlap_flag = False
|
| 910 |
+
for subset in group_list[group_idx]:
|
| 911 |
+
for idx in item[0]:
|
| 912 |
+
if idx in subset[0]:
|
| 913 |
+
overlap_flag = True
|
| 914 |
+
break
|
| 915 |
+
if overlap_flag:
|
| 916 |
+
break
|
| 917 |
+
if overlap_flag:
|
| 918 |
+
group_list[group_idx].append(item)
|
| 919 |
+
else:
|
| 920 |
+
group_idx += 1
|
| 921 |
+
group_list[group_idx].append(item)
|
| 922 |
+
|
| 923 |
+
final_subset = []
|
| 924 |
+
for _, group in group_list.items():
|
| 925 |
+
if len(group) == 1:
|
| 926 |
+
final_subset.append(group[0][0])
|
| 927 |
+
else:
|
| 928 |
+
path_dict = defaultdict(list)
|
| 929 |
+
path_idx = 0
|
| 930 |
+
path_dict[path_idx].append(group[0])
|
| 931 |
+
|
| 932 |
+
for subset in group[1:]:
|
| 933 |
+
new_path = True
|
| 934 |
+
for path_idx_s, path_items in path_dict.items():
|
| 935 |
+
is_dup = False
|
| 936 |
+
is_same = False
|
| 937 |
+
for path_item in path_items:
|
| 938 |
+
if path_item[0] == subset[0]:
|
| 939 |
+
is_dup = True
|
| 940 |
+
is_same = True
|
| 941 |
+
if path_item[1] > subset[1]:
|
| 942 |
+
path_dict[path_idx_s].pop(path_dict[path_idx_s].index(path_item))
|
| 943 |
+
path_dict[path_idx_s].append(subset)
|
| 944 |
+
else:
|
| 945 |
+
for num_1 in path_item[0]:
|
| 946 |
+
for num_2 in subset[0]:
|
| 947 |
+
if num_1 == num_2:
|
| 948 |
+
is_dup = True
|
| 949 |
+
if not is_dup:
|
| 950 |
+
path_dict[path_idx_s].append(subset)
|
| 951 |
+
new_path = False
|
| 952 |
+
if is_same:
|
| 953 |
+
new_path = False
|
| 954 |
+
if new_path:
|
| 955 |
+
path_idx = len(path_dict.keys())
|
| 956 |
+
path_dict[path_idx].append(subset)
|
| 957 |
+
|
| 958 |
+
saved_cost = float('inf')
|
| 959 |
+
saved_subset = []
|
| 960 |
+
for path_idx, path in path_dict.items():
|
| 961 |
+
avg_cost = sum([i[1] for i in path]) / len(path)
|
| 962 |
+
if avg_cost < saved_cost:
|
| 963 |
+
saved_subset = [i[0] for i in path]
|
| 964 |
+
saved_cost = avg_cost
|
| 965 |
+
|
| 966 |
+
final_subset.extend(saved_subset)
|
| 967 |
+
|
| 968 |
+
return final_subset
|
| 969 |
+
|
| 970 |
+
def judge_pred_merge(gt_list, pred_list, threshold=0.6):
|
| 971 |
+
if len(pred_list) == 1:
|
| 972 |
+
return False, False
|
| 973 |
+
|
| 974 |
+
cur_pred = ' '.join(pred_list[:-1])
|
| 975 |
+
merged_pred = ' '.join(pred_list)
|
| 976 |
+
|
| 977 |
+
cur_dist = Levenshtein.distance(gt_list[0], cur_pred) / max(len(gt_list[0]), len(cur_pred))
|
| 978 |
+
merged_dist = Levenshtein.distance(gt_list[0], merged_pred) / max(len(gt_list[0]), len(merged_pred))
|
| 979 |
+
|
| 980 |
+
if merged_dist > cur_dist:
|
| 981 |
+
return False, False
|
| 982 |
+
|
| 983 |
+
cur_fuzzy_dists = [sub_pred_fuzzy_matching(gt_list[0], cur_pred) for cur_pred in pred_list[:-1]]
|
| 984 |
+
if any(dist is False or dist > threshold for dist in cur_fuzzy_dists):
|
| 985 |
+
return False, False
|
| 986 |
+
|
| 987 |
+
add_fuzzy_dist = sub_pred_fuzzy_matching(gt_list[0], pred_list[-1])
|
| 988 |
+
if add_fuzzy_dist is False:
|
| 989 |
+
return False, False
|
| 990 |
+
|
| 991 |
+
merged_pred_flag = add_fuzzy_dist < threshold
|
| 992 |
+
continue_flag = len(merged_pred) <= len(gt_list[0])
|
| 993 |
+
|
| 994 |
+
return merged_pred_flag, continue_flag
|
| 995 |
+
|
| 996 |
+
def deal_with_truncated(cost_matrix, norm_gt_lines, norm_pred_lines):
|
| 997 |
+
matched_first = np.argwhere(cost_matrix < 0.25)
|
| 998 |
+
masked_gt_idx = [i[0] for i in matched_first]
|
| 999 |
+
unmasked_gt_idx = [i for i in range(cost_matrix.shape[0]) if i not in masked_gt_idx]
|
| 1000 |
+
masked_pred_idx = [i[1] for i in matched_first]
|
| 1001 |
+
unmasked_pred_idx = [i for i in range(cost_matrix.shape[1]) if i not in masked_pred_idx]
|
| 1002 |
+
|
| 1003 |
+
merges_gt_dict = {}
|
| 1004 |
+
merges_pred_dict = {}
|
| 1005 |
+
merged_gt_subsets = []
|
| 1006 |
+
|
| 1007 |
+
for gt_idx in unmasked_gt_idx:
|
| 1008 |
+
check_merge_subset = []
|
| 1009 |
+
merged_dist = []
|
| 1010 |
+
|
| 1011 |
+
for pred_idx in unmasked_pred_idx:
|
| 1012 |
+
step = 1
|
| 1013 |
+
merged_pred = [norm_pred_lines[pred_idx]]
|
| 1014 |
+
|
| 1015 |
+
while True:
|
| 1016 |
+
if pred_idx + step in masked_pred_idx or pred_idx + step >= len(norm_pred_lines):
|
| 1017 |
+
break
|
| 1018 |
+
else:
|
| 1019 |
+
merged_pred.append(norm_pred_lines[pred_idx + step])
|
| 1020 |
+
merged_pred_flag, continue_flag = judge_pred_merge([norm_gt_lines[gt_idx]], merged_pred)
|
| 1021 |
+
if not merged_pred_flag:
|
| 1022 |
+
break
|
| 1023 |
+
else:
|
| 1024 |
+
step += 1
|
| 1025 |
+
if not continue_flag:
|
| 1026 |
+
break
|
| 1027 |
+
|
| 1028 |
+
check_merge_subset.append(list(range(pred_idx, pred_idx + step)))
|
| 1029 |
+
matched_line = ' '.join([norm_pred_lines[i] for i in range(pred_idx, pred_idx + step)])
|
| 1030 |
+
dist = Levenshtein_distance(norm_gt_lines[gt_idx], matched_line) / max(len(matched_line), len(norm_gt_lines[gt_idx]))
|
| 1031 |
+
merged_dist.append(dist)
|
| 1032 |
+
|
| 1033 |
+
if not merged_dist:
|
| 1034 |
+
subset_certain = []
|
| 1035 |
+
min_cost_idx = ""
|
| 1036 |
+
min_cost = float('inf')
|
| 1037 |
+
else:
|
| 1038 |
+
min_cost = min(merged_dist)
|
| 1039 |
+
min_cost_idx = merged_dist.index(min_cost)
|
| 1040 |
+
subset_certain = check_merge_subset[min_cost_idx]
|
| 1041 |
+
|
| 1042 |
+
merges_gt_dict[gt_idx] = {
|
| 1043 |
+
'merge_subset': check_merge_subset,
|
| 1044 |
+
'merged_cost': merged_dist,
|
| 1045 |
+
'min_cost_idx': min_cost_idx,
|
| 1046 |
+
'subset_certain': subset_certain,
|
| 1047 |
+
'min_cost': min_cost
|
| 1048 |
+
}
|
| 1049 |
+
|
| 1050 |
+
subset_certain = [merges_gt_dict[gt_idx]['subset_certain'] for gt_idx in unmasked_gt_idx if merges_gt_dict[gt_idx]['subset_certain']]
|
| 1051 |
+
subset_certain_cost = [merges_gt_dict[gt_idx]['min_cost'] for gt_idx in unmasked_gt_idx if merges_gt_dict[gt_idx]['subset_certain']]
|
| 1052 |
+
|
| 1053 |
+
subset_certain_final = get_final_subset(subset_certain, subset_certain_cost)
|
| 1054 |
+
|
| 1055 |
+
if not subset_certain_final:
|
| 1056 |
+
return cost_matrix, norm_pred_lines, range(len(norm_pred_lines))
|
| 1057 |
+
|
| 1058 |
+
final_pred_idx_list = merge_lists_with_sublists(range(len(norm_pred_lines)), subset_certain_final)
|
| 1059 |
+
final_norm_pred_lines = [' '.join(norm_pred_lines[idx_list[0]:idx_list[-1]+1]) if isinstance(idx_list, list) else norm_pred_lines[idx_list] for idx_list in final_pred_idx_list]
|
| 1060 |
+
|
| 1061 |
+
new_cost_matrix = compute_edit_distance_matrix_new(norm_gt_lines, final_norm_pred_lines)
|
| 1062 |
+
|
| 1063 |
+
return new_cost_matrix, final_norm_pred_lines, final_pred_idx_list
|
| 1064 |
+
|
| 1065 |
+
def cal_move_dist(gt, pred):
|
| 1066 |
+
assert len(gt) == len(pred), 'Not right length'
|
| 1067 |
+
step = 0
|
| 1068 |
+
for i, gt_c in enumerate(gt):
|
| 1069 |
+
if gt_c != pred[i]:
|
| 1070 |
+
step += abs(i - pred.index(gt_c))
|
| 1071 |
+
pred[i], pred[pred.index(gt_c)] = pred[pred.index(gt_c)], pred[i]
|
| 1072 |
+
return step / len(gt)
|
| 1073 |
+
|
| 1074 |
+
def cal_final_match(cost_matrix, norm_gt_lines, norm_pred_lines):
|
| 1075 |
+
# min_indice = cost_matrix.argmax(axis=1)
|
| 1076 |
+
|
| 1077 |
+
new_cost_matrix, final_norm_pred_lines, final_pred_idx_list = deal_with_truncated(cost_matrix, norm_gt_lines, norm_pred_lines)
|
| 1078 |
+
|
| 1079 |
+
row_ind, col_ind = linear_sum_assignment(new_cost_matrix)
|
| 1080 |
+
|
| 1081 |
+
cost_list = [new_cost_matrix[r][c] for r, c in zip(row_ind, col_ind)]
|
| 1082 |
+
matched_col_idx = [final_pred_idx_list[i] for i in col_ind]
|
| 1083 |
+
|
| 1084 |
+
return matched_col_idx, row_ind, cost_list
|
| 1085 |
+
|
| 1086 |
+
def initialize_indices(norm_gt_lines, norm_pred_lines):
|
| 1087 |
+
gt_lens_dict = {idx: len(gt_line) for idx, gt_line in enumerate(norm_gt_lines)}
|
| 1088 |
+
pred_lens_dict = {idx: len(pred_line) for idx, pred_line in enumerate(norm_pred_lines)}
|
| 1089 |
+
return gt_lens_dict, pred_lens_dict
|
| 1090 |
+
|
| 1091 |
+
def process_matches(matched_col_idx, row_ind, cost_list, norm_gt_lines, norm_pred_lines, pred_lines):
|
| 1092 |
+
matches = {}
|
| 1093 |
+
unmatched_gt_indices = []
|
| 1094 |
+
unmatched_pred_indices = []
|
| 1095 |
+
|
| 1096 |
+
for i in range(len(norm_gt_lines)):
|
| 1097 |
+
if i in row_ind:
|
| 1098 |
+
idx = list(row_ind).index(i)
|
| 1099 |
+
pred_idx = matched_col_idx[idx]
|
| 1100 |
+
|
| 1101 |
+
if pred_idx is None or (isinstance(pred_idx, list) and None in pred_idx):
|
| 1102 |
+
unmatched_pred_indices.append(pred_idx)
|
| 1103 |
+
continue
|
| 1104 |
+
|
| 1105 |
+
if isinstance(pred_idx, list):
|
| 1106 |
+
pred_line = ' | '.join(norm_pred_lines[pred_idx[0]:pred_idx[-1]+1])
|
| 1107 |
+
ori_pred_line = ' | '.join(pred_lines[pred_idx[0]:pred_idx[-1]+1])
|
| 1108 |
+
matched_pred_indices_range = list(range(pred_idx[0], pred_idx[-1]+1))
|
| 1109 |
+
else:
|
| 1110 |
+
pred_line = norm_pred_lines[pred_idx]
|
| 1111 |
+
ori_pred_line = pred_lines[pred_idx]
|
| 1112 |
+
matched_pred_indices_range = [pred_idx]
|
| 1113 |
+
|
| 1114 |
+
edit = cost_list[idx]
|
| 1115 |
+
|
| 1116 |
+
if edit > 0.7:
|
| 1117 |
+
unmatched_pred_indices.extend(matched_pred_indices_range)
|
| 1118 |
+
unmatched_gt_indices.append(i)
|
| 1119 |
+
else:
|
| 1120 |
+
matches[i] = {
|
| 1121 |
+
'pred_indices': matched_pred_indices_range,
|
| 1122 |
+
'edit_distance': edit,
|
| 1123 |
+
}
|
| 1124 |
+
for matched_pred_idx in matched_pred_indices_range:
|
| 1125 |
+
if matched_pred_idx in unmatched_pred_indices:
|
| 1126 |
+
unmatched_pred_indices.remove(matched_pred_idx)
|
| 1127 |
+
else:
|
| 1128 |
+
unmatched_gt_indices.append(i)
|
| 1129 |
+
|
| 1130 |
+
return matches, unmatched_gt_indices, unmatched_pred_indices
|
| 1131 |
+
|
| 1132 |
+
def fuzzy_match_unmatched_items(unmatched_gt_indices, norm_gt_lines, norm_pred_lines):
|
| 1133 |
+
matching_dict = {}
|
| 1134 |
+
|
| 1135 |
+
for pred_idx, pred_content in enumerate(norm_pred_lines):
|
| 1136 |
+
if isinstance(pred_idx, list):
|
| 1137 |
+
continue
|
| 1138 |
+
|
| 1139 |
+
matching_indices = []
|
| 1140 |
+
|
| 1141 |
+
for unmatched_gt_idx in unmatched_gt_indices:
|
| 1142 |
+
gt_content = norm_gt_lines[unmatched_gt_idx]
|
| 1143 |
+
cur_fuzzy_dist_unmatch, cur_pos, gt_lens, matched_field = sub_gt_fuzzy_matching(pred_content, gt_content)
|
| 1144 |
+
if cur_fuzzy_dist_unmatch < 0.4:
|
| 1145 |
+
matching_indices.append(unmatched_gt_idx)
|
| 1146 |
+
|
| 1147 |
+
if matching_indices:
|
| 1148 |
+
matching_dict[pred_idx] = matching_indices
|
| 1149 |
+
|
| 1150 |
+
return matching_dict
|
| 1151 |
+
|
| 1152 |
+
def merge_matches(matches, matching_dict):
|
| 1153 |
+
final_matches = {}
|
| 1154 |
+
processed_gt_indices = set()
|
| 1155 |
+
|
| 1156 |
+
for gt_idx, match_info in matches.items():
|
| 1157 |
+
pred_indices = match_info['pred_indices']
|
| 1158 |
+
edit_distance = match_info['edit_distance']
|
| 1159 |
+
|
| 1160 |
+
pred_key = tuple(sorted(pred_indices))
|
| 1161 |
+
|
| 1162 |
+
if pred_key in final_matches:
|
| 1163 |
+
if gt_idx not in processed_gt_indices:
|
| 1164 |
+
final_matches[pred_key]['gt_indices'].append(gt_idx)
|
| 1165 |
+
processed_gt_indices.add(gt_idx)
|
| 1166 |
+
else:
|
| 1167 |
+
final_matches[pred_key] = {
|
| 1168 |
+
'gt_indices': [gt_idx],
|
| 1169 |
+
'edit_distance': edit_distance
|
| 1170 |
+
}
|
| 1171 |
+
processed_gt_indices.add(gt_idx)
|
| 1172 |
+
|
| 1173 |
+
for pred_idx, gt_indices in matching_dict.items():
|
| 1174 |
+
pred_key = (pred_idx,) if not isinstance(pred_idx, (list, tuple)) else tuple(sorted(pred_idx))
|
| 1175 |
+
|
| 1176 |
+
if pred_key in final_matches:
|
| 1177 |
+
for gt_idx in gt_indices:
|
| 1178 |
+
if gt_idx not in processed_gt_indices:
|
| 1179 |
+
final_matches[pred_key]['gt_indices'].append(gt_idx)
|
| 1180 |
+
processed_gt_indices.add(gt_idx)
|
| 1181 |
+
else:
|
| 1182 |
+
final_matches[pred_key] = {
|
| 1183 |
+
'gt_indices': [gt_idx for gt_idx in gt_indices if gt_idx not in processed_gt_indices],
|
| 1184 |
+
'edit_distance': None
|
| 1185 |
+
}
|
| 1186 |
+
processed_gt_indices.update(final_matches[pred_key]['gt_indices'])
|
| 1187 |
+
|
| 1188 |
+
return final_matches
|
| 1189 |
+
|
| 1190 |
+
|
| 1191 |
+
|
| 1192 |
+
def recalculate_edit_distances(final_matches, gt_lens_dict, norm_gt_lines, norm_pred_lines):
|
| 1193 |
+
for pred_key, info in final_matches.items():
|
| 1194 |
+
gt_indices = sorted(set(info['gt_indices']))
|
| 1195 |
+
|
| 1196 |
+
if not gt_indices:
|
| 1197 |
+
info['edit_distance'] = 1
|
| 1198 |
+
continue
|
| 1199 |
+
|
| 1200 |
+
if len(gt_indices) > 1:
|
| 1201 |
+
merged_gt_content = ''.join(norm_gt_lines[gt_idx] for gt_idx in gt_indices)
|
| 1202 |
+
pred_content = norm_pred_lines[pred_key[0]] if isinstance(pred_key[0], int) else ''
|
| 1203 |
+
|
| 1204 |
+
try:
|
| 1205 |
+
edit_distance = Levenshtein_distance(merged_gt_content, pred_content)
|
| 1206 |
+
normalized_edit_distance = edit_distance / max(len(merged_gt_content), len(pred_content))
|
| 1207 |
+
except ZeroDivisionError:
|
| 1208 |
+
normalized_edit_distance = 1
|
| 1209 |
+
|
| 1210 |
+
info['edit_distance'] = normalized_edit_distance
|
| 1211 |
+
else:
|
| 1212 |
+
gt_idx = gt_indices[0]
|
| 1213 |
+
pred_content = ' '.join(norm_pred_lines[pred_idx] for pred_idx in pred_key if isinstance(pred_idx, int))
|
| 1214 |
+
|
| 1215 |
+
try:
|
| 1216 |
+
edit_distance = Levenshtein_distance(norm_gt_lines[gt_idx], pred_content)
|
| 1217 |
+
normalized_edit_distance = edit_distance / max(len(norm_gt_lines[gt_idx]), len(pred_content))
|
| 1218 |
+
except ZeroDivisionError:
|
| 1219 |
+
normalized_edit_distance = 1
|
| 1220 |
+
|
| 1221 |
+
info['edit_distance'] = normalized_edit_distance
|
| 1222 |
+
info['pred_content'] = pred_content
|
| 1223 |
+
|
| 1224 |
+
|
| 1225 |
+
def convert_final_matches(final_matches, norm_gt_lines, norm_pred_lines):
|
| 1226 |
+
converted_results = []
|
| 1227 |
+
|
| 1228 |
+
all_gt_indices = set(range(len(norm_gt_lines)))
|
| 1229 |
+
all_pred_indices = set(range(len(norm_pred_lines)))
|
| 1230 |
+
|
| 1231 |
+
for pred_key, info in final_matches.items():
|
| 1232 |
+
pred_content = ' '.join(norm_pred_lines[pred_idx] for pred_idx in pred_key if isinstance(pred_idx, int))
|
| 1233 |
+
|
| 1234 |
+
for gt_idx in sorted(set(info['gt_indices'])):
|
| 1235 |
+
result_entry = {
|
| 1236 |
+
'gt_idx': int(gt_idx),
|
| 1237 |
+
'gt': norm_gt_lines[gt_idx],
|
| 1238 |
+
'pred_idx': list(pred_key),
|
| 1239 |
+
'pred': pred_content,
|
| 1240 |
+
'edit': info['edit_distance']
|
| 1241 |
+
}
|
| 1242 |
+
converted_results.append(result_entry)
|
| 1243 |
+
|
| 1244 |
+
matched_gt_indices = set().union(*[set(info['gt_indices']) for info in final_matches.values()])
|
| 1245 |
+
unmatched_gt_indices = all_gt_indices - matched_gt_indices
|
| 1246 |
+
matched_pred_indices = set(idx for pred_key in final_matches.keys() for idx in pred_key if isinstance(idx, int))
|
| 1247 |
+
unmatched_pred_indices = all_pred_indices - matched_pred_indices
|
| 1248 |
+
|
| 1249 |
+
if unmatched_pred_indices:
|
| 1250 |
+
if unmatched_gt_indices:
|
| 1251 |
+
distance_matrix = [
|
| 1252 |
+
# [Levenshtein_distance(norm_gt_lines[gt_idx], norm_pred_lines[pred_idx]) for pred_idx in unmatched_pred_indices]
|
| 1253 |
+
[Levenshtein_distance(norm_gt_lines[gt_idx], norm_pred_lines[pred_idx])/max(len(norm_gt_lines[gt_idx]), len(norm_pred_lines[pred_idx])) for pred_idx in unmatched_pred_indices]
|
| 1254 |
+
for gt_idx in unmatched_gt_indices
|
| 1255 |
+
]
|
| 1256 |
+
|
| 1257 |
+
row_ind, col_ind = linear_sum_assignment(distance_matrix)
|
| 1258 |
+
|
| 1259 |
+
for i, j in zip(row_ind, col_ind):
|
| 1260 |
+
gt_idx = list(unmatched_gt_indices)[i]
|
| 1261 |
+
pred_idx = list(unmatched_pred_indices)[j]
|
| 1262 |
+
result_entry = {
|
| 1263 |
+
'gt_idx': int(gt_idx),
|
| 1264 |
+
'gt': norm_gt_lines[gt_idx],
|
| 1265 |
+
'pred_idx': [pred_idx],
|
| 1266 |
+
'pred': norm_pred_lines[pred_idx],
|
| 1267 |
+
'edit': 1
|
| 1268 |
+
}
|
| 1269 |
+
converted_results.append(result_entry)
|
| 1270 |
+
|
| 1271 |
+
matched_gt_indices.update(list(unmatched_gt_indices)[i] for i in row_ind)
|
| 1272 |
+
else:
|
| 1273 |
+
result_entry = {
|
| 1274 |
+
'gt_idx': "",
|
| 1275 |
+
'gt': '',
|
| 1276 |
+
'pred_idx': list(unmatched_pred_indices),
|
| 1277 |
+
'pred': ' '.join(norm_pred_lines[pred_idx] for pred_idx in unmatched_pred_indices),
|
| 1278 |
+
'edit': 1
|
| 1279 |
+
}
|
| 1280 |
+
converted_results.append(result_entry)
|
| 1281 |
+
else:
|
| 1282 |
+
for gt_idx in unmatched_gt_indices:
|
| 1283 |
+
result_entry = {
|
| 1284 |
+
'gt_idx': int(gt_idx),
|
| 1285 |
+
'gt': norm_gt_lines[gt_idx],
|
| 1286 |
+
'pred_idx': "",
|
| 1287 |
+
'pred': '',
|
| 1288 |
+
'edit': 1
|
| 1289 |
+
}
|
| 1290 |
+
converted_results.append(result_entry)
|
| 1291 |
+
|
| 1292 |
+
return converted_results
|
FinixDocBench_Eval_for_Markdown/finixdoc_md_eval/utils/table_utils.py
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
def markdown_to_html(markdown_table):
|
| 5 |
+
rows = [row.strip() for row in markdown_table.strip().split('\n') if row.strip()]
|
| 6 |
+
if len(rows) < 2:
|
| 7 |
+
return markdown_table
|
| 8 |
+
|
| 9 |
+
html_table = '<table>\n <thead>\n <tr>\n'
|
| 10 |
+
header_cells = [cell.strip() for cell in rows[0].split('|')[1:-1]]
|
| 11 |
+
for cell in header_cells:
|
| 12 |
+
html_table += f' <th>{cell}</th>\n'
|
| 13 |
+
html_table += ' </tr>\n </thead>\n <tbody>\n'
|
| 14 |
+
|
| 15 |
+
for row in rows[2:]:
|
| 16 |
+
cells = [cell.strip() for cell in row.split('|')[1:-1]]
|
| 17 |
+
html_table += ' <tr>\n'
|
| 18 |
+
for cell in cells:
|
| 19 |
+
html_table += f' <td>{cell}</td>\n'
|
| 20 |
+
html_table += ' </tr>\n'
|
| 21 |
+
|
| 22 |
+
html_table += ' </tbody>\n</table>\n'
|
| 23 |
+
return html_table
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def convert_table_str(s):
|
| 27 |
+
s = re.sub(r'<table.*?>', '<table>', s)
|
| 28 |
+
s = re.sub(r'<th', '<td', s)
|
| 29 |
+
s = re.sub(r'</th>', '</td>', s)
|
| 30 |
+
res = '\n\n'
|
| 31 |
+
temp_item = ''
|
| 32 |
+
for c in s:
|
| 33 |
+
temp_item += c
|
| 34 |
+
if c == '>' and not re.search(r'<td.*?>\$', temp_item):
|
| 35 |
+
res += temp_item + '\n'
|
| 36 |
+
temp_item = ''
|
| 37 |
+
return res + '\n'
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def find_md_table_mode(line):
|
| 41 |
+
return bool(re.search(r'-*?:', line) or re.search(r'---', line) or re.search(r':-*?', line))
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def delete_table_and_body(input_list):
|
| 45 |
+
return [line for line in input_list if not re.search(r'</?t(able|head|body)>', line)]
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def merge_table(md):
|
| 49 |
+
return convert_table_str(''.join(md))
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def replace_table_with_placeholder(input_string):
|
| 53 |
+
lines = input_string.split('\n')
|
| 54 |
+
output_lines = []
|
| 55 |
+
in_table_block = False
|
| 56 |
+
temp_block = ''
|
| 57 |
+
last_line = ''
|
| 58 |
+
|
| 59 |
+
for line in lines:
|
| 60 |
+
if '<table>' in line:
|
| 61 |
+
in_table_block = True
|
| 62 |
+
temp_block += last_line
|
| 63 |
+
elif in_table_block:
|
| 64 |
+
if not find_md_table_mode(last_line) and '</thead>' not in last_line:
|
| 65 |
+
temp_block += '\n' + last_line
|
| 66 |
+
if '</table>' in last_line:
|
| 67 |
+
if '<table>' not in line:
|
| 68 |
+
in_table_block = False
|
| 69 |
+
output_lines.append(merge_table(temp_block))
|
| 70 |
+
temp_block = ''
|
| 71 |
+
else:
|
| 72 |
+
output_lines.append(last_line)
|
| 73 |
+
last_line = line
|
| 74 |
+
|
| 75 |
+
if last_line:
|
| 76 |
+
if in_table_block or '</table>' in last_line:
|
| 77 |
+
temp_block += '\n' + last_line
|
| 78 |
+
output_lines.append(merge_table(temp_block))
|
| 79 |
+
else:
|
| 80 |
+
output_lines.append(last_line)
|
| 81 |
+
|
| 82 |
+
return '\n'.join(output_lines)
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
def convert_table(input_str):
|
| 86 |
+
output_str = input_str.replace('<table>', '<table border="1" >')
|
| 87 |
+
output_str = output_str.replace('<td>', '<td colspan="1" rowspan="1">')
|
| 88 |
+
return output_str
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
def convert_markdown_to_html(markdown_content):
|
| 92 |
+
markdown_content = markdown_content.replace('\r', '') + '\n'
|
| 93 |
+
pattern = re.compile(r'\|\s*.*?\s*\|\n', re.DOTALL)
|
| 94 |
+
matches = pattern.findall(markdown_content)
|
| 95 |
+
|
| 96 |
+
for match in matches:
|
| 97 |
+
html_table = markdown_to_html(match)
|
| 98 |
+
markdown_content = markdown_content.replace(match, html_table, 1)
|
| 99 |
+
|
| 100 |
+
return convert_table(replace_table_with_placeholder(markdown_content))
|
track2_finixphoto_300/mds/00c07dff-e570-5c66-9caa-37b6254d859c.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
住院次数 1
|
| 2 |
+
|
| 3 |
+
# 河南省医疗住院收费票据
|
| 4 |
+
|
| 5 |
+
呼吸内科
|
| 6 |
+
|
| 7 |
+
票据代码:豫H010214
|
| 8 |
+
|
| 9 |
+
票据校验码:RH010
|
| 10 |
+
|
| 11 |
+
业务流水号: 0110600129 病案号: 28 09
|
| 12 |
+
|
| 13 |
+
院区号:
|
| 14 |
+
|
| 15 |
+
住院时间:
|
| 16 |
+
|
| 17 |
+
10月19日
|
| 18 |
+
|
| 19 |
+
287 09
|
| 20 |
+
|
| 21 |
+
出院日期: 21
|
| 22 |
+
|
| 23 |
+
NO.
|
| 24 |
+
|
| 25 |
+
姓名:
|
| 26 |
+
|
| 27 |
+
男
|
| 28 |
+
|
| 29 |
+
社会保障号码:
|
| 30 |
+
|
| 31 |
+
城镇职工(金保)
|
| 32 |
+
|
| 33 |
+
<table><tr><th>收费项目</th><th>金额</th><th>个人支付金额</th><th>收费项目</th><th>金额</th><th>个人支付金额</th><th>收费项目</th><th>金额</th><th>个人支付金额</th></tr><tr><td>西药费</td><td>2318.58</td><td></td><td>中成药费</td><td>310.65</td><td></td><td>治疗费</td><td>468.50</td><td></td></tr><tr><td>放射费</td><td>390.00</td><td></td><td>化验费</td><td>2916.00</td><td></td><td>材料费</td><td>7.95</td><td></td></tr><tr><td>床位费</td><td>420.00</td><td></td><td>诊查费</td><td>63.00</td><td></td><td>其它</td><td>52.50</td><td></td></tr><tr><td>检查费</td><td>810.00</td><td></td><td></td><td></td><td></td><td>护理费</td><td>105.00</td><td></td></tr></table>
|
| 34 |
+
|
| 35 |
+
本票据为财务专用章,严禁伪造、变造,否则无效
|
| 36 |
+
|
| 37 |
+
医保卡余额: 201.48
|
| 38 |
+
|
| 39 |
+
自费费用: 1455.93
|
| 40 |
+
|
| 41 |
+
个人自付:364.56
|
| 42 |
+
|
| 43 |
+
按比例自付:666.25
|
| 44 |
+
|
| 45 |
+
<table><tr><td>合计(大写):</td><td>柒仟壹佰陆拾贰元壹角捌分</td><td>7162.18</td><td>大额记账:</td><td>0</td></tr><tr><td>预缴金额:</td><td>3500.00</td><td>补缴金额:</td><td>0.00</td><td>退费金额:</td><td>113.26</td><td>公务员记账:</td><td>0</td></tr><tr><td>起付标准:</td><td>900</td><td>医保统筹支付:</td><td>3775.44</td><td>个人账户支付:</td><td>0</td><td>其他医保支付:</td><td>3386.74</td></tr><tr><td>收款单位(章):</td><td colspan=7></td></tr><tr><td>收款人(签章):</td><td colspan=7></td></tr></table>
|
| 46 |
+
|
| 47 |
+
收款人(章):
|
track2_finixphoto_300/mds/00cedd70-e693-42ac-855f-d8f9b0ccf8f3.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 湖北省医疗单位住院收费票据
|
| 2 |
+
|
| 3 |
+
费单位 武汉大学中南医院
|
| 4 |
+
|
| 5 |
+
院科室 心脏血管外科病区
|
| 6 |
+
|
| 7 |
+
00184902
|
| 8 |
+
|
| 9 |
+
性别
|
| 10 |
+
|
| 11 |
+
年龄
|
| 12 |
+
|
| 13 |
+
住院
|
| 14 |
+
|
| 15 |
+
时间
|
| 16 |
+
|
| 17 |
+
2018年11月27日
|
| 18 |
+
|
| 19 |
+
医保类型
|
| 20 |
+
|
| 21 |
+
入院日期:2018年09月27日
|
| 22 |
+
|
| 23 |
+
出院日期 2018年11月27日
|
| 24 |
+
|
| 25 |
+
共住院 61 天
|
| 26 |
+
|
| 27 |
+
结肠镜 300.00
|
| 28 |
+
病室治疗费 211066.95
|
| 29 |
+
住院费 3060.00
|
| 30 |
+
同位素 80.00
|
| 31 |
+
病检费 1515.00
|
| 32 |
+
|
| 33 |
+
化验费 89815.00
|
| 34 |
+
肺功能 4776.00
|
| 35 |
+
心电图 485.00
|
| 36 |
+
透析费 68910.00
|
| 37 |
+
胃镜检查 4900.00
|
| 38 |
+
|
| 39 |
+
B超费 4637.00
|
| 40 |
+
西药费 478038.29
|
| 41 |
+
手术费用 11128.60
|
| 42 |
+
放射费 1085.00
|
| 43 |
+
检查费 43464.00
|
| 44 |
+
|
| 45 |
+
介入治疗 9000.00
|
| 46 |
+
血费 59680.00
|
| 47 |
+
中药费 4511.87
|
| 48 |
+
CT费 1152.00
|
| 49 |
+
仪器监测 37505.00
|
| 50 |
+
|
| 51 |
+
纤支镜 5040.00
|
| 52 |
+
|
| 53 |
+
(预收:924000.00(信用卡:924000) 补收: 信用卡:116139.71
|
| 54 |
+
|
| 55 |
+
金额合计(大写):壹佰零肆万零壹佰叁拾玖元柒角壹分
|
| 56 |
+
|
| 57 |
+
¥1040139.71
|
| 58 |
+
|
| 59 |
+
002501
|
| 60 |
+
|
| 61 |
+
0002318
|
track2_finixphoto_300/mds/00e93638-9af3-4bca-b249-c414440b54dd.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
发票号:9102454
|
| 2 |
+
|
| 3 |
+
2020-06-29 16:16
|
| 4 |
+
|
| 5 |
+
# 山西省医疗门诊收费票据
|
| 6 |
+
|
| 7 |
+
56313.
|
| 8 |
+
|
| 9 |
+
2020062990
|
| 10 |
+
|
| 11 |
+
业务
|
| 12 |
+
|
| 13 |
+
医疗类型:
|
| 14 |
+
|
| 15 |
+
NO.91024540
|
| 16 |
+
|
| 17 |
+
姓名:
|
| 18 |
+
|
| 19 |
+
性别:
|
| 20 |
+
|
| 21 |
+
医保类型:
|
| 22 |
+
|
| 23 |
+
社会保障号码:
|
| 24 |
+
|
| 25 |
+
<table><tr><td>项目规格</td><td>数量</td><td>金额</td><td>个人支付金额</td></tr><tr><td>各类病原体(DNA、RNA)测定</td><td>1.人次</td><td></td><td>60.00</td></tr><tr><td>核酸检测试剂</td><td>1.人份</td><td></td><td>14.08</td></tr></table>
|
| 26 |
+
|
| 27 |
+
56313.160 共2条:应收74.08;实收74.08
|
| 28 |
+
|
| 29 |
+
合计(大写) 柒拾肆元零角捌分
|
| 30 |
+
|
| 31 |
+
¥ 74.08
|
| 32 |
+
|
| 33 |
+
支付方式微信支付
|
| 34 |
+
|
| 35 |
+
医保统筹支付:0.00
|
| 36 |
+
|
| 37 |
+
个人账户支付: ¥0.00
|
| 38 |
+
|
| 39 |
+
其他医保支付: 0.00
|
| 40 |
+
|
| 41 |
+
个人支付金额:74.08
|
| 42 |
+
|
| 43 |
+
山西省财政厅监制 银威特印业印制
|
| 44 |
+
|
| 45 |
+
收据清单 盖章有效 遗失不补
|
| 46 |
+
|
| 47 |
+
收款单位(章):山西省人民医院检验科
|
| 48 |
+
|
| 49 |
+
收款人(签章): 90
|
| 50 |
+
|
| 51 |
+
2020年06月29日
|
| 52 |
+
|
| 53 |
+
2020-06-29 16:16
|
track2_finixphoto_300/mds/0170086d-957e-4ec2-b505-92cece37d302.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 中国人民解放军医疗门诊收费票据
|
| 2 |
+
|
| 3 |
+
ID: 70001729
|
| 4 |
+
|
| 5 |
+
70001729
|
| 6 |
+
|
| 7 |
+
票控盘号: 0010003698
|
| 8 |
+
|
| 9 |
+
票控码:00100036986
|
| 10 |
+
|
| 11 |
+
(2019): 1901088636
|
| 12 |
+
|
| 13 |
+
业务流水号: B403449
|
| 14 |
+
|
| 15 |
+
医疗机构类型:大型综合医院
|
| 16 |
+
|
| 17 |
+
机打票号: 1901088636
|
| 18 |
+
|
| 19 |
+
姓名:
|
| 20 |
+
|
| 21 |
+
性别:女
|
| 22 |
+
|
| 23 |
+
医保类型:
|
| 24 |
+
|
| 25 |
+
社会保障号码:
|
| 26 |
+
|
| 27 |
+
<table><tr><td>项目/规格</td><td>数量</td><td>金额</td><td>个人支付金额</td><td>项目/规格</td><td>数量</td><td>金额</td><td>个人支付金额</td></tr><tr><td>下腹部X体层(CT)增强扫描(乙)</td><td>1</td><td>每个部位 354.2</td><td></td><td></td><td></td><td></td><td></td></tr></table>
|
| 28 |
+
|
| 29 |
+
合计(大写): 叁佰伍拾肆元贰角整
|
| 30 |
+
|
| 31 |
+
¥ :354.20
|
| 32 |
+
|
| 33 |
+
医保统筹支付:
|
| 34 |
+
|
| 35 |
+
个人账户支付:
|
| 36 |
+
|
| 37 |
+
其他医保支付:
|
| 38 |
+
|
| 39 |
+
个人支付金额:
|
| 40 |
+
|
| 41 |
+
第一联 收据联 盖章有效 遗失不补 手写无效
|
| 42 |
+
二零二零年六月底前有效
|
| 43 |
+
|
| 44 |
+
收款单位(盖章):
|
| 45 |
+
|
| 46 |
+
收款人(签章):9490
|
| 47 |
+
|
| 48 |
+
2020/03/06 缴费日期:2020-03-06
|
| 49 |
+
|
| 50 |
+
年 月 日
|
| 51 |
+
|
| 52 |
+
现金:354.20
|
track2_finixphoto_300/mds/0428c7d7-8d44-403a-8f16-c244fd488f86.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 山 西 省 医 疗 住 院 收 费 票 据
|
| 2 |
+
|
| 3 |
+
业务流水号:
|
| 4 |
+
|
| 5 |
+
医疗机构类型:综合三甲
|
| 6 |
+
|
| 7 |
+
病历号 003536
|
| 8 |
+
|
| 9 |
+
住院号:003536
|
| 10 |
+
|
| 11 |
+
住院时间: 2021 年 2 月 28 日到 2021 年 3 月 12 日
|
| 12 |
+
|
| 13 |
+
住院天数::12
|
| 14 |
+
|
| 15 |
+
N 90014827
|
| 16 |
+
|
| 17 |
+
山西省财政厅监制 山西卫生报印刷厂印制
|
| 18 |
+
|
| 19 |
+
<table>
|
| 20 |
+
<tr>
|
| 21 |
+
<td>姓名</td>
|
| 22 |
+
<td></td>
|
| 23 |
+
<td>性别</td>
|
| 24 |
+
<td>男</td>
|
| 25 |
+
<td>医保类型</td>
|
| 26 |
+
<td>其他人员</td>
|
| 27 |
+
<td colspan="3">社会保障号码</td>
|
| 28 |
+
<td></td>
|
| 29 |
+
<td></td>
|
| 30 |
+
<td></td></tr>
|
| 31 |
+
<tr>
|
| 32 |
+
<td>项目</td>
|
| 33 |
+
<td>金额(元)</td>
|
| 34 |
+
<td>项目</td>
|
| 35 |
+
<td>金额(元)</td>
|
| 36 |
+
<td>项目</td>
|
| 37 |
+
<td>金额(元)</td>
|
| 38 |
+
<td>项目</td>
|
| 39 |
+
<td>金额(元)</td>
|
| 40 |
+
<td>项目</td>
|
| 41 |
+
<td>金额(元)</td></tr>
|
| 42 |
+
<tr>
|
| 43 |
+
<td>床位费</td>
|
| 44 |
+
<td>444.00</td>
|
| 45 |
+
<td>诊察费</td>
|
| 46 |
+
<td>240.00</td>
|
| 47 |
+
<td>检查费</td>
|
| 48 |
+
<td>2102.00</td>
|
| 49 |
+
<td>化验费</td>
|
| 50 |
+
<td>1709.00</td>
|
| 51 |
+
<td>治疗费</td>
|
| 52 |
+
<td>4091.00</td></tr>
|
| 53 |
+
<tr>
|
| 54 |
+
<td>手术费</td>
|
| 55 |
+
<td></td>
|
| 56 |
+
<td>护理费</td>
|
| 57 |
+
<td>519.00</td>
|
| 58 |
+
<td>卫生材料费</td>
|
| 59 |
+
<td>2119.53</td>
|
| 60 |
+
<td>西药费</td>
|
| 61 |
+
<td>8511.38</td>
|
| 62 |
+
<td>中草药费</td>
|
| 63 |
+
<td></td></tr>
|
| 64 |
+
<tr>
|
| 65 |
+
<td>中成药费</td>
|
| 66 |
+
<td>744.98</td>
|
| 67 |
+
<td>药事服务费</td>
|
| 68 |
+
<td></td>
|
| 69 |
+
<td>一般诊疗费</td>
|
| 70 |
+
<td></td>
|
| 71 |
+
<td></td>
|
| 72 |
+
<td></td>
|
| 73 |
+
<td></td>
|
| 74 |
+
<td></td></tr>
|
| 75 |
+
<tr>
|
| 76 |
+
<td colspan="5">合计(大写)贰万零肆佰捌拾元捌角玖分</td>
|
| 77 |
+
<td>¥</td>
|
| 78 |
+
<td colspan="2">20480.89</td>
|
| 79 |
+
<td>付款方式</td>
|
| 80 |
+
<td></td></tr>
|
| 81 |
+
<tr>
|
| 82 |
+
<td colspan="4">预缴金额:11506.70 起付线 0</td>
|
| 83 |
+
<td colspan="3">补缴金额:</td>
|
| 84 |
+
<td colspan="3">退费金额:</td></tr>
|
| 85 |
+
<tr>
|
| 86 |
+
<td colspan="2">医保统筹支付:8973.29</td>
|
| 87 |
+
<td colspan="2">个人账户支付: 0.90</td>
|
| 88 |
+
<td colspan="2">其他医保支付: 0.00</td>
|
| 89 |
+
<td colspan="4">个人支付金额: 11506.70</td></tr>
|
| 90 |
+
</table>
|
| 91 |
+
|
| 92 |
+
第一联 收据联 盖章有效 遗失不补
|
| 93 |
+
|
| 94 |
+
收款单位(章):山西白求恩医院
|
| 95 |
+
|
| 96 |
+
收款人(签章):5102
|
| 97 |
+
|
| 98 |
+
2021年3月12日
|
track2_finixphoto_300/mds/0704a982-8416-4d2f-a2b1-f10506301d50.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 华北理工大学附属医院
|
| 2 |
+
|
| 3 |
+
# 出院记录
|
| 4 |
+
|
| 5 |
+
姓名:-
|
| 6 |
+
|
| 7 |
+
性別:男
|
| 8 |
+
|
| 9 |
+
年龄:35岁
|
| 10 |
+
|
| 11 |
+
病案号:
|
| 12 |
+
|
| 13 |
+
入院日期:2019-10-
|
| 14 |
+
|
| 15 |
+
出院日期: 2019-12-
|
| 16 |
+
|
| 17 |
+
共住院71天
|
| 18 |
+
|
| 19 |
+
入院当时情况:患者主因诊断骨髓增生异常综合征6月余入院,查体:T 36.9℃,P98112次/分,R19次/分,Bp132/63mmHg,贫血貌,周身皮肤粘膜无出血点,浅表淋巴结不大,巩膜无黄染,咽部无红肿,胸骨无压痛,双肺呼吸音清,未闻及干湿性啰音,心律齐,各瓣膜听诊区未闻及病理性杂音,腹平软,全腹无压痛,无反跳痛及肌紧张,肝、脾肋下未及。双下肢无水肿,病理征阴性。既往2型糖尿病病史6月,不规律口服"二甲双胍 格列齐特"治疗。
|
| 20 |
+
|
| 21 |
+
入院诊断:骨髓增生异常综合征-RAEB-1(IPSS中危-1;IPSS-R 高危) 2型糖尿病。
|
| 22 |
+
|
| 23 |
+
住院诊治经过:完善各项检查:1.依据:①患者中青年男性,急性病程。②诊断骨髓增生异常综合征5月。③临床上主要表现为乏力、出血、感染。患者2019年4月因头晕就诊于唐山市工人医院,初诊血常规WBC3.69×10^9/L,PLT61×10^9/L,HGB87g/l。骨髓常规、骨髓活检考虑MDS,未见PNH克隆;免疫分型:染色体:46,XY【4】,JAK2/V617F阴性。诊断为骨髓增生异常综合征-EB-1(IPSS中危-1),口服"司坦唑醇、升血宝、环孢素"治疗,后自行停药。2.依据既往病史诊断为2型糖尿病。患者血钾高,补充诊断:高钾血症。患者血钠低,补充诊断:低钠血症。依据凝血系列,补充诊断:低纤维蛋白原血症。患者HSCT术后早期,造血细胞植入不良,长期粒细胞减低,机体免疫力极度低下,近日持续低热,昨晚体温最高38.3℃,胸部CT未见明显炎性病变,故考虑为感染性发热,补充诊断。入院后查血常规(血细胞分析)(住院):白细胞[WBC] 1.6x10⁹/L↓;血红蛋白[HGB] 58g/L↓;血小板[PLT] 28x10⁹/L↓;乙肝两对半(5项):乙型肝炎病毒表面抗原 0IU /mL;肝肾功能、电解质:乳酸脱氢酶 340U /L↑,羟丁酸脱氢酶 283U /L↑,肌红蛋白 5ug /L↓,肌酐(氧化酶法) 55umol/L↓,葡萄糖 7.91mmol/L↑,铁 60.2umol/L↑;免疫系列(非医保):补体C3 72.3mg /dl↓,补体C4 40.8mg /dl↑,免疫球蛋白A 85.4mg /dl↓,免疫球蛋白G 1000.0mg /dl↓,免疫球蛋白M 67.9mg /dl↓;凝血系列检查结果正常;甲功六项(电化学发光法)检查结果正常;梅毒螺旋体特异抗体测定ELA法 阴性(-);请内分泌科会诊建议:普通胰岛素6u、6u、6u;三餐前半小时皮下注射;监测血糖4/日。头颅核磁:1.右侧额部大脑镰旁异常强化,不除外脑膜瘤,建议复查。2.脑实质MR平扫及增强扫描未见异常。腹部增强CT:1.肝左叶低密度影显示不清。2.胆囊密度欠均匀较前缓解。3.肝大,脾大,较前未见明显变化,请结合相关检查。4.胰腺CT增强未见异常。胸部CT:1.右肺上叶结节影,建议定期复查。2.两侧胸膜粘连,较前未见明显变化。3.心腔密度减低,较前未见明显变化,请结合临床。骨髓细胞学检查:骨髓增生重度低下,原粒细胞比例增高,红系比例增高,巨核细胞少伴部分巨核细胞形态异常。HSCT术后1月复查骨髓常规(髂后):此部位骨
|
| 24 |
+
|
| 25 |
+
第 1 页
|
track2_finixphoto_300/mds/0809dc84-f135-411e-9459-8d69bda2c15e.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 哈尔滨医科大学附属肿瘤医院
|
| 2 |
+
|
| 3 |
+
# (黑龙江省肿瘤医院)
|
| 4 |
+
|
| 5 |
+
# 出 院 记 录
|
| 6 |
+
|
| 7 |
+
姓名:
|
| 8 |
+
|
| 9 |
+
性别:男
|
| 10 |
+
|
| 11 |
+
年龄:53岁
|
| 12 |
+
|
| 13 |
+
科别:
|
| 14 |
+
|
| 15 |
+
住院号:
|
| 16 |
+
|
| 17 |
+
入院科室:
|
| 18 |
+
|
| 19 |
+
出院科室:
|
| 20 |
+
|
| 21 |
+
入院日期:2019年12月
|
| 22 |
+
|
| 23 |
+
出院日期:2019年12月
|
| 24 |
+
|
| 25 |
+
入院诊断: 直肠癌
|
| 26 |
+
|
| 27 |
+
出院诊断: 直肠癌
|
| 28 |
+
|
| 29 |
+
入院情况:中年男患,既往体健,患者于2019年10月初无明显诱因出现排便习惯改变,肛门口可触及肿物,无便中带血,无黑便,无便稀,无便细,无里急后重,无肛门坠胀感,有排便不尽感,无腹泻,无腹痛,无贫血,无乏力,排便频率增加,2-3次/日。遂于当地医院行肛门检查示:肛门口见一肿物,质脆易出血。病理回报:直肠(腺癌)(大庆市第四医院)。2019年10月16日就诊于我院明确诊断:直肠癌,根据患者病情给予患者行直肠癌新辅助化疗XELOX方案化疗二周期,化疗后患者偶有上腹部不适,查体:一般状态良好,步入病房,神清语明,皮肤黏膜未见黄染,无出血点,双肺呼吸音清,心律齐,各瓣膜区未闻及病理性杂音,腹平软,未见肠型及蠕动波,无压痛、反跳痛及肌紧张,叩诊移动性浊音(-),肝脾肋下未及,双下肢无水肿。
|
| 30 |
+
|
| 31 |
+
诊疗经过:患者按结直肠常规入院,入院后行相关检查检验,于住院期间行保肝对症治疗,治疗期间给予Xelox化疗方案一周期,化疗后患者无明显不适主诉,今日准予患者出院,嘱出院后行抗肿瘤综合治疗,并定期复查,不适随诊。
|
| 32 |
+
|
| 33 |
+
出院时情况:患者一般状况良好,神清语明,心肺未见明显异常,腹部平软,全腹无压痛反跳痛及肌紧张,活动自如。今日出院,嘱定期复查。
|
| 34 |
+
|
| 35 |
+
出院医嘱:1、定期复查2、不适随诊3、注意化疗期间饮食
|
| 36 |
+
|
| 37 |
+
主治医师:
|
| 38 |
+
|
| 39 |
+
2019年12月22日
|
| 40 |
+
|
| 41 |
+
哈尔滨医科大学附属第三医院
|
| 42 |
+
|
| 43 |
+
医疗表格统一编号1-02
|
track2_finixphoto_300/mds/08605a96-3a7d-4fad-9f0a-bfb3e5105d39.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 郑州大学第五附属医院
|
| 2 |
+
|
| 3 |
+
姓名
|
| 4 |
+
|
| 5 |
+
性别 男
|
| 6 |
+
|
| 7 |
+
年龄 45岁
|
| 8 |
+
|
| 9 |
+
床号
|
| 10 |
+
|
| 11 |
+
住院号
|
| 12 |
+
|
| 13 |
+
2019.12
|
| 14 |
+
|
| 15 |
+
# 出院记录
|
| 16 |
+
|
| 17 |
+
姓名:
|
| 18 |
+
|
| 19 |
+
性别:男
|
| 20 |
+
|
| 21 |
+
年龄:45岁
|
| 22 |
+
|
| 23 |
+
入院日期:2019.10
|
| 24 |
+
|
| 25 |
+
出院日期:2019.12.
|
| 26 |
+
|
| 27 |
+
共住院: 59天
|
| 28 |
+
|
| 29 |
+
入院情况:患者中年男性,急性起病,以“(代)突起意识丧失6月余”为代主诉来院。既往“高血压”2年余,最高达160/100mmHg,未服用降压药物治疗。20年前行“阑尾切除术”;2年前行“喉息肉切除术”。无药物过敏史。入院查体:体温37.2℃,脉搏70次/分,呼吸18次/分,血压120/78mmHg。浅昏迷,高级智能不能查。双侧瞳孔等大等圆,直径约3mm,直接及间接对光反射存在;张口下颌不配合,双侧掌颏反射阴性;双侧额纹对称,双侧鼻唇沟对称,示齿口角不配合,味觉、听力不配合;双侧转颈耸肩查体不合作;伸舌不配合。四肢肌张力高,四肢腱反射活跃,四肢肌力查体不配合,双侧巴氏征阳性,双侧指鼻试验及跟-膝-胫试验不合作,闭目难立征不合作,无不自主运动。感觉系统检查查体不合作。自主神经系统检查阴性。脑膜刺激征阳性。双肺呼吸音粗,可闻及较多湿性啰音,心率70次/分,律齐,心音可,腹平软,无压痛及反跳痛,肝脾肋缘下未触及,双下肢无水肿。辅助检查:CT示(本院2019-9-17):1、脑干软化灶形成,结合病史考虑出血吸收后改变,对比2019.08.26片变化不明显。2、左侧基底节区腔梗、脑白质脱髓鞘;3、两肺炎症,对比2019.08.26片无明显变化。双侧胸膜增厚。
|
| 30 |
+
|
| 31 |
+
入院诊断:1.脑出血;2.高血压病2级,极高危;3.肺炎;4、气管切开术后;5.亚甲状腺功能减退症;6.前列腺增生;7.肩关节半脱位;8.尿路感染;9.便秘;10.脂溢性皮炎。
|
| 32 |
+
|
| 33 |
+
诊疗经过:入院后完善相关检查;给予吸氧、心电监护,密切观察病情变化;给予胞磷胆碱营养脑细胞、醒脑静促醒、鼠神经生长因子营养神经、痰热清祛痰、雾化祛痰、康复理疗等治疗。2019-10-16 尿常规:白细胞241.60/ul,上皮细胞0.60/ul,细菌5197.80/ul。血脂7项:甘油三酯2.00mmol/L,高密度脂蛋白胆固醇0.61mmol/L,载脂蛋白A10.90g/L。甲状腺功能五项:超敏促甲状腺激素0.424mIU/l,甲状腺球蛋白抗体>500.00U/ml,甲状腺过氧化物酶抗体1190.50U/ml。血沉:魏氏血沉40毫米/小时。痰培养及鉴定:培养出革兰氏阳性杆菌。患者脑出血,给予营养脑细胞、醒脑静促醒、鼠神经生长因子营养神经及康复治疗,给予美金刚改善认知,查脑电图明确病情变化;患者肺炎,给予依替米星抗炎抗感染、雾化祛痰等治疗。患者尿中白细胞数、细菌数明显增高,诊断为尿路感染,行尿培养查找敏感抗生素。患者发热、咳嗽咳痰,诊断为肺炎,根据药敏结果给予哌拉西林抗感染治疗,给予雾化祛痰、加强翻身拍背。患者尿中白细胞数、细菌数明显升高,诊断为尿路感染,给予诺氟沙星抗感染治疗,嘱患者多饮水。患者脑出血后浅昏迷,继续给予营养脑细胞、抗感染等治疗,行针灸、高压氧、免疫三氧血、康复理疗等治疗。患者脑出血后仍浅昏迷,给予吡拉西坦营养脑细胞、纳美芬促醒等治疗。经上述治疗,患者病情好转,要求出院,请示上级医师后同意其今日出院。
|
| 34 |
+
|
| 35 |
+
第 1 页
|
track2_finixphoto_300/mds/09c2592b-a278-4bf9-99ba-4c7fbc91bb5d.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 广西壮族自治区医疗住院收费票据
|
| 2 |
+
|
| 3 |
+
1450602
|
| 4 |
+
|
| 5 |
+
No 0002
|
| 6 |
+
|
| 7 |
+
票据代码:
|
| 8 |
+
|
| 9 |
+
专科医院
|
| 10 |
+
|
| 11 |
+
票据号码:
|
| 12 |
+
|
| 13 |
+
电子票据代码:
|
| 14 |
+
|
| 15 |
+
中区直基本医疗保险
|
| 16 |
+
|
| 17 |
+
电子票据号码:20731
|
| 18 |
+
|
| 19 |
+
交款人统一社会信用代码
|
| 20 |
+
|
| 21 |
+
校验码
|
| 22 |
+
|
| 23 |
+
交款人:
|
| 24 |
+
|
| 25 |
+
2021年03月15日-2021年04月25日
|
| 26 |
+
|
| 27 |
+
普通居民
|
| 28 |
+
|
| 29 |
+
开票日期:2021年04月25日
|
| 30 |
+
|
| 31 |
+
<table><tr><td>项目名称</td><td>金额(元)</td><td>备注</td><td>项目名称</td><td>金额(元)</td><td>备注</td><td>项目名称</td><td>金额(元)</td><td>备注</td></tr><tr><td>西药</td><td>18,627.65</td><td></td><td>中成药</td><td>1,273.15</td><td></td><td>中草药</td><td></td><td></td></tr><tr><td>检查费</td><td>9,633.30</td><td></td><td>化验费</td><td>5,176.60</td><td></td><td>治疗费</td><td>77,516.10</td><td></td></tr><tr><td>手术费</td><td>292.00</td><td></td><td>输氧费</td><td></td><td></td><td>输血费</td><td></td><td></td></tr><tr><td>护理费</td><td>2,301.40</td><td></td><td>麻醉费</td><td>16.90</td><td></td><td>注射费</td><td></td><td></td></tr><tr><td>病理费</td><td>687.60</td><td></td><td>床位费</td><td>571.00</td><td></td><td>材料费</td><td>2,350.96</td><td></td></tr><tr><td>特殊检查费</td><td></td><td></td><td>特殊治疗费</td><td></td><td></td><td>其他费用</td><td>174.60</td><td></td></tr>
|
| 32 |
+
</table>
|
| 33 |
+
|
| 34 |
+
金额合计(大写)壹拾壹万捌仟陆佰贰拾壹元贰角柒分
|
| 35 |
+
|
| 36 |
+
(小写)118,621.27
|
| 37 |
+
|
| 38 |
+
其他信息
|
| 39 |
+
|
| 40 |
+
预交金额:70000.00
|
| 41 |
+
|
| 42 |
+
补交金额:27211.88
|
| 43 |
+
|
| 44 |
+
退款金额:0.00
|
| 45 |
+
|
| 46 |
+
社保账号:
|
| 47 |
+
|
| 48 |
+
公务员补助:0.00
|
| 49 |
+
|
| 50 |
+
大额医疗支付:
|
| 51 |
+
|
| 52 |
+
统筹支付累计:0.00
|
| 53 |
+
|
| 54 |
+
大额医疗支付累计: 0.00
|
| 55 |
+
|
| 56 |
+
账户余额: 0.00
|
| 57 |
+
|
| 58 |
+
医保统筹支付: 21409.39
|
| 59 |
+
|
| 60 |
+
个人账户支付:0.00
|
| 61 |
+
|
| 62 |
+
其他医保支付:
|
| 63 |
+
|
| 64 |
+
个人支付金额:97211.88
|
| 65 |
+
|
| 66 |
+
异地结算
|
| 67 |
+
|
| 68 |
+
广西瑞熙特种票证印务有限公司承印 0771-3899843
|
| 69 |
+
|
| 70 |
+
第一联 收据
|
| 71 |
+
|
| 72 |
+
收款单位(章):广西医科大学附属肿瘤医院
|
| 73 |
+
|
| 74 |
+
复核人:
|
| 75 |
+
|
| 76 |
+
收款人:
|
track2_finixphoto_300/mds/0b270427-6cba-48f7-93cc-aab09ab25784.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 福建省医疗机构住院收费票据
|
| 2 |
+
|
| 3 |
+
№:00
|
| 4 |
+
|
| 5 |
+
00217070
|
| 6 |
+
|
| 7 |
+
姓名:唐仙
|
| 8 |
+
|
| 9 |
+
科别: 神内科②组
|
| 10 |
+
|
| 11 |
+
00FE009246E209F760
|
| 12 |
+
|
| 13 |
+
住院号:595470
|
| 14 |
+
|
| 15 |
+
流水号:4519476
|
| 16 |
+
|
| 17 |
+
2014年12月01日
|
| 18 |
+
|
| 19 |
+
<table><thead><tr><td>项目</td><td>金额</td><td>项目</td><td>金额</td><td>项目</td><td>金额</td></tr></thead><tbody><tr><td>西药费</td><td>973.61</td><td>检查费</td><td>565.30</td><td>输氧费</td><td>162.00</td></tr><tr><td>床位费</td><td>402.00</td><td>化验费</td><td>1,360.35</td><td></td><td></td></tr><tr><td>诊察费</td><td>44.00</td><td>治疗费</td><td>107.10</td><td></td><td></td></tr><tr><td>护理费</td><td>105.00</td><td>其他费</td><td>106.40</td><td></td><td></td></tr></tbody></table>
|
| 20 |
+
|
| 21 |
+
合计人民币(大写):叁仟捌佰贰拾伍元柒角陆分
|
| 22 |
+
|
| 23 |
+
¥:3,825.76
|
| 24 |
+
|
| 25 |
+
付款方式:
|
| 26 |
+
|
| 27 |
+
现金: ¥
|
| 28 |
+
|
| 29 |
+
转账:¥
|
| 30 |
+
|
| 31 |
+
预收款:4200.00
|
| 32 |
+
|
| 33 |
+
应补交:0.00
|
| 34 |
+
|
| 35 |
+
应退还:374.24
|
| 36 |
+
|
| 37 |
+
个人医疗账户支付:0.00
|
| 38 |
+
|
| 39 |
+
莆田小鱼网
|
| 40 |
+
|
| 41 |
+
www.phish.com
|
| 42 |
+
|
| 43 |
+
统筹基金支付:0.00
|
| 44 |
+
|
| 45 |
+
自付:3,825.76
|
| 46 |
+
|
| 47 |
+
电脑打印,手写无效
|
| 48 |
+
|
| 49 |
+
第一联 收据
|
| 50 |
+
|
| 51 |
+
医疗单位收费章 结算日期:20141122 -20141201
|
| 52 |
+
|
| 53 |
+
经办人:潘美华
|
| 54 |
+
|
| 55 |
+
(未经收费单位盖章无效)
|
track2_finixphoto_300/mds/0b6a9275-725c-4f4b-873c-a20af0ed0ec8.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 湖北增值税普通发票
|
| 2 |
+
|
| 3 |
+
042001900104
|
| 4 |
+
|
| 5 |
+
№ 46751023
|
| 6 |
+
|
| 7 |
+
机器编号:
|
| 8 |
+
|
| 9 |
+
开票日期: 2020年03月01日
|
| 10 |
+
|
| 11 |
+
购买方
|
| 12 |
+
|
| 13 |
+
名 称:
|
| 14 |
+
纳税人识别号:
|
| 15 |
+
地址、电话:
|
| 16 |
+
开户行及账号:
|
| 17 |
+
|
| 18 |
+
密码区
|
| 19 |
+
|
| 20 |
+
03<023>68**>3<8<+700**838857
|
| 21 |
+
464/7<6003<023>68**>3<8<9627
|
| 22 |
+
+7>8
|
| 23 |
+
|
| 24 |
+
<table><tr><td>货物或应税劳务、服务名称</td><td>规格型号</td><td>单位</td><td>数量</td><td>单价</td><td>金额</td><td>税率</td><td>税额</td></tr><tr><td>*餐饮服务*餐饮费</td><td></td><td></td><td></td><td></td><td>1.00</td><td>免税</td><td>***</td></tr><tr><td>合计</td><td></td><td></td><td></td><td></td><td>¥1.00</td><td></td><td>***</td></tr></table>
|
| 25 |
+
|
| 26 |
+
价税合计(大写)
|
| 27 |
+
|
| 28 |
+
⊗壹圆整
|
| 29 |
+
|
| 30 |
+
(小写)¥1.00
|
| 31 |
+
|
| 32 |
+
销售方
|
| 33 |
+
|
| 34 |
+
名 称:
|
| 35 |
+
纳税人识别号:
|
| 36 |
+
地 址、电 话:
|
| 37 |
+
开户行及账号:
|
| 38 |
+
|
| 39 |
+
备注
|
| 40 |
+
|
| 41 |
+
校验码 00718
|
| 42 |
+
|
| 43 |
+
税总函〔2019〕119号 上海东港安全印刷有限公司
|
| 44 |
+
|
| 45 |
+
第一联:记账联 销售方记账凭证
|
| 46 |
+
|
| 47 |
+
收款人:陈锦华
|
| 48 |
+
|
| 49 |
+
复核:林会
|
| 50 |
+
|
| 51 |
+
开票人:刘程
|
| 52 |
+
|
| 53 |
+
销售方:(章)
|
track2_finixphoto_300/mds/0c84a961-ddfe-4c95-84c6-2cee1f9d7bff.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 哈尔滨医科大学附属肿瘤医院
|
| 2 |
+
|
| 3 |
+
# (黑龙江省肿瘤医院)
|
| 4 |
+
|
| 5 |
+
# 出 院 记 录
|
| 6 |
+
|
| 7 |
+
姓名:
|
| 8 |
+
|
| 9 |
+
性别:女
|
| 10 |
+
|
| 11 |
+
年龄:55岁
|
| 12 |
+
|
| 13 |
+
科别:
|
| 14 |
+
|
| 15 |
+
住院号:
|
| 16 |
+
|
| 17 |
+
入院科室:
|
| 18 |
+
|
| 19 |
+
出院科室:
|
| 20 |
+
|
| 21 |
+
入院日期:2019年12月
|
| 22 |
+
|
| 23 |
+
出院日期:2019年12月
|
| 24 |
+
|
| 25 |
+
入院诊断:左肺上叶癌可能,右肺结节
|
| 26 |
+
|
| 27 |
+
出院诊断:左肺上叶癌,右肺结节
|
| 28 |
+
|
| 29 |
+
入院情况:患者一般状态良好,头面部无水肿,颈静脉无怒张,气管居中,未触及明显肿大浅表淋巴结,胸廓无畸形,胸式呼吸对称,胸腹壁无静脉曲张。双肺语颤对等无减弱。未触及胸膜摩擦感,双肺叩诊呈清音,双肺听诊未闻及干湿啰音及其他异常呼吸音。无副癌综合症。腹部无压痛,四肢活动自如,神经反射存在,病理反射未引出。
|
| 30 |
+
|
| 31 |
+
诊疗经过:患者于2019年12月入院,行术前检查,是手术适应症,未见手术禁忌症,于2019年12月13日行单孔胸腔镜下左肺上叶癌根治术(左肺上叶切除淋巴结清扫术),术后行抗感染治疗、祛痰治疗、雾化吸入、维护心功、维护肝功、抑酸治疗、增强机体免疫力等治疗。术后病理未见回报。治疗过程顺利,无并发症或不良反应发生。
|
| 32 |
+
|
| 33 |
+
出院时情况:一般状态良好,神清语明,查体配合。切口愈合良好,无红肿及渗出。已拔除胸引流管。
|
| 34 |
+
|
| 35 |
+
出院医嘱:
|
| 36 |
+
|
| 37 |
+
1. 继续对症治疗
|
| 38 |
+
2. 随诊
|
| 39 |
+
3. 定期复查
|
| 40 |
+
4. 一个月后门诊复查
|
| 41 |
+
|
| 42 |
+
主治医师:
|
| 43 |
+
|
| 44 |
+
2019年12月
|
| 45 |
+
|
| 46 |
+
哈尔滨医科大学附属第三医院 医疗表格统一编号1-02
|
track2_finixphoto_300/mds/0d3c3350-3db0-5dc3-8c69-03a8c4a10185.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 哈尔滨医科大学附属肿瘤医院
|
| 2 |
+
|
| 3 |
+
## (黑龙江省肿瘤医院)
|
| 4 |
+
|
| 5 |
+
# 出院诊断证明书
|
| 6 |
+
|
| 7 |
+
<table><tr><td>姓名:</td><td></td><td>性别:女</td><td>年龄:56岁</td><td>科别:</td><td></td><td>住院号:</td><td></td></tr></table>
|
| 8 |
+
|
| 9 |
+
住 所:
|
| 10 |
+
|
| 11 |
+
诊 断: 右肺癌 右肺门淋巴结转移
|
| 12 |
+
|
| 13 |
+
治疗经过:该患复查胸CT:病灶略缩小;给予版白蛋白结合型紫杉醇联合卡铂方案全身化疗一周期,化后升白对症处置。
|
| 14 |
+
|
| 15 |
+
<table><tr><td>入院日期:</td><td>自</td><td>2019年12月</td><td>起</td></tr><tr><td colspan=4 style="text-align:center">共住院 6 天</td></tr><tr><td>出院日期:</td><td>至</td><td>2019年12月</td><td>止</td></tr></table>
|
| 16 |
+
|
| 17 |
+
治疗结果: 未愈
|
| 18 |
+
|
| 19 |
+
## 出院后注意事项:
|
| 20 |
+
|
| 21 |
+
1. 注意休息,加强营养,预防感染;2. 继续保肝、升白等对症治疗;3. 每3-5天复查血常规、肝肾功,病情变化随诊(白细胞<4.0*10^9/L, 中性粒细胞:<2.0*10^9/L, 血小板<100*10^9/L联系主管医生);4. 定期返院检查及治疗。
|
| 22 |
+
|
| 23 |
+
主任医生:
|
| 24 |
+
2019年12月
|
| 25 |
+
|
| 26 |
+
注:如出院患者需要病历复印件,请到病案室申请办理:
|
| 27 |
+
1. 申请人为患者本人的需提供本人有效身份证明。
|
| 28 |
+
2. 申请人为患者代理人的应提供患者及代理人的有效身份证明。
|
| 29 |
+
|
| 30 |
+
哈尔滨医科大学附属第三医院
|
| 31 |
+
|
| 32 |
+
医疗表格统一编号1-17
|
track2_finixphoto_300/mds/0f1638f7-bfc1-4d10-847a-c335659af13a.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 内蒙古自治区医疗住院收费票据
|
| 2 |
+
|
| 3 |
+
业务流水号:
|
| 4 |
+
|
| 5 |
+
医疗机构:包头市肿瘤医院
|
| 6 |
+
|
| 7 |
+
医保类型:城镇职工
|
| 8 |
+
|
| 9 |
+
住院时间:2021-01-19至2021-02-05
|
| 10 |
+
年 月 日到
|
| 11 |
+
|
| 12 |
+
年 月 日
|
| 13 |
+
|
| 14 |
+
住院天数:7 天
|
| 15 |
+
|
| 16 |
+
住院/病历号:2021011
|
| 17 |
+
|
| 18 |
+
NO. 20021868
|
| 19 |
+
|
| 20 |
+
姓名:
|
| 21 |
+
|
| 22 |
+
性别:男
|
| 23 |
+
|
| 24 |
+
年龄:57
|
| 25 |
+
|
| 26 |
+
社会保障号码:150200D15600
|
| 27 |
+
|
| 28 |
+
<table><tr><td>收费项目</td><td>金额</td><td>收费项目</td><td>金额</td><td>收费项目</td><td>金额</td></tr><tr><td>化验费:</td><td>5,726.00</td><td>药费</td><td>7,198.42</td><td>检查费</td><td>4,541.00</td></tr><tr><td>治疗费</td><td>18,691.27</td><td>手术费</td><td>2,800.00</td><td>输氧费</td><td>451.00</td></tr><tr><td>CT费</td><td>1,880.00</td><td>床位费</td><td>1,060.00</td><td>取暖费</td><td>160.00</td></tr><tr><td>其他费</td><td>120.00</td><td></td><td></td><td></td><td></td></tr></table>
|
| 29 |
+
|
| 30 |
+
合计(大写):肆万贰仟陆佰贰拾柒圆陆角玖分
|
| 31 |
+
|
| 32 |
+
¥:42,627.69
|
| 33 |
+
|
| 34 |
+
预缴金额:37,000.00
|
| 35 |
+
|
| 36 |
+
补缴金额:0.00
|
| 37 |
+
|
| 38 |
+
退费金额:26,994. 52
|
| 39 |
+
|
| 40 |
+
起付钱支付:600.00
|
| 41 |
+
|
| 42 |
+
基金支付:32,622. 21
|
| 43 |
+
|
| 44 |
+
个人账号支付:0.00
|
| 45 |
+
|
| 46 |
+
个人支付金额:10,005.48
|
| 47 |
+
|
| 48 |
+
第一联
|
| 49 |
+
|
| 50 |
+
收款单位(章):
|
| 51 |
+
|
| 52 |
+
收款人:张慧娟
|
| 53 |
+
|
| 54 |
+
日期:2021-2-5 10:45:49
|
track2_finixphoto_300/mds/0ff98c5a-5d36-4bb7-bfa8-aa408d548f21.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 浙江省医疗机构住院收费收据(351)
|
| 2 |
+
|
| 3 |
+
医疗卡号:
|
| 4 |
+
|
| 5 |
+
十六病区
|
| 6 |
+
|
| 7 |
+
№ 1200271258
|
| 8 |
+
|
| 9 |
+
人员类别:
|
| 10 |
+
|
| 11 |
+
自费医保
|
| 12 |
+
|
| 13 |
+
结算日期: 2013年02月23日
|
| 14 |
+
|
| 15 |
+
<table><tr><td colspan="2">姓名:何梓诺</td><td colspan="4">工作单位:无</td></tr><tr><td colspan="2">住院号:00666484</td><td colspan="4">住院日期:2013.02.18-2013.02.23 共5天</td></tr><tr><td>收费项目</td><td>金额</td><td>其中自理自费</td><td colspan="3">结算信息</td></tr><tr><td>西药费</td><td>977.38</td><td>24.94</td><td colspan="2">项目</td><td>金额</td></tr><tr><td>中成药</td><td>24.90</td><td>0.75</td><td colspan="2">现金(支票)</td><td></td></tr><tr><td>中草药</td><td></td><td></td><td colspan="2">本年账户</td><td></td></tr><tr><td>床位费</td><td>200.00</td><td></td><td colspan="2">历年账户</td><td></td></tr><tr><td>诊查费</td><td>30.00</td><td></td><td colspan="2">医保账户</td><td></td></tr><tr><td>检查费</td><td>118.00</td><td>8.00</td><td colspan="2"></td><td></td></tr><tr><td></td><td></td><td></td><td colspan="2"></td><td></td></tr><tr><td></td><td></td><td></td><td colspan="2"></td><td></td></tr><tr><td>检验费</td><td>2,228.00</td><td>309.00</td><td colspan="2">合计</td><td></td></tr><tr><td>治疗费</td><td>629.00</td><td></td><td colspan="3">现金(支票)结算明细</td></tr><tr><td></td><td></td><td></td><td colspan="2">预缴款</td><td>5,000.00</td></tr><tr><td>手术费</td><td></td><td></td><td colspan="2">补缴</td><td></td></tr><tr><td>输血费</td><td></td><td></td><td colspan="2">其中:现金</td><td></td></tr><tr><td>护理费</td><td>52.00</td><td></td><td colspan="2">支票</td><td></td></tr><tr><td>材料费</td><td>82.45</td><td></td><td colspan="2"></td><td></td></tr><tr><td>其他</td><td>3.00</td><td>3.00</td><td colspan="2">退款</td><td>584.67</td></tr><tr><td>输氧费</td><td>4.00</td><td></td><td colspan="2">其中:现金</td><td>584.67</td></tr><tr><td>注射费</td><td>66.60</td><td></td><td colspan="2">支票</td><td></td></tr><tr><td>合计</td><td>4,415.33</td><td>345.69</td><td colspan="2"></td><td></td></tr><tr><td colspan="6">合计金额(大写)肆仟肆佰壹拾伍元叁角叁分</td></tr><tr><td colspan="6">备注:预缴款:373740</td></tr></table>
|
| 16 |
+
|
| 17 |
+
第二联 收据联
|
| 18 |
+
|
| 19 |
+
浙江致用印务中心承印 2012.06*2万份×2联
|
| 20 |
+
|
| 21 |
+
盖章有效 遗失不补
|
| 22 |
+
|
| 23 |
+
领款人(签章):83
|
| 24 |
+
|
| 25 |
+
收银员:83
|
| 26 |
+
|
| 27 |
+
注:本票据限于2014年12月31日前填开使用方为有效。
|
track2_finixphoto_300/mds/1290989e-ba23-46e9-adab-802a00fb3472.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
141436767
|
| 2 |
+
|
| 3 |
+
# 河南省医疗住院收费票据
|
| 4 |
+
|
| 5 |
+
出院全结
|
| 6 |
+
|
| 7 |
+
业务流水号
|
| 8 |
+
|
| 9 |
+
医疗机构类型:
|
| 10 |
+
|
| 11 |
+
住院科室 儿科病区
|
| 12 |
+
|
| 13 |
+
病历号:201744286
|
| 14 |
+
|
| 15 |
+
票据代码:豫财
|
| 16 |
+
|
| 17 |
+
票据标次:MB [2615]
|
| 18 |
+
|
| 19 |
+
住院号:
|
| 20 |
+
|
| 21 |
+
住院时间:2017.10.29 年 月 日到 2017.11.6 年 月 日
|
| 22 |
+
|
| 23 |
+
住院天数:8天
|
| 24 |
+
|
| 25 |
+
NO.1436767
|
| 26 |
+
|
| 27 |
+
姓名:景品之子[新农合]
|
| 28 |
+
|
| 29 |
+
性别:
|
| 30 |
+
|
| 31 |
+
医保类型:
|
| 32 |
+
|
| 33 |
+
社会保障号码:
|
| 34 |
+
|
| 35 |
+
<table><tr><td>收费项目</td><td>金额</td><td>个人支付金额</td><td>收费项目</td><td>金额</td><td>个人支付金额</td><td>收费项目</td><td>金额</td><td>个人支付金额</td><td></td><td></td><td></td></tr><tr><td>西药费</td><td>567.60</td><td></td><td>中成药</td><td></td><td></td><td>中草药</td><td></td><td></td><td>化验费</td><td>665.00</td><td></td></tr><tr><td>检查费</td><td></td><td></td><td>治疗费</td><td>629.72</td><td></td><td>手术费</td><td></td><td></td><td>接生费</td><td></td><td></td></tr><tr><td>材料费</td><td>121.80</td><td></td><td>床位费</td><td>192.00</td><td></td><td>护理费</td><td></td><td></td><td>血费</td><td></td><td></td></tr><tr><td>放射费</td><td>60.00</td><td></td><td>CT费</td><td></td><td></td><td>输氧费</td><td></td><td></td><td>其他费</td><td>16.00</td><td></td></tr></table>
|
| 36 |
+
|
| 37 |
+
2252.21
|
| 38 |
+
|
| 39 |
+
0.00
|
| 40 |
+
|
| 41 |
+
0.00
|
| 42 |
+
|
| 43 |
+
合计(大写) :贰仟贰佰伍拾贰元贰角壹分
|
| 44 |
+
|
| 45 |
+
¥:2252.21
|
| 46 |
+
|
| 47 |
+
预缴金额:3000.00
|
| 48 |
+
|
| 49 |
+
补缴金额:
|
| 50 |
+
|
| 51 |
+
退费金额:747.79
|
| 52 |
+
|
| 53 |
+
起付标准:
|
| 54 |
+
|
| 55 |
+
医保统筹支付:
|
| 56 |
+
|
| 57 |
+
个人账户支付:
|
| 58 |
+
|
| 59 |
+
其他医保支付:
|
| 60 |
+
|
| 61 |
+
个人支付金额:2252.21
|
| 62 |
+
|
| 63 |
+
第一联 收据联 盖章有效 遗失不补
|
| 64 |
+
|
| 65 |
+
收款单位(章):00362350
|
| 66 |
+
|
| 67 |
+
0137
|
| 68 |
+
|
| 69 |
+
收款人(签章):0137
|
| 70 |
+
|
| 71 |
+
2017-11-06 10:29
|
| 72 |
+
|
| 73 |
+
年 月 日
|
| 74 |
+
|
| 75 |
+
结账人签字:
|
track2_finixphoto_300/mds/12adc3bc-a164-4791-94ce-7ecc9845d407.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 福建省肿瘤医院病历记录
|
| 2 |
+
|
| 3 |
+
姓名:
|
| 4 |
+
|
| 5 |
+
病区:
|
| 6 |
+
|
| 7 |
+
床号:
|
| 8 |
+
|
| 9 |
+
住院号:
|
| 10 |
+
|
| 11 |
+
# 出 院 记 录
|
| 12 |
+
|
| 13 |
+
姓名:
|
| 14 |
+
|
| 15 |
+
性别:女
|
| 16 |
+
|
| 17 |
+
年龄:52岁
|
| 18 |
+
|
| 19 |
+
婚姻:离婚
|
| 20 |
+
|
| 21 |
+
职业:个体户
|
| 22 |
+
|
| 23 |
+
入院日期:2019-11
|
| 24 |
+
|
| 25 |
+
出院日期:2019-11
|
| 26 |
+
|
| 27 |
+
共住院: 9 天
|
| 28 |
+
|
| 29 |
+
手术日期:2019-11
|
| 30 |
+
|
| 31 |
+
入院诊断:1. 左乳浸润性癌伴左腋窝左锁骨上淋巴结转移化疗后(cT4N3M0 Ⅲc期);2. 高胆固醇血症;3. PICC置管术后
|
| 32 |
+
|
| 33 |
+
出院诊断:1. 左乳浸润性癌伴左腋窝左锁骨上淋巴结转移化疗后(cT4N3M0 Ⅲc期);2. 高胆固醇血症;3. PICC置管术后
|
| 34 |
+
|
| 35 |
+
住院经过:以"确诊 "左乳癌"6月余,化疗后18天"为主诉入院。入院查体:ECOG1分,神志清楚,营养一般。双锁骨上、腋窝等处浅表淋巴结未触及肿大。双乳发育正常,乳房皮肤未见红、肿及橘皮样改变;右乳头无内陷或朝向改变,挤压无溢液。左乳头内陷,双乳未触及明显肿物。右侧贵要静脉PICC置管通畅,周围皮肤未见红肿及分泌物。心肺查体无异常。腹平软,无压痛、反跳痛,未触及包块,肝、脾肋下未触及。入院前查肺部CT:1、右肺上叶微小结节,建议随访;2、左乳癌伴左侧腋窝淋巴结肿大较前大致相仿,建议结合乳腺相关检查。骨ECT:考虑右肩关节良性病变可能,较2019-5-16旧片81102相仿。入院后查三大常规、生化全套、APTT、PT、乙肝二对半、抗HCV、TP、抗HIV无明显异常;心电图:1、窦性心律;2、大致正常心电图。心超示:1、心脏结构未见明显异常;2、左室舒张功能降低。彩超:1、左乳4点处低回声区(结合临床:倾向乳腺癌治疗中),BI-RADS 6类;2、左腋下组多发淋巴结肿大(结合临床:倾向转移治疗中);3、倾向右乳腺体退化不全,BI-RADS 2类;4、倾向右肝局灶性钙化灶;脂肪肝;5、门脉未见明显占位;6、右腋窝、腹主动脉、下腔静脉及双侧髂血管周围未见明显肿大淋巴结。完善相关检查,未发现明显手术禁忌症,于2019-11-08在全麻下行"左乳腺单纯切除术及左腋窝淋巴结清扫术"。术后予输液、预防性止血、改善皮瓣血运及止痛等治疗。术后恢复好。现患者无明显不适,左胸壁皮瓣紧贴,血运正常,切口愈合好。现予带管出院。
|
| 36 |
+
|
| 37 |
+
出院医嘱:1、门诊定期随访、复查;
|
| 38 |
+
|
| 39 |
+
第 1 页
|
track2_finixphoto_300/mds/12e1b36e-6f63-52e0-9d2c-fb5660dca9a4.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 广东省医疗收费票据
|
| 2 |
+
# Medical Invoice of Guangdong Province
|
| 3 |
+
|
| 4 |
+
1001574156
|
| 5 |
+
|
| 6 |
+
JV07366118
|
| 7 |
+
|
| 8 |
+
业务流水号:
|
| 9 |
+
|
| 10 |
+
社会保障号:
|
| 11 |
+
|
| 12 |
+
病历号:
|
| 13 |
+
|
| 14 |
+
住院(科室):儿童血液肿
|
| 15 |
+
|
| 16 |
+
院号:P519491
|
| 17 |
+
|
| 18 |
+
医院类型:综合医院
|
| 19 |
+
|
| 20 |
+
2016年7月18日
|
| 21 |
+
|
| 22 |
+
<table><tr><td>姓名</td><td colspan="2">陈俊楠</td><td>?门诊 ?急诊 √住院</td><td>住院日期</td><td>2016.7.09</td><td>出院日期</td><td>26.07.18</td></tr><tr><td>性别</td><td>?男 ?女</td><td></td><td>?5238.59</td><td>个人缴费</td><td>?6151.07</td><td>结算方式</td><td>现金</td></tr><tr><td>医药费</td><td>金额</td><td>诊查费</td><td>金额</td><td>治疗费</td><td>金额</td><td>其他</td><td>金额</td></tr><tr><td>西药费</td><td>6203.39</td><td>诊查费</td><td>45.00</td><td>治疗费</td><td>1380.29</td><td>床位费</td><td>892.00</td></tr><tr><td></td><td></td><td>检查费</td><td>100.00</td><td>手术费</td><td>25.00</td><td>护理费</td><td>421.98</td></tr><tr><td></td><td></td><td>检验费</td><td>2175.00</td><td></td><td></td><td>其他</td><td>147.00</td></tr><tr><td>预交款</td><td>6839.12</td><td>补收</td><td>0.00</td><td>退款</td><td>688.05</td><td>欠费</td><td>0.00</td></tr><tr><td colspan="2">合计人民币(大写)</td><td colspan="4">零拾壹万壹仟叁佰捌拾玖元陆角陆分</td><td colspan="2">¥:1389.66</td></tr></table>
|
| 23 |
+
|
| 24 |
+
备注
|
| 25 |
+
|
| 26 |
+
1、药品费包括:西药、中成药及中草药等
|
| 27 |
+
2、诊查费包括:诊金、化验及体检等检查项目
|
| 28 |
+
3、治疗费包括:正骨、敷贴、针灸、推拿、放疗、化疗、手术及材料等
|
| 29 |
+
4、其它费用:床位、护理、药事服务、医学鉴证、司法鉴定等费用
|
| 30 |
+
|
| 31 |
+
市异地医保
|
| 32 |
+
|
| 33 |
+
梅州医保(新异地)
|
| 34 |
+
|
| 35 |
+
第一联 交缴款人(收据联)
|
| 36 |
+
|
| 37 |
+
收费单位(盖章):
|
| 38 |
+
|
| 39 |
+
复核:
|
| 40 |
+
|
| 41 |
+
收款人: HX009
|
| 42 |
+
|
| 43 |
+
广东省财政厅印制
|
| 44 |
+
|
| 45 |
+
(手写无效,限2017年6月30日前使用)
|
track2_finixphoto_300/mds/130a7f45-b7f6-4304-b276-5ebe82f3a1de.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 山东省医疗住院收费票据
|
| 2 |
+
|
| 3 |
+
No. A 4030830035
|
| 4 |
+
|
| 5 |
+
业务流水号:S1009
|
| 6 |
+
|
| 7 |
+
医疗机构类型:
|
| 8 |
+
|
| 9 |
+
病历号:
|
| 10 |
+
|
| 11 |
+
校验码:
|
| 12 |
+
|
| 13 |
+
住院时间:2020年04月02日到2020年05月08日
|
| 14 |
+
|
| 15 |
+
住院天数:36
|
| 16 |
+
|
| 17 |
+
住院号:05842
|
| 18 |
+
|
| 19 |
+
姓名:
|
| 20 |
+
|
| 21 |
+
性别:男
|
| 22 |
+
|
| 23 |
+
医保类型:
|
| 24 |
+
|
| 25 |
+
跨省居民医
|
| 26 |
+
|
| 27 |
+
社会保障号码:
|
| 28 |
+
|
| 29 |
+
<table><tr><td>收费项目</td><td>金额</td><td>个人支付金额</td><td>收费项目</td><td>金额</td><td>个人支付金额</td><td>收费项目</td><td>金额</td><td>个人支付金额</td></tr><tr><td>床位费</td><td>2520.00</td><td>2520.00</td><td>放射费</td><td>1730.00</td><td>1730.00</td><td></td><td></td><td></td></tr><tr><td>西药费</td><td>23637.66</td><td>23637.66</td><td>诊查费</td><td>1008.00</td><td>1008.00</td><td></td><td></td><td></td></tr><tr><td>材料费</td><td>2382.48</td><td>2382.48</td><td>治疗费</td><td>18117.50</td><td>18117.50</td><td></td><td></td><td></td></tr><tr><td>其他费</td><td>956.00</td><td>956.00</td><td>检查费</td><td>4159.50</td><td>4159.50</td><td></td><td></td><td></td></tr><tr><td>化验费</td><td>4652.00</td><td>4652.00</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>护理费</td><td>3362.00</td><td>3362.00</td><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>
|
| 30 |
+
|
| 31 |
+
本次结算总费用:62525.14
|
| 32 |
+
|
| 33 |
+
病人负担:25703.53
|
| 34 |
+
|
| 35 |
+
医保负担:36821.61
|
| 36 |
+
|
| 37 |
+
医疗补助:0
|
| 38 |
+
|
| 39 |
+
医院负担:0
|
| 40 |
+
|
| 41 |
+
个人账户:0
|
| 42 |
+
|
| 43 |
+
统筹支付:32546.54
|
| 44 |
+
|
| 45 |
+
其他统筹支付:4275.07
|
| 46 |
+
|
| 47 |
+
二次报销金额:0
|
| 48 |
+
|
| 49 |
+
大病补助金额:
|
| 50 |
+
|
| 51 |
+
4275.07
|
| 52 |
+
|
| 53 |
+
本次起付线:800
|
| 54 |
+
|
| 55 |
+
省医保账户(亲属):0
|
| 56 |
+
|
| 57 |
+
合计(大写): 陆万贰仟伍佰贰拾伍元壹角肆分
|
| 58 |
+
|
| 59 |
+
¥ 62525.14
|
| 60 |
+
|
| 61 |
+
预缴金额:61000.00
|
| 62 |
+
|
| 63 |
+
补缴金额:0.00
|
| 64 |
+
|
| 65 |
+
退费金额:35296.47
|
| 66 |
+
|
| 67 |
+
医保统筹支付:
|
| 68 |
+
|
| 69 |
+
个人账户支付:
|
| 70 |
+
|
| 71 |
+
其他医保支付:
|
| 72 |
+
|
| 73 |
+
个人支付金额:
|
| 74 |
+
|
| 75 |
+
202印制 2010-11-Y-0034(机打票据 手写无效)
|
| 76 |
+
|
| 77 |
+
第三联 收据 盖章有效 遗失不补
|
| 78 |
+
|
| 79 |
+
收款单位(章):山东大学第二医院
|
| 80 |
+
|
| 81 |
+
收款人(签章):5629
|
| 82 |
+
|
| 83 |
+
2020年05月13日
|
track2_finixphoto_300/mds/13eedc25-e64d-4110-9bd5-e39a8a7508c7.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 重庆市医疗住院收费票据(电子)
|
| 2 |
+
|
| 3 |
+
票据代码:500602
|
| 4 |
+
|
| 5 |
+
票据号码:00127225
|
| 6 |
+
|
| 7 |
+
交款人统一社会信用代码: 51022119600402****
|
| 8 |
+
|
| 9 |
+
校验码:0f9b
|
| 10 |
+
|
| 11 |
+
交款人
|
| 12 |
+
|
| 13 |
+
开票日期:2021-06-01
|
| 14 |
+
|
| 15 |
+
<table><tr><td>项目名称</td><td>金额(元)</td><td>备注</td><td>项目名称</td><td>金额(元)</td><td>备注</td><td>项目名称</td><td>金额(元)</td><td>备注</td></tr><tr><td>床位费</td><td>560.00</td><td></td><td>诊察费</td><td>187.50</td><td></td><td>检查费</td><td>4159.75</td><td></td></tr><tr><td>化验费</td><td>4347.40</td><td></td><td>治疗费</td><td>1746.05</td><td></td><td>手术费</td><td>7112.10</td><td></td></tr><tr><td>护理费</td><td>402.80</td><td></td><td>卫生材料费</td><td>35082.96</td><td></td><td>西药费</td><td>4273.46</td><td></td></tr><tr><td>一般诊疗费</td><td>47.90</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>
|
| 16 |
+
|
| 17 |
+
金额合计(大写)伍万柒仟玖佰壹拾玖元玖角贰分
|
| 18 |
+
|
| 19 |
+
(小写)57919.92
|
| 20 |
+
|
| 21 |
+
其他信息
|
| 22 |
+
|
| 23 |
+
业务流水号:
|
| 24 |
+
|
| 25 |
+
病历号:
|
| 26 |
+
|
| 27 |
+
住院号:
|
| 28 |
+
|
| 29 |
+
住院科别
|
| 30 |
+
|
| 31 |
+
住院时间:20210525
|
| 32 |
+
|
| 33 |
+
预缴金额:55000.00
|
| 34 |
+
|
| 35 |
+
补缴金额:0.00
|
| 36 |
+
|
| 37 |
+
退费金额:4335.17
|
| 38 |
+
|
| 39 |
+
医疗机构类型:三级甲等综合医院
|
| 40 |
+
|
| 41 |
+
医保类型:居民医保
|
| 42 |
+
|
| 43 |
+
医保编号:
|
| 44 |
+
|
| 45 |
+
性别:男
|
| 46 |
+
|
| 47 |
+
医保统筹基金支付
|
| 48 |
+
|
| 49 |
+
其他支付:0.10
|
| 50 |
+
|
| 51 |
+
个人账户支付:0.00
|
| 52 |
+
|
| 53 |
+
个人现金支付:50664.83
|
| 54 |
+
|
| 55 |
+
个人自付:0.00
|
| 56 |
+
|
| 57 |
+
个人自费:50664.83
|
| 58 |
+
|
| 59 |
+
医院垫付:0.10元
|
| 60 |
+
|
| 61 |
+
收款单位(章):重庆医科大学附属第一医院
|
| 62 |
+
|
| 63 |
+
复核人:王琼
|
| 64 |
+
|
| 65 |
+
收款人:王琼
|
track2_finixphoto_300/mds/15fbe32f-5851-45ee-9247-9932d9cda3e2.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 海南省医疗门诊收费票据(电子)
|
| 2 |
+
|
| 3 |
+
票据代码: 460601
|
| 4 |
+
|
| 5 |
+
票据号码:00219142
|
| 6 |
+
|
| 7 |
+
交款人统一社会信用代码: 90080041
|
| 8 |
+
|
| 9 |
+
校验码: 9833
|
| 10 |
+
|
| 11 |
+
交款人:
|
| 12 |
+
|
| 13 |
+
开票日期:2021-05-12
|
| 14 |
+
|
| 15 |
+
<table><tr><td>项目名称</td><td>数量/单位</td><td>金额(元)</td><td>备注</td><td>项目名称</td><td>数量/单位</td><td>金额(元)</td><td>备注</td></tr><tr><td>病理费</td><td>1 元</td><td>418.00</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>病理体视学检查与图象分析(</td><td>1 次</td><td>88.00</td><td></td><td>局部切除组织活检检查与诊</td><td>5 每个</td><td>330.00</td><td></td></tr></table>
|
| 16 |
+
|
| 17 |
+
金额合计(大写)肆佰壹拾捌元整
|
| 18 |
+
|
| 19 |
+
(小写)418.00
|
| 20 |
+
|
| 21 |
+
其他信息
|
| 22 |
+
|
| 23 |
+
业务流水号:0502104
|
| 24 |
+
|
| 25 |
+
门诊号:900800
|
| 26 |
+
|
| 27 |
+
就诊日期:20210512
|
| 28 |
+
|
| 29 |
+
医疗机构类型:综合性医院
|
| 30 |
+
|
| 31 |
+
医保类型:自费
|
| 32 |
+
|
| 33 |
+
医保编号:
|
| 34 |
+
|
| 35 |
+
性别:女
|
| 36 |
+
|
| 37 |
+
医保统筹基金支付:0.00
|
| 38 |
+
|
| 39 |
+
其他支付:0.00
|
| 40 |
+
|
| 41 |
+
个人账户支付:0.00
|
| 42 |
+
|
| 43 |
+
个人现金支付:418.00
|
| 44 |
+
|
| 45 |
+
个人自付:
|
| 46 |
+
|
| 47 |
+
个人自费:
|
| 48 |
+
|
| 49 |
+
050210416174
|
| 50 |
+
|
| 51 |
+
收款单位(章):海南医学院第一附属医院
|
| 52 |
+
|
| 53 |
+
复核人:郑丹丹
|
| 54 |
+
|
| 55 |
+
收款人:郑丹丹
|
track2_finixphoto_300/mds/16cd5c50-5086-5fbe-a1a6-7e7be304140a.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 四川增值税专用发票
|
| 2 |
+
|
| 3 |
+
5100191160
|
| 4 |
+
|
| 5 |
+
NO 22222222
|
| 6 |
+
|
| 7 |
+
5100191160
|
| 8 |
+
|
| 9 |
+
22222222
|
| 10 |
+
|
| 11 |
+
开票日期:2019年2月21日
|
| 12 |
+
|
| 13 |
+
<table><tr><td>购买方</td><td><b>名称:</b>小艾财税咨询有限公司<br><b>纳税人识别号:</b>2222222222222222<br><b>地址、电话:</b><br><b>开户行及账号:</b></td><td>销售方</td><td><b>名称:</b>***<br><b>纳税人识别号:</b>222-40+0/034x0*200+855+353*5+<-5414/813025*+<5-23-4259-51-9/621222/3946/6130/21085062*+016921198+6534/222<br><b>地址、电话:</b><br><b>开户行及账号:</b></td></tr><tr><td colspan=2>货物或应税劳务、服务名称</td><td>规格型号</td><td>单位</td><td>数量</td><td>单价</td><td>金额</td><td>税率</td><td>税额</td></tr><tr><td colspan=2>*运输服务*公路运输服务</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td colspan=5>合计</td><td></td><td></td><td></td></tr><tr><td colspan=5>价税合计(大写)</td><td colspan=4>(小写)</td></tr></table>
|
| 14 |
+
|
| 15 |
+
<table><tr><td>销售方</td><td><b>名称:</b>***有限公司<br><b>纳税人识别号:</b>915000000000000000<br><b>地址、电话:</b>四川省成都市***028-22222222<br><b>开户行及账号:</b>工行***支行 222222222222222</td><td>备注</td><td><b>起运地:</b>成都,到达地:西安<br><b>货物:</b>实木桌椅<br><b>车种:</b>东风一吨轻型厢式货车<br><b>车号:</b>川A 8G222</td></tr><tr><td colspan=2>收款人:小李</td><td colspan=2>复核:小艾</td><td colspan=2>开票人:小王</td><td colspan=2>销售方:(章)</td></tr></table>
|
track2_finixphoto_300/mds/1721a339-a34a-4f54-bc61-3c4ec1dcf09d.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 明市儿童医院出院记录
|
| 2 |
+
|
| 3 |
+
姓名:
|
| 4 |
+
|
| 5 |
+
号:902180
|
| 6 |
+
|
| 7 |
+
性别:女
|
| 8 |
+
|
| 9 |
+
床号:08
|
| 10 |
+
|
| 11 |
+
转归:治
|
| 12 |
+
|
| 13 |
+
天
|
| 14 |
+
|
| 15 |
+
入院科室:烧(创)伤整形外科病区
|
| 16 |
+
|
| 17 |
+
入院时间:2020年10月25日18时56分
|
| 18 |
+
|
| 19 |
+
出院科室:烧(创)伤整形外科病区
|
| 20 |
+
|
| 21 |
+
出院时间:2020年11月11日10时12分
|
| 22 |
+
|
| 23 |
+
入院诊断:
|
| 24 |
+
1. 猴咬伤致面部皮肤裂伤, 2. 面部皮肤裂伤清创缝合术后伤口感染, 3. 面部皮肤瘢痕形成
|
| 25 |
+
|
| 26 |
+
出院诊断:
|
| 27 |
+
1. 右面部创伤后皮肤感染性窦道。2. 猴咬伤右面部清创缝合术后伴感染。3. 皮肤和皮下组织的局部感染。
|
| 28 |
+
|
| 29 |
+
患者入院情况:患儿因“不慎被野生猴子咬伤面部清创缝合术后8日余”于2020-10-25 18:56入院。查体:体温36.5℃,心率104次/分,呼吸22次/分,体重20.5kg,疼痛评分2分,营养评估风险评分2分,压疮风险评分23分,跌倒风险评分10分。神志清楚,未见三凹征,全身皮肤黏膜无黄染点;头颅外形正常,巩膜无黄染,双侧瞳孔等大等圆,对光反射存在;双肺呼吸音清,未闻及干湿性啰音;心音有力,律齐,各瓣膜听诊区未闻及病理性杂音;腹平软,无压痛及反跳痛肌紧张,肝脾肋下未触及,肠鸣音正常,4次/分;脊柱四肢外形正常,肌力肌张力正常,各关节活动正常,生理反射存在,病理反射未引出,肢端暖,未见花斑;
|
| 30 |
+
|
| 31 |
+
患者住院经过(治疗方案、患者病情变化、并发症):患儿因“不慎被野生猴子咬伤面部"于2020-10-25 18:56入院,入院后予完善相关检查,静脉予甲硝唑抗炎、破伤风抗毒素肌注,止血药物静滴抑制出血,急诊送手术室颜面清创、面部引流术,面部外伤扩创清缝合术,脓腔隧道去除,创面负压封闭引流术”,皮下空腔予三明治贯浇,负压封闭缩小皮下空腔,定期换药治疗,后创面基底空腔缩窄,并于2020-11-09因在麻醉下行“面部残余创面扩创清创缝合术+任意皮瓣形成覆盖术”,术后第2天,伤口换药见术区愈合固定,对合良好,未见明显异常渗出。患儿术后病情平稳,予以拆线、换药、今日患儿一般情况好,嘱出院后继续门诊换药,术后5-7天返院拆线。愈合后早期瘢痕防治及防晒。
|
| 32 |
+
|
| 33 |
+
重要检查检验及结果:2020-10-27,分泌物培养(用无菌干棉签取样)(样本:分泌物),嗜血杆菌培养 未分离到嗜血杆菌属细菌,一般细菌培养 2天培养无生长;
|
| 34 |
+
|
| 35 |
+
患者出院时情况:缝合术后第2天,今日换药见术区缝合固定,对合良好,未见明显渗出,原创口延期缝合处轻度瘢痕形成。今日出院,嘱出院后继续门诊换药,术后5-7天拆线,愈合后早期瘢痕防治及防晒。
|
| 36 |
+
|
| 37 |
+
出院医嘱(包括出院带药、植入物、交通工具等):
|
| 38 |
+
1、门诊随诊,如有不适,随时就诊。出院后继续门诊换药,术后5-7天返院拆线。愈合后早期瘢痕防治及防晒。
|
| 39 |
+
2、出院带药:无,无植入物。
|
| 40 |
+
3、交通工具:自行。
|
track2_finixphoto_300/mds/17431f4c-4db9-4ced-bee1-e8c24d8df3e1.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ID:80012336
|
| 2 |
+
|
| 3 |
+
# 中国人民解放军医疗门诊收费票据
|
| 4 |
+
|
| 5 |
+
80012336
|
| 6 |
+
|
| 7 |
+
票控盘号:0010003693
|
| 8 |
+
|
| 9 |
+
票控码:001000369339-1698893
|
| 10 |
+
|
| 11 |
+
(2019):1901135782
|
| 12 |
+
|
| 13 |
+
业务流水号 B403700
|
| 14 |
+
|
| 15 |
+
医疗机构类型:大型综合医院
|
| 16 |
+
|
| 17 |
+
机打票号:1901135782
|
| 18 |
+
|
| 19 |
+
姓名:
|
| 20 |
+
|
| 21 |
+
性别:女
|
| 22 |
+
|
| 23 |
+
医保类型:
|
| 24 |
+
|
| 25 |
+
社会保障号码:
|
| 26 |
+
|
| 27 |
+
<table><tr><td>项目/规格</td><td>数量</td><td>金额</td><td>个人支付金额</td><td>项目/规格</td><td>数量</td><td>金额</td><td>个人支付金额</td></tr><tr><td>APTT活化部分凝血活酶时间(8.8)</td><td>1项</td><td>18.8</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>乙型肝炎表面抗体测定(定量)</td><td>1项</td><td>24.4</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>血浆凝血酶原时间(PT)测定(全自动仪)</td><td>1项</td><td>18.8</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>凝血酶时间TT测定(全自动仪)8.8</td><td>1项</td><td>18.8</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>乙型肝炎e抗原测定(定量)</td><td>1项</td><td>24.4</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>血浆纤维蛋白原测定(仪器法)11</td><td>1项</td><td>19</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>乙型肝炎e抗体测定(定量)</td><td>1项</td><td>24.4</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>乙型肝炎核心抗体测定(定量)</td><td>1项</td><td>24.4</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>乙型肝炎表面抗原测定(定量)</td><td>1项</td><td>24.4</td><td></td><td></td><td></td><td></td><td></td></tr></table>
|
| 28 |
+
|
| 29 |
+
合计(大写):壹佰玖拾柒元肆角整
|
| 30 |
+
|
| 31 |
+
¥:197.40
|
| 32 |
+
|
| 33 |
+
医保统筹支付:
|
| 34 |
+
|
| 35 |
+
个人账户支付:
|
| 36 |
+
|
| 37 |
+
其他医保支付:现金:197.40
|
| 38 |
+
|
| 39 |
+
个人支付金额:
|
| 40 |
+
|
| 41 |
+
2020/05/06
|
| 42 |
+
|
| 43 |
+
缴费日期:2020-05-06
|
| 44 |
+
|
| 45 |
+
第一联 收据联 盖章有效 遗失不补 手写无效
|
| 46 |
+
|
| 47 |
+
二零二零年六月底前有效
|
| 48 |
+
|
| 49 |
+
收款单位(盖章):
|
| 50 |
+
|
| 51 |
+
收款人(签章):2964(132)
|
| 52 |
+
|
| 53 |
+
年 月 日
|
track2_finixphoto_300/mds/1833ad18-dc1d-486b-8c59-7e9b89eb56f1.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 福建省肿瘤医院病历记录
|
| 2 |
+
|
| 3 |
+
姓名:
|
| 4 |
+
|
| 5 |
+
病区:
|
| 6 |
+
|
| 7 |
+
床号:
|
| 8 |
+
|
| 9 |
+
住院号:
|
| 10 |
+
|
| 11 |
+
# 出院记录
|
| 12 |
+
|
| 13 |
+
姓名:
|
| 14 |
+
|
| 15 |
+
性别:女
|
| 16 |
+
|
| 17 |
+
年龄:52岁
|
| 18 |
+
|
| 19 |
+
婚姻:离婚
|
| 20 |
+
|
| 21 |
+
职业:个体户
|
| 22 |
+
|
| 23 |
+
入院日期:2019-09
|
| 24 |
+
|
| 25 |
+
出院日期:2019-09
|
| 26 |
+
|
| 27 |
+
共住院: 11 天
|
| 28 |
+
|
| 29 |
+
入院诊断:1.左乳浸润性癌伴左腋窝左锁骨上淋巴结转移化疗后(cT4N3Mc0 Ⅲc期);2.高胆固醇血症;3.PICC置管术后
|
| 30 |
+
|
| 31 |
+
出院诊断:1.左乳浸润性癌伴左腋窝左锁骨上淋巴结转移化疗后(cT4N3M0 Ⅲc期);2.高胆固醇血症;3.PICC置管术后
|
| 32 |
+
|
| 33 |
+
住院经过:患者 ,女,52岁,汉族,离婚,以确诊"左乳癌"5个月,化疗后7天为主诉入院。患者于2019.4月中旬无意中发现左乳中央区可扪及一肿物,大小约8.0*7.0cm,质地硬,边界欠清,活动度尚可,表面欠光滑,无触痛,表面皮肤呈橘皮样,左乳头内陷。就诊我院,门诊行乳腺钼靶:左乳团块影并左腋窝淋巴结肿大,考虑恶性可能,建议穿刺活检 BI-RADS:4B类。彩超:1、左乳多发实性占位(倾向乳腺癌),BI-RADS 5类;2、左腋中、腋下组多发淋巴结肿大(倾向转移)。肺部CT:1、左乳占位、左乳皮肤增厚伴左侧腋窝淋巴结肿大,建议结合乳腺相关检查;3、左侧胸壁皮下小结节。彩超引导下行左乳肿物+左腋窝及左锁骨上淋巴结穿刺活检术,2019.4.10穿刺病理回报(19-07275):(左乳房,穿刺)浸润性癌,(左腋窝淋巴结,穿刺)转移性癌。(左锁骨上淋巴结,穿刺)转移性癌。IHC:ER(+)(60%,中等-强),PR(+)(5%,弱-中等),HER2(1+),Ki-67(+,约20%),P63示肌上皮缺失。MRI:1、符合左乳腺癌累及皮肤伴左侧腋窝多发淋巴结肿大 BI-RADS:6类 2、右乳 BI-RADS:1类。ECT:考虑右肩关节良性病变可能。排除治疗禁忌症,于2019.4.30-8.20以"紫杉醇126m qw*14+表柔比星120mg*5"化疗,过程顺利,化疗间歇期给予粒细胞因子预防升白。2、4疗程后门诊查CT、MR提示疗效好转。入院查体:神志清楚,营养一般。左腋窝可扪及一肿大淋巴结,大小约0.5*0.5cm,质地硬,边界欠清,活动度尚可,表面欠光滑,无触痛。双锁骨上、右腋窝等处浅表淋巴结未触及肿大。双乳发育正常,左乳头内陷,无溢液。左乳中央区可扪及一肿物,大小约2.5*1.5cm,质地硬,边界欠清,活动度尚可,表面欠光滑,无触痛,表面皮肤呈橘皮
|
| 34 |
+
|
| 35 |
+
第 1 页
|
track2_finixphoto_300/mds/19b3a90a-8cb6-40c6-b30e-40860f27c8b8.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 中国人民解放军医疗住院收费票据
|
| 2 |
+
|
| 3 |
+
票控盘号: 001010005002
|
| 4 |
+
|
| 5 |
+
票控码:001010005002-08007330260337782454
|
| 6 |
+
|
| 7 |
+
(2020):201100673748
|
| 8 |
+
|
| 9 |
+
业务流水号:87096819
|
| 10 |
+
|
| 11 |
+
医疗机构类型: 综台医院
|
| 12 |
+
|
| 13 |
+
病历号:07055179
|
| 14 |
+
|
| 15 |
+
机打票号:201100673748
|
| 16 |
+
|
| 17 |
+
住院时间: 2021年05月13日至 2021年05月26日
|
| 18 |
+
|
| 19 |
+
住院天数: 13
|
| 20 |
+
|
| 21 |
+
住院号 :220194
|
| 22 |
+
|
| 23 |
+
姓名: 林作岭
|
| 24 |
+
|
| 25 |
+
性别:男
|
| 26 |
+
|
| 27 |
+
社会保障号码:
|
| 28 |
+
|
| 29 |
+
<table><tr><td>收费项目</td><td>金额</td><td>个人支付金额</td><td>收费项目</td><td></td><td>金额</td></tr><tr><td>西药费</td><td>9062.80</td><td>\</td><td>检查费</td><td>1743.00</td><td>\</td></tr><tr><td>手术费</td><td>60.00</td><td>\</td><td>化验费</td><td>1529.00</td><td>\</td></tr><tr><td>放射费</td><td>645.00</td><td>\</td><td>护理费</td><td>1329.82</td><td>\</td></tr><tr><td>诊察费</td><td>337.00</td><td>\</td><td>治疗费</td><td>5436.42</td><td>\</td></tr><tr><td>床位费</td><td>455.00</td><td>\</td><td>其他</td><td>2421.20</td><td>\</td></tr></table>
|
| 30 |
+
|
| 31 |
+
合计(大写): 贰万叁仟零壹拾玖元贰角肆分
|
| 32 |
+
|
| 33 |
+
¥:23019.24
|
| 34 |
+
|
| 35 |
+
预缴金额: 22000.00
|
| 36 |
+
|
| 37 |
+
补缴金额:0
|
| 38 |
+
|
| 39 |
+
退费金额: 12614.39
|
| 40 |
+
|
| 41 |
+
医保统筹支付: 13633.63
|
| 42 |
+
|
| 43 |
+
个人账户支付:0
|
| 44 |
+
|
| 45 |
+
其他医保支付:0
|
| 46 |
+
|
| 47 |
+
个人支付金额:9385.61
|
| 48 |
+
|
| 49 |
+
第一联 收据联 盖章有效 遗失不补 手写无效
|
| 50 |
+
二零二一年六月底前有效
|
| 51 |
+
|
| 52 |
+
收款单位(盖章):
|
| 53 |
+
|
| 54 |
+
收款人(签章):1261
|
| 55 |
+
|
| 56 |
+
2021年5月26日
|
| 57 |
+
|
| 58 |
+
医保住院号:YD002864836,医保单据号:YD004921560,医保个人帐户余额:0
|
track2_finixphoto_300/mds/19bccfb7-9af9-48f7-b0c6-a559afcf80d8.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 河北省医疗住院收费票据
|
| 2 |
+
|
| 3 |
+
医疗机构:廊坊市中医医院
|
| 4 |
+
|
| 5 |
+
类型:
|
| 6 |
+
|
| 7 |
+
科室:
|
| 8 |
+
|
| 9 |
+
流水号:
|
| 10 |
+
|
| 11 |
+
005208181
|
| 12 |
+
|
| 13 |
+
住院号:
|
| 14 |
+
|
| 15 |
+
住院时间:2020 年 06 月 30 日到 2020 年 07 月 16 日
|
| 16 |
+
|
| 17 |
+
住院天数:16
|
| 18 |
+
|
| 19 |
+
姓名:
|
| 20 |
+
|
| 21 |
+
性别:男
|
| 22 |
+
|
| 23 |
+
医保类型: 居民医保
|
| 24 |
+
|
| 25 |
+
社会保障号码:
|
| 26 |
+
|
| 27 |
+
<table><tr><td>收费项目</td><td>金额</td><td>支付类型</td><td>收费项目</td><td>金额</td><td>支付类型</td></tr><tr><td>床位费</td><td>720.00</td><td></td><td>护理费</td><td>288.00</td><td></td></tr><tr><td>检查费</td><td>3144.00</td><td></td><td>卫生材料费</td><td>51562.21</td><td></td></tr><tr><td>化验费</td><td>1952.70</td><td></td><td>药品费</td><td>13206.70</td><td></td></tr><tr><td>治疗费</td><td>1858.40</td><td></td><td>诊察费</td><td>320.00</td><td></td></tr><tr><td>手术费</td><td>5516.00</td><td></td><td>其他</td><td>12.00</td><td></td></tr><tr><td>输血费</td><td>500.00</td><td></td><td></td><td></td><td></td></tr></table>
|
| 28 |
+
|
| 29 |
+
合计(大写):柒万玖仟零捌拾元零壹分
|
| 30 |
+
|
| 31 |
+
¥:79080.01
|
| 32 |
+
|
| 33 |
+
预缴金额:80000.00
|
| 34 |
+
|
| 35 |
+
补缴金额:0
|
| 36 |
+
|
| 37 |
+
退费金额: 31143.15
|
| 38 |
+
|
| 39 |
+
医院垫支: 30223.16
|
| 40 |
+
|
| 41 |
+
医保统筹支付:25948.48
|
| 42 |
+
|
| 43 |
+
个人账户支付: 0.00
|
| 44 |
+
|
| 45 |
+
个人自付: 13724.31
|
| 46 |
+
|
| 47 |
+
个人自费: 34822.54
|
| 48 |
+
|
| 49 |
+
个人账户余额:80.00
|
| 50 |
+
|
| 51 |
+
统筹累计支付:4623.71
|
| 52 |
+
|
| 53 |
+
大病统筹4274.68
|
| 54 |
+
|
| 55 |
+
贫困救助:0.00
|
| 56 |
+
|
| 57 |
+
个人现金支付:48856.85
|
| 58 |
+
|
| 59 |
+
起付标准:700.00
|
| 60 |
+
|
| 61 |
+
纳入报销费用:43247.47
|
| 62 |
+
|
| 63 |
+
符合医疗保险费用:43947.47
|
| 64 |
+
|
| 65 |
+
结算前余额80.00
|
| 66 |
+
|
| 67 |
+
第一联 收据联 盖章有效 遗失不补
|
| 68 |
+
|
| 69 |
+
收款单位(章):
|
| 70 |
+
|
| 71 |
+
收款人:072019
|
| 72 |
+
|
| 73 |
+
2020 年 07 月 23 日
|
track2_finixphoto_300/mds/1a8ba629-13ba-4b18-bcc7-4eeb2b0866f3.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
莲湖区
|
| 2 |
+
|
| 3 |
+
0003391295
|
| 4 |
+
|
| 5 |
+
住院号:0871058
|
| 6 |
+
|
| 7 |
+
NO.2100
|
| 8 |
+
|
| 9 |
+
2100729077
|
| 10 |
+
|
| 11 |
+
住院时间 2021年08月17日到2021年08月21日
|
| 12 |
+
|
| 13 |
+
共计4天
|
| 14 |
+
|
| 15 |
+
性别 女
|
| 16 |
+
|
| 17 |
+
医保类型:市居民
|
| 18 |
+
|
| 19 |
+
社会保障号码:
|
| 20 |
+
|
| 21 |
+
<table><tr><td>收费项目</td><td>金额</td><td>个人支付金额</td><td></td><td></td><td></td></tr><tr><td>床位费</td><td>620</td><td></td><td>护理费</td><td>80</td><td></td></tr><tr><td>化验费</td><td>930</td><td></td><td>检查费</td><td>1555</td><td></td></tr><tr><td>其他</td><td></td><td></td><td>手术费</td><td></td><td></td></tr><tr><td>特殊材料</td><td></td><td></td><td>西药费</td><td>550177.2</td><td></td></tr><tr><td>血费</td><td></td><td></td><td>诊查费</td><td>120</td><td></td></tr><tr><td>治疗费</td><td>157</td><td></td><td>中草药</td><td></td><td></td></tr><tr><td>中成药</td><td></td><td></td><td></td><td></td><td></td></tr></table>
|
| 22 |
+
|
| 23 |
+
2021-08-24 09:54:59
|
| 24 |
+
|
| 25 |
+
合计(大写):伍拾伍万叁仟陆佰叁拾玖元贰角
|
| 26 |
+
|
| 27 |
+
553639.2
|
| 28 |
+
|
| 29 |
+
555000.00
|
| 30 |
+
|
| 31 |
+
银行卡(建行):
|
| 32 |
+
|
| 33 |
+
医保统筹支付 570.25
|
| 34 |
+
|
| 35 |
+
个人账户支付 0
|
| 36 |
+
|
| 37 |
+
其他医保支付
|
| 38 |
+
|
| 39 |
+
个人支付金额 553068.95
|
| 40 |
+
|
| 41 |
+
第一联 收据联 盖章有效 遗失不补
|
| 42 |
+
|
| 43 |
+
收款单位(章)
|
| 44 |
+
|
| 45 |
+
收款人(签章) 陈建鹏
|
| 46 |
+
|
| 47 |
+
2021年08月24日
|
track2_finixphoto_300/mds/1a9f3b5a-8234-430a-a723-ea082ecb77ee.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 齐齐哈尔医学院附属第一医院
|
| 2 |
+
|
| 3 |
+
# 出院记录
|
| 4 |
+
|
| 5 |
+
姓名:
|
| 6 |
+
|
| 7 |
+
性别:男
|
| 8 |
+
|
| 9 |
+
科别:
|
| 10 |
+
|
| 11 |
+
床号:
|
| 12 |
+
|
| 13 |
+
病案号:
|
| 14 |
+
|
| 15 |
+
姓名:
|
| 16 |
+
|
| 17 |
+
性别:男
|
| 18 |
+
|
| 19 |
+
年龄:47岁
|
| 20 |
+
|
| 21 |
+
入院时间:2019-11
|
| 22 |
+
|
| 23 |
+
出院时间; 2019-12
|
| 24 |
+
|
| 25 |
+
住院天数:56天
|
| 26 |
+
|
| 27 |
+
入院科别:
|
| 28 |
+
|
| 29 |
+
出院科别:
|
| 30 |
+
|
| 31 |
+
第1次住院
|
| 32 |
+
|
| 33 |
+
门诊收治诊断:脑血栓形成
|
| 34 |
+
|
| 35 |
+
临床初步诊断:脑血栓形成
|
| 36 |
+
|
| 37 |
+
临床确定诊断:急性呼吸衰竭(中枢性),脑血栓形成,坠积性肺炎,心肌损害,泌尿系统感染
|
| 38 |
+
入院时情况:患者,男,47岁,退(离)休人员。因“头痛、恶心吐,左侧肢体活动不灵2小时”于2019-11入院。该患于入院前2小时无明显诱因突然出现头痛,恶心呕吐,左侧肢体活动不灵症状,左上肢抬举差,左手抓握力弱,左下肢抬举尚可,但不能行走。在明珠医院行头CT检查未见明显异常,为求系统诊治在家属陪同下来我院急诊检查,急诊以“脑梗死”收入院。病程中无肢体抽搐,无视物旋转,无二便失禁,精神状态欠佳,饮食、睡眠一般。查体:体温:36.7℃,脉搏:72次/分,呼吸:20次/分,血压:140/90mmHg。发育正常,营养中等,推入病房,自主体位,查体合作,心肺腹检查未及明显异常。专科检查:意识清晰,言语流利,反应灵敏,计算力正常,定向力正常,近记忆正常,眼球各方向,活动良好,双侧瞳孔等大同圆,直径3.0mm,对光反射灵敏,无面舌瘫,左上肢肌力4级、下肢肌力4+级,右侧肢体肌力5级,四肢肌张力、腱反射正常,感觉系统未及异常,共济运动不能完成,双侧病理征阴性,颈强阴性,克氏征阴性。辅助检查:头MRI(2019.11.05):双侧小脑急性期脑梗死。
|
| 39 |
+
|
| 40 |
+
治疗经过:入院后明确诊断后给予介入取栓治疗,病人基底动脉供血区域脑组织缺血坏死,脑组织肿胀明显,给予脑室钻孔引流+后颅窝去骨瓣减压手术,病情稳定后返回病房继续脱水、降颅压、醒脑,控制并发症治疗。
|
| 41 |
+
|
| 42 |
+
出院时情况:患者处于昏迷状态,痰减少,仍然比较粘稠,发热。年底医保资金结算,要求办理出院,重新办理住院,继续治疗。
|
| 43 |
+
|
| 44 |
+
治疗效果(转归): 好转
|
| 45 |
+
|
| 46 |
+
出院医嘱:重新办理住院,继续治疗。
|
| 47 |
+
|
| 48 |
+
主治医师签名:
|
| 49 |
+
|
| 50 |
+
住院医师签名:
|
| 51 |
+
|
| 52 |
+
注:医师签字前添加职称,右侧由经治医师签名,左侧由上级医师签名。
|
| 53 |
+
|
| 54 |
+
医疗表格统一编号1-2
|
| 55 |
+
|
| 56 |
+
第 页
|
track2_finixphoto_300/mds/1b6fdf72-97d5-4435-a9f3-1152d426aad0.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
哈爾濱醫科大學附属第二医院
|
| 2 |
+
|
| 3 |
+
The 2nd Affiliated Hospital of Harbin Medical University
|
| 4 |
+
|
| 5 |
+
# 出院记录
|
| 6 |
+
|
| 7 |
+
姓名:
|
| 8 |
+
|
| 9 |
+
科室:
|
| 10 |
+
|
| 11 |
+
病案号:
|
| 12 |
+
|
| 13 |
+
姓名:
|
| 14 |
+
|
| 15 |
+
性别:女
|
| 16 |
+
|
| 17 |
+
年龄:36岁
|
| 18 |
+
|
| 19 |
+
入院次数:1
|
| 20 |
+
|
| 21 |
+
入院科别:
|
| 22 |
+
|
| 23 |
+
出院科别:
|
| 24 |
+
|
| 25 |
+
入院日期: 2019年12月
|
| 26 |
+
|
| 27 |
+
出院日期:2019年12月
|
| 28 |
+
|
| 29 |
+
住院天数:7天
|
| 30 |
+
|
| 31 |
+
门诊诊断:子宫平滑肌瘤
|
| 32 |
+
|
| 33 |
+
初步诊断:子宫平滑肌瘤
|
| 34 |
+
|
| 35 |
+
确定诊断:子宫平滑肌瘤 盆腔粘连
|
| 36 |
+
|
| 37 |
+
入院时情况:因“经期延长伴经量减少半年余。”入院。
|
| 38 |
+
|
| 39 |
+
治疗经过:完善相关检查,于2019年12月11日行子宫肌瘤核除术+子宫整形术+盆腔粘连松解术+腹腔引流术+瘢痕剔除术,术后抗炎对症治疗。
|
| 40 |
+
|
| 41 |
+
出院情况: 患者一般状态良好, 无发热, 无呕心呕吐, 生命体征平稳, 查体: T:36.8℃, P:76次/分, R:18次/分, Bp:122/78mmHg,一般情况可, 神清语明, 颈软, 心肺无著征, 腹平软, 无压痛, 肝脾肋下未触及,双下肢无浮肿, 神经系统未见异常, 病理反射未引出, 腹部切口愈合良好, 二便未见明显异常。
|
| 42 |
+
|
| 43 |
+
治疗效果(转归):治愈
|
| 44 |
+
|
| 45 |
+
出院医嘱:1、加强营养,注意休息1个月;
|
| 46 |
+
2、禁盆浴及性生活1个月;
|
| 47 |
+
3、建议避孕至少1年;
|
| 48 |
+
4、出院3周后电话咨询病理结果;
|
| 49 |
+
5、定期复查,不适随诊。
|
| 50 |
+
|
| 51 |
+
2
|
| 52 |
+
|
| 53 |
+
第1页
|
| 54 |
+
|
| 55 |
+
医疗表格统一编号 1-02
|
track2_finixphoto_300/mds/1f61fb07-32c0-4a57-a725-458ef0d0d3f9.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 湖南省医疗住院收费票据
|
| 2 |
+
|
| 3 |
+
№ 0130707478
|
| 4 |
+
|
| 5 |
+
湘财
|
| 6 |
+
通字
|
| 7 |
+
|
| 8 |
+
(2016)
|
| 9 |
+
|
| 10 |
+
013070747
|
| 11 |
+
|
| 12 |
+
业务流水号: LJ030342
|
| 13 |
+
|
| 14 |
+
医疗机构类型: 综合医院
|
| 15 |
+
|
| 16 |
+
病历号:1261465
|
| 17 |
+
|
| 18 |
+
住院号: 0004567727
|
| 19 |
+
|
| 20 |
+
住院时间: 2016年12月27日到2017年01月10日
|
| 21 |
+
|
| 22 |
+
住院天数:14
|
| 23 |
+
|
| 24 |
+
25病区(肾内科)
|
| 25 |
+
|
| 26 |
+
姓名: 卢微
|
| 27 |
+
|
| 28 |
+
性别: 女
|
| 29 |
+
|
| 30 |
+
医保类型: 宁乡县居民
|
| 31 |
+
|
| 32 |
+
社会保障号码: 124350712002806
|
| 33 |
+
|
| 34 |
+
<table><tr><td>收费项目</td><td>金额</td><td>个人支付金额</td><td>收费项目</td><td>金额</td><td>个人支付金额</td><td>收费项目</td><td>金额</td><td>个人支付金额</td></tr><tr><td>床位费</td><td>850.00</td><td></td><td>手术费</td><td>800.10</td><td></td><td>输血费</td><td>540.00</td><td></td></tr><tr><td>诊查费</td><td>390.00</td><td></td><td>护理费</td><td>469.00</td><td></td><td>其它</td><td>165.28</td><td></td></tr><tr><td>检查费</td><td>3282.00</td><td></td><td>材料费</td><td>6763.52</td><td></td><td></td><td></td><td></td></tr><tr><td>化验费</td><td>4396.50</td><td></td><td>西药费</td><td>7032.25</td><td></td><td></td><td></td><td></td></tr><tr><td>治疗费</td><td>11752.07</td><td></td><td>中成药费</td><td>640.55</td><td></td><td></td><td></td><td></td></tr></table>
|
| 35 |
+
|
| 36 |
+
合计(大写)叁万柒仟零捌拾壹元贰角柒分
|
| 37 |
+
|
| 38 |
+
¥ 37081.27
|
| 39 |
+
|
| 40 |
+
预缴金额:85561.67
|
| 41 |
+
|
| 42 |
+
补缴金额:
|
| 43 |
+
|
| 44 |
+
退费金额:34000.00/29243.60
|
| 45 |
+
|
| 46 |
+
医保统筹支付:14763.20
|
| 47 |
+
|
| 48 |
+
个人账户支付:
|
| 49 |
+
|
| 50 |
+
其他医保支付:
|
| 51 |
+
|
| 52 |
+
个人支付金额:22318.07
|
| 53 |
+
|
| 54 |
+
第一联 收据联 盖章有效 遗失不补
|
| 55 |
+
|
| 56 |
+
本票据使用至2018年底,过期作废
|
| 57 |
+
|
| 58 |
+
湘非税 1538号 湖南人民印务印
|
| 59 |
+
|
| 60 |
+
收款单位(章):
|
| 61 |
+
|
| 62 |
+
收款人(签章): 4995
|
| 63 |
+
|
| 64 |
+
2017年1月12日
|
track2_finixphoto_300/mds/208198de-2044-50ca-8f1b-d3a7b588b352.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
知乎@ZHDD
|
| 2 |
+
|
| 3 |
+
# 广东省医疗收费票据
|
| 4 |
+
# Medical Invoice of Guangdong Province
|
| 5 |
+
|
| 6 |
+
LB1
|
| 7 |
+
|
| 8 |
+
业务流水号:
|
| 9 |
+
Serial number
|
| 10 |
+
|
| 11 |
+
社会保障号:
|
| 12 |
+
Social security number
|
| 13 |
+
|
| 14 |
+
病历号:
|
| 15 |
+
ID
|
| 16 |
+
|
| 17 |
+
住院(科室):
|
| 18 |
+
Ward
|
| 19 |
+
|
| 20 |
+
眼耳鼻
|
| 21 |
+
|
| 22 |
+
住院号:
|
| 23 |
+
Hospitalization number
|
| 24 |
+
|
| 25 |
+
医院类型:
|
| 26 |
+
Hospital type
|
| 27 |
+
|
| 28 |
+
19:11:16
|
| 29 |
+
|
| 30 |
+
2021年01月24日
|
| 31 |
+
Y M D
|
| 32 |
+
|
| 33 |
+
<table><tr><td>姓名<br/>Name</td><td colspan=2></td><td>口门诊□急诊□住院<br/>Ortpatient A&E Inpaticnt</td><td>住院日期<br/>Date of hospitalization</td><td>2021-01-22</td><td>出院日期<br/>Date of departure</td><td>2021-01-24</td></tr><tr><td>性别<br/>Gender</td><td>□男□女<br/>Male Female</td><td>统筹/公医记帐<br/>Medical insurance/Public health service accounts</td><td></td><td>个人缴费<br/>Individual payment</td><td>3563.49</td><td>结算方式<br/>Method of payment</td><td>微信支付,银行卡</td></tr><tr><td>医药费<br/>Medicine fee</td><td>金额<br/>Amount</td><td>诊查费<br/>Physical examination</td><td>金额<br/>Amount</td><td>治疗费<br/>Treatment</td><td>金额<br/>Amount</td><td>其他<br/>Others</td><td>金额<br/>Amount</td></tr><tr><td>西药费:</td><td>529.19</td><td>检查费:</td><td>1469.50</td><td>治疗费:</td><td>119.00</td><td>床位费:</td><td>50.00</td></tr><tr><td rowspan="2">中成药:</td><td rowspan="2"></td><td rowspan="2">诊查费:</td><td rowspan="2">36.00</td><td>输氧费:</td><td></td><td>护理费</td><td>26.00</td></tr><tr><td>输血费:</td><td></td><td>特殊服务费:</td><td></td></tr><tr><td>中草药:</td><td>237.50</td><td>检验费:</td><td>1090.30</td><td>手术费:</td><td>6.00</td><td>其他费:</td><td>0.00</td></tr><tr><td>预交款<br/>Pre-charge</td><td>3563.49</td><td>补收<br/>Re-charge</td><td></td><td>退款<br/>Refund</td><td></td><td>欠费<br/>Overdue</td><td></td></tr><tr><td colspan="2">合计人民币(大写)<br/>TOTAL (RMB,In words)</td><td colspan="4">零拾零万叁仟伍佰陆拾叁元肆角玖分</td><td colspan="2">¥:3563.49</td></tr></table>
|
| 34 |
+
|
| 35 |
+
备注
|
| 36 |
+
|
| 37 |
+
1.医药费包括:西药、中成药及中草药等
|
| 38 |
+
2.诊查费包括:检查 、化验及体检等医技项目
|
| 39 |
+
3、治疗费包括:正畸、镶牙、输血、输氧、放疗、化疗、手术及材料等
|
| 40 |
+
4、其他包括:床位、护理、药事服务、医学签证、法医鉴定等费用
|
| 41 |
+
|
| 42 |
+
个人自付包括:
|
| 43 |
+
|
| 44 |
+
个人现金:3563.40
|
| 45 |
+
|
| 46 |
+
个人账户:0.00
|
| 47 |
+
|
| 48 |
+
医疗救助:0.00
|
| 49 |
+
|
| 50 |
+
第三联 存 根
|
| 51 |
+
Countertfoil
|
| 52 |
+
|
| 53 |
+
收费单位(盖章):吴川市人民医院
|
| 54 |
+
Payee(seal)
|
| 55 |
+
|
| 56 |
+
复核:
|
| 57 |
+
Assessor
|
| 58 |
+
|
| 59 |
+
收款人:5312
|
| 60 |
+
Cashier
|
| 61 |
+
|
| 62 |
+
广东省财政厅印制
|
| 63 |
+
Printed by Guangdong Provincial Finance Bureau
|
| 64 |
+
|
| 65 |
+
(手写无效,限2021年12月31日前使用)
|
track2_finixphoto_300/mds/2090cf59-a30e-47b0-81a9-489e8e6a6063.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 河北省沧州中西医结合医院
|
| 2 |
+
|
| 3 |
+
# 出院记录
|
| 4 |
+
|
| 5 |
+
姓名:
|
| 6 |
+
|
| 7 |
+
性别:男
|
| 8 |
+
|
| 9 |
+
年龄:33 岁
|
| 10 |
+
|
| 11 |
+
科别:
|
| 12 |
+
|
| 13 |
+
床号:
|
| 14 |
+
|
| 15 |
+
病案号:
|
| 16 |
+
|
| 17 |
+
入院时间:2019-10-
|
| 18 |
+
|
| 19 |
+
出院时间:2019-11-
|
| 20 |
+
|
| 21 |
+
入院情况:患者 男,33岁。主因腰部疼痛2个月余,加重5天于2019-10-30 10:06入院。查体:T:36.7℃ P:67次/分 R呼吸:17次/分 BP血压:126/80mmHg 腰部生理曲度存在,未见明显侧弯畸形,腰4-5正中压痛明显,叩击痛阳性,无明显双下肢放射,双下肢未见明显肿胀,未见肌肉萎缩,双下肢各区针刺觉未见明显减退,双下肢直腿抬高试验:右侧70°(-),加强试验(+),左侧70°(+),双下肢各肌肌力、肌张力正常。
|
| 22 |
+
|
| 23 |
+
入院诊断:
|
| 24 |
+
|
| 25 |
+
中医:腰痛病【气滞血瘀证】
|
| 26 |
+
|
| 27 |
+
西医:1、腰椎滑脱 L4椎体2、腰椎峡部裂 L4椎体 3、腰椎间盘膨出 L4-5
|
| 28 |
+
|
| 29 |
+
诊疗经过:患者入院后完善术前相关检查,于2019-11-01在全麻下行腰椎(L4-5)后路椎弓根内固定+腰4峡部及椎板间植骨术,手术顺利,术后病人安返病房,给予抗炎等治疗,病情平稳,今日出院。
|
| 30 |
+
|
| 31 |
+
出院诊断
|
| 32 |
+
|
| 33 |
+
中医:腰痛病【气滞血瘀证】
|
| 34 |
+
|
| 35 |
+
西医:1、腰椎滑脱 L4椎体2、腰椎峡部裂 L4椎体 3、腰椎间盘膨出 L4-5
|
| 36 |
+
|
| 37 |
+
出院情况:患者病情平稳,未诉不适,体温不高,查体:生命体征平稳,心肺未见明显异常,腰部伤口敷料包扎良好,无明显渗出,伤口无红肿,双下肢肌力、肌张力正常。
|
| 38 |
+
|
| 39 |
+
出院医嘱:1、伤口定期换药,保持伤口清洁。2、继续多卧床静养,佩戴腰围保护。3、一个月后门诊复查,以后每四周周二上午门诊复查。4、不适随诊。
|
| 40 |
+
|
| 41 |
+
主治医师签字:
|
| 42 |
+
|
| 43 |
+
住院医师签字:
|
| 44 |
+
|
| 45 |
+
(一式两份,一份交患者或监护人、被授权人收执、一份入病案)
|
| 46 |
+
|
| 47 |
+
第1页
|
track2_finixphoto_300/mds/20a85e8b-2f46-595f-b3e7-01d34f606fac.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 北京增值税普通发票
|
| 2 |
+
|
| 3 |
+
# 发票联
|
| 4 |
+
|
| 5 |
+
011001900104
|
| 6 |
+
|
| 7 |
+
№ 07694593
|
| 8 |
+
|
| 9 |
+
011001900104
|
| 10 |
+
|
| 11 |
+
07694593
|
| 12 |
+
|
| 13 |
+
校验码 49117 30532 23680 31871
|
| 14 |
+
|
| 15 |
+
开票日期:2020年06月24日
|
| 16 |
+
|
| 17 |
+
购 买 方
|
| 18 |
+
|
| 19 |
+
名 称: 中国农业发展银行伊犁哈萨克自治州分行
|
| 20 |
+
|
| 21 |
+
纳税人识别号: 916540009304796015
|
| 22 |
+
|
| 23 |
+
地址、 电话: 伊宁市解放西路399号0999-8129032
|
| 24 |
+
|
| 25 |
+
开户行及账号: 中国农业发展银行伊犁哈萨克自治州分行营业部2036540990010000005537
|
| 26 |
+
|
| 27 |
+
密 码 区
|
| 28 |
+
|
| 29 |
+
2/75-03<1-702<15*6<92<-4>3- 3>1007341825860>+190+/14624 /1+439/-/1*2>/7/2<11*6<96<+ 5<->+/300-+41921>02>+5863<0
|
| 30 |
+
|
| 31 |
+
<table>
|
| 32 |
+
<tr><td>货物或应税劳务、服务名称</td><td>规格型号</td><td>单位</td><td>数量</td><td>单价</td><td>金额</td><td>税率</td><td>税额</td></tr>
|
| 33 |
+
<tr><td>*印刷品*银行业消防安全管理</td><td>169mm*239mm</td><td>册</td><td>1</td><td>55.87</td><td>55.87</td><td>9%</td><td>5.03</td></tr>
|
| 34 |
+
<tr><td>合计</td><td></td><td></td><td></td><td></td><td>?55.87</td><td></td><td>?5.03</td></tr>
|
| 35 |
+
</table>
|
| 36 |
+
|
| 37 |
+
价税合计(大写)
|
| 38 |
+
|
| 39 |
+
?陆拾圆玖角整
|
| 40 |
+
|
| 41 |
+
(小写)¥60.90
|
| 42 |
+
|
| 43 |
+
销 售 方
|
| 44 |
+
|
| 45 |
+
名 称: 中国金融出版社有限公司
|
| 46 |
+
|
| 47 |
+
纳税人识别号: 91110000400005169P
|
| 48 |
+
|
| 49 |
+
地址、电话: 北京市丰台区丰台北路12号 63267697
|
| 50 |
+
|
| 51 |
+
开户行及账号: 中国光大银行北京长安支行083518120100304006660
|
| 52 |
+
|
| 53 |
+
备 注
|
| 54 |
+
|
| 55 |
+
税总函〔2018〕670号 北京东港安全印刷有限公司
|
| 56 |
+
|
| 57 |
+
第二联:发票联 购买方记账凭证
|
| 58 |
+
|
| 59 |
+
收款人:田宇
|
| 60 |
+
|
| 61 |
+
复核:王维
|
| 62 |
+
|
| 63 |
+
开票人:杨峥
|
| 64 |
+
|
| 65 |
+
销售方:(章)
|
track2_finixphoto_300/mds/213b444f-95ca-41a3-92df-2bd8a0374f83.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 深圳增值税专用发票
|
| 2 |
+
|
| 3 |
+
# 发票联
|
| 4 |
+
|
| 5 |
+
4403162130
|
| 6 |
+
|
| 7 |
+
№ 46021580
|
| 8 |
+
|
| 9 |
+
4403162130
|
| 10 |
+
|
| 11 |
+
46021580
|
| 12 |
+
|
| 13 |
+
销项负数
|
| 14 |
+
|
| 15 |
+
开票日期: 2017年06月01日
|
| 16 |
+
|
| 17 |
+
购买方
|
| 18 |
+
|
| 19 |
+
名称:
|
| 20 |
+
|
| 21 |
+
深圳市中兴新地技术股份有限公司
|
| 22 |
+
|
| 23 |
+
纳税人识别号:
|
| 24 |
+
|
| 25 |
+
91440301750499138T
|
| 26 |
+
|
| 27 |
+
地址、电话:
|
| 28 |
+
|
| 29 |
+
深圳市龙岗区坂田街道岗头社区新地路1号A厂房、B厂房、C厂房 28801996
|
| 30 |
+
|
| 31 |
+
开户行及账号:
|
| 32 |
+
|
| 33 |
+
中国民生银行深圳高新区支行1820014210000923
|
| 34 |
+
|
| 35 |
+
密码区
|
| 36 |
+
|
| 37 |
+
1>/<>66>941393211603362203->12/*841>6+>>/5>+41+34286>/ +*11>369808*671<9321141>3322233630/8*31<7+-6*7>609*+>5
|
| 38 |
+
|
| 39 |
+
<table><tr><td>货物或应税劳务、服务名称</td><td>规格型号</td><td>单位</td><td>数量</td><td>单价</td><td>金额</td><td>税率</td><td>税额</td></tr><tr><td>光纤尾胶</td><td>20g/支</td><td>g</td><td>-2000</td><td>2.0512820513</td><td>-4102.56</td><td>17%</td><td>-697.44</td></tr><tr><td>合 计</td><td></td><td></td><td></td><td></td><td></td><td>¥-4102.56</td><td>¥-697.44</td></tr></table>
|
| 40 |
+
|
| 41 |
+
价税合计(大写)
|
| 42 |
+
|
| 43 |
+
⊗(负数)肆仟捌佰圆整
|
| 44 |
+
|
| 45 |
+
(小写) ¥-4800.00
|
| 46 |
+
|
| 47 |
+
销售方
|
| 48 |
+
|
| 49 |
+
名称:
|
| 50 |
+
|
| 51 |
+
深圳市浩力新材料技术有限公司
|
| 52 |
+
|
| 53 |
+
纳税人识别号:
|
| 54 |
+
|
| 55 |
+
91440300080750089U
|
| 56 |
+
|
| 57 |
+
地址、电话:
|
| 58 |
+
|
| 59 |
+
深圳市龙岗区龙城街道龙西社区五联路21号宝康工业园C栋5楼 0755-28992254
|
| 60 |
+
|
| 61 |
+
开户行及账号:
|
| 62 |
+
|
| 63 |
+
深圳农村商业银行龙西支行000157523896
|
| 64 |
+
|
| 65 |
+
备注
|
| 66 |
+
|
| 67 |
+
税总函〔2016〕117号中钞光华印制有限公司
|
| 68 |
+
|
| 69 |
+
第三联:发票联 购买方记账凭证
|
| 70 |
+
|
| 71 |
+
收款人:刘晓玲
|
| 72 |
+
|
| 73 |
+
复核:隆妹萍
|
| 74 |
+
|
| 75 |
+
开票人: 魏伟琴
|
| 76 |
+
|
| 77 |
+
销售方:(章)
|
track2_finixphoto_300/mds/23c733e1-ca08-41a9-a080-cb680f396da9.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 郑州大学洛阳中心医院 洛阳市中心医院
|
| 2 |
+
|
| 3 |
+
# 出院记录
|
| 4 |
+
|
| 5 |
+
姓名:
|
| 6 |
+
|
| 7 |
+
性别:女
|
| 8 |
+
|
| 9 |
+
年龄:54 岁
|
| 10 |
+
|
| 11 |
+
住院号:
|
| 12 |
+
|
| 13 |
+
科室:
|
| 14 |
+
|
| 15 |
+
床号:
|
| 16 |
+
|
| 17 |
+
入院日期:2019-12
|
| 18 |
+
|
| 19 |
+
出院日期:2019-12
|
| 20 |
+
|
| 21 |
+
住院天数:6
|
| 22 |
+
|
| 23 |
+
入院诊断:宫颈鳞癌 Ⅲb 期术后第 2 次化疗后
|
| 24 |
+
|
| 25 |
+
入院情况及诊疗经过:患者以“宫颈鳞癌ⅢB期术后第2次化疗后3周”为主诉入院,完善检查,无明显化疗禁忌症,于2019年12月22日给予多西他赛针+洛铂针方案静脉化疗,化疗过程顺利,出现恶心、呕吐、骨髓抑制等反应,给予补液、补钾、升白对症治疗后好转。
|
| 26 |
+
|
| 27 |
+
出院诊断:1.宫颈鳞癌ⅢB期术后第3次化疗后;2.化疗后骨髓抑制
|
| 28 |
+
|
| 29 |
+
出院情况:患者病情稳定,一般情况可,诉无恶心、呕吐,无腹痛、无腹泻,口腔无溃疡。查体:生命体征平稳,神志清楚,精神可,睡眠可,饮食可,大小便无异常,口腔黏膜完整,心肺听诊无明显异常,腹平软,无压痛、无反跳痛,肝脾未触及肿大,肠鸣音正常,双下肢无压痛。今日复查血常规无明显异常,请示上级医师后准予出院。
|
| 30 |
+
|
| 31 |
+
出院医嘱:
|
| 32 |
+
|
| 33 |
+
1、复诊时间:3周后返院治疗。
|
| 34 |
+
|
| 35 |
+
复诊次数:多次
|
| 36 |
+
|
| 37 |
+
2、出院带药用法用量:无
|
| 38 |
+
|
| 39 |
+
3、出院注意事项: 1.合理膳食, 健康生活方式宣教, 注意休息, 少量多餐, 加强营养。2.每3日定期复查血常规, 如白细胞<3.0×10⁹/l 或血小板<30×10⁹/l返院治疗。3.1月12日返院继续治疗, 返院前1-2日电话联系管床医生。4.若恶心、呕吐、发热等不适随诊。
|
| 40 |
+
|
| 41 |
+
医师签名:
|
track2_finixphoto_300/mds/24605939-36d9-49ba-89f5-111934063fb1.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
0401
|
| 2 |
+
|
| 3 |
+
# 重庆市
|
| 4 |
+
# 门诊医药费专用收据
|
| 5 |
+
|
| 6 |
+
0559817
|
| 7 |
+
|
| 8 |
+
<table>
|
| 9 |
+
<tr>
|
| 10 |
+
<td style="text-align:center;">项目</td>
|
| 11 |
+
<td style="text-align:center;">金额(元)</td></tr>
|
| 12 |
+
<tr>
|
| 13 |
+
<td>2020-05-16</td>
|
| 14 |
+
<td>发票号:0559817</td></tr>
|
| 15 |
+
<tr>
|
| 16 |
+
<td>会诊费</td>
|
| 17 |
+
<td>5.00</td></tr>
|
| 18 |
+
</table>
|
| 19 |
+
|
| 20 |
+
急诊医学
|
| 21 |
+
|
| 22 |
+
第一联 收据
|
| 23 |
+
|
| 24 |
+
合计小写:
|
| 25 |
+
|
| 26 |
+
合计大写:5.00
|
| 27 |
+
|
| 28 |
+
备注:伍圆整
|
| 29 |
+
|
| 30 |
+
合计:5.00,自助:5.00
|
| 31 |
+
|
| 32 |
+
收款单位(盖章):
|
| 33 |
+
|
| 34 |
+
收款人:龙邱渝
|
track2_finixphoto_300/mds/27c01a18-e2eb-4735-852d-c367d44fdc82.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 吉林增值税普通发票
|
| 2 |
+
|
| 3 |
+
# 发票联
|
| 4 |
+
|
| 5 |
+
2200162320
|
| 6 |
+
|
| 7 |
+
№ 18352069
|
| 8 |
+
|
| 9 |
+
2200162320
|
| 10 |
+
|
| 11 |
+
18352069
|
| 12 |
+
|
| 13 |
+
开票日期:2019年3月24日
|
| 14 |
+
|
| 15 |
+
校验码 37278 91098 57448 84153
|
| 16 |
+
|
| 17 |
+
购买方
|
| 18 |
+
|
| 19 |
+
名 称:胡亚茜
|
| 20 |
+
|
| 21 |
+
纳税人识别号:
|
| 22 |
+
|
| 23 |
+
地址、电话:
|
| 24 |
+
|
| 25 |
+
开户行及账号:
|
| 26 |
+
|
| 27 |
+
密码区
|
| 28 |
+
|
| 29 |
+
>>21/<40120<<6072--71-*7*0*-2-209-9582-8/1/7/3219/0/+1*--043+>/*>+7479<508+2-*8<58/8511282+1019*3-2808-18950
|
| 30 |
+
|
| 31 |
+
<table><tr><td>货物或应税劳务、服务名称</td><td>规格型号</td><td>单位</td><td>数量</td><td>单价</td><td>金额</td><td>税率</td><td>税额</td></tr><tr><td>苹果数据线</td><td></td><td>条</td><td>200</td><td>36.893204</td><td>7378.64</td><td>3%</td><td>221.36</td></tr><tr><td>苹果充电器</td><td></td><td>个</td><td>150</td><td>43.689320</td><td>6553.40</td><td>3%</td><td>196.60</td></tr><tr><td>苹果国行耳机</td><td></td><td>条</td><td>150</td><td>58.252427</td><td>8737.86</td><td>3%</td><td>262.14</td></tr><tr><td>苹果港版耳机</td><td></td><td>条</td><td>150</td><td>58.252427</td><td>8737.86</td><td>3%</td><td>262.14</td></tr><tr><td>苹果PD充电器+数据线</td><td></td><td>条</td><td>100</td><td>87.378641</td><td>8737.86</td><td>3%</td><td>262.14</td></tr><tr><td>合计</td><td></td><td></td><td></td><td></td><td>¥ 40145.62</td><td></td><td>¥ 1204.38</td></tr></table>
|
| 32 |
+
|
| 33 |
+
价税合计(大写)
|
| 34 |
+
|
| 35 |
+
⊗肆万壹仟叁佰伍拾圆整
|
| 36 |
+
|
| 37 |
+
(小写)¥41350.00
|
| 38 |
+
|
| 39 |
+
销 售 方
|
| 40 |
+
|
| 41 |
+
名 称:吉林省巴黎春天百货有限公司
|
| 42 |
+
|
| 43 |
+
纳税人识别号: 220104795211855
|
| 44 |
+
|
| 45 |
+
地址、电 话: 长春市朝阳区工农大路1055号
|
| 46 |
+
|
| 47 |
+
开户行及账号:中国银行(长春支行)220485003747
|
| 48 |
+
|
| 49 |
+
备 注
|
| 50 |
+
|
| 51 |
+
税总函〔2016〕116号山东承安发票印刷有限公司
|
| 52 |
+
|
| 53 |
+
第二联:发票联 购买方记账凭证
|
| 54 |
+
|
| 55 |
+
收款人:刘思琴
|
| 56 |
+
|
| 57 |
+
复核:肖镇国
|
| 58 |
+
|
| 59 |
+
开票人:金伟光
|
| 60 |
+
|
| 61 |
+
销售方:(章)
|