MCPcopy Create free account
hub / github.com/chatdoc-com/OCRFlux / CustomConfig

Class CustomConfig

eval/eval_table_to_html_olmocr.py:34–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32
33
34class CustomConfig(Config):
35 @staticmethod
36 def maximum(*sequences):
37 """Get maximum possible value
38 """
39 return max(map(len, sequences))
40
41 def normalized_distance(self, *sequences):
42 """Get distance from 0 to 1
43 """
44 return float(distance.levenshtein(*sequences)) / self.maximum(*sequences)
45
46 def rename(self, node1, node2):
47 """Compares attributes of trees"""
48 if (node1.tag != node2.tag) or (node1.colspan != node2.colspan) or (node1.rowspan != node2.rowspan):
49 return 1.
50 if node1.tag == 'td':
51 if node1.content or node2.content:
52 return self.normalized_distance(node1.content, node2.content)
53 return 0.
54
55
56class TEDS(object):

Callers 1

evaluateMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected