MCPcopy Create free account
hub / github.com/comaps/comaps / common_part

Function common_part

tools/python/openlr/quality.py:99–107  ·  view source on GitHub ↗
(l1, l2)

Source from the content-addressed store, hash-verified

97 )
98
99def common_part(l1, l2):
100 assert l1, 'left hand side argument should not be empty'
101 if not l2:
102 return 0.0
103 common, diff = lcs(l1, l2, eq=almost_equal)
104 common_len = sum(distance(*x) for x in common)
105 diff_len = sum(distance(*x) for x in diff)
106 assert common_len + diff_len
107 return common_len / (common_len + diff_len)
108
109class Segment:
110 class NoGoldenPathError(ValueError):

Callers 1

calculateFunction · 0.85

Calls 2

lcsFunction · 0.85
distanceFunction · 0.85

Tested by

no test coverage detected