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

Class CustomConfig

eval/eval_table_to_html.py:33–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

evaluateMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected