| Algorithm 2: Column Constraint Function |
|
function columnConstraint(VariableNodeSet v’)
1: E ← all e of v’//(e is generated in Algorithm 1) 2: Map ← Create a key-value mapping, key represent type and value represent vote 3: for all e in E do 4: T ← queryColumnTypes(e); 5: for all t in T do 6: if Map.contains(t) then 7: t.value += 1 8: else 9: Map.put(t, 1) 10: end if 11: end for 12: end for 13: topVote ← max votes in all t.value 14: Thigh ← all t where t.value == topVote 15: for all t in Thigh do 16: t.granularity ← searchGranularity(t); 17: end for 18: top_col ← t with maximum t.value and minimum t.granularity 19: topScore ← top_col.value/number of rows 20: if topScore <= threshold then 21: send low-confidence and unchanged messages to all variable nodes in this column. 22: column annotation ← “no-annotation” 23: else 24: column annotation ← top_col 25: end if 26: for all e in E do 27: if e.T.contains(top_col) then 28: send change message along with top_col as the type for entity that e should update to 29: else 30: send the unchanged message. 31: end if 32: end for end function |