fix column matcher false-positive on shared table prefixes; round float durations for int columns
This commit is contained in:
@@ -139,9 +139,23 @@ class ColumnMatcher:
|
||||
if normalized_source == unprefixed_target:
|
||||
return _UNPREFIXED, "unprefixed"
|
||||
# Not every field has a table prefix (`hemoglobina_g_dl`), so words
|
||||
# are compared against both the full and the unprefixed name.
|
||||
# are compared against both the full and the unprefixed name. When
|
||||
# the target *does* have real content beyond its prefix ("eeg" in
|
||||
# "eeg_estudio"), that prefix is dropped from the full-name words
|
||||
# first: every column in the table shares it, so a source word
|
||||
# matching only that (e.g. "eeg_id" ~ "eeg_estudio", both just
|
||||
# carrying "eeg") is not real evidence of a relationship. When the
|
||||
# target has no content beyond its prefix (it isn't really a
|
||||
# "prefix_field" name, e.g. "hemoglobina_g_dl"), nothing is dropped.
|
||||
unprefixed_target_words = _words(unprefixed_target)
|
||||
prefix_token = normalized_target.split("_", 1)[0]
|
||||
target_words_full = (
|
||||
[w for w in _words(normalized_target) if w != prefix_token]
|
||||
if unprefixed_target_words
|
||||
else _words(normalized_target)
|
||||
)
|
||||
source_words = _words(normalized_source)
|
||||
words = max(_word_score(source_words, _words(normalized_target)), _word_score(source_words, _words(unprefixed_target)))
|
||||
words = max(_word_score(source_words, target_words_full), _word_score(source_words, unprefixed_target_words))
|
||||
if words >= _WORD_FLOOR:
|
||||
# 0.5..0.7 by word overlap, plus a tiny whole-string tiebreak so
|
||||
# "fecha_reporte" prefers bx_fecha_reporte over another one-word overlap.
|
||||
|
||||
Reference in New Issue
Block a user