5656
5757logger = logging .getLogger (__name__ )
5858
59+ COLUMNS = [
60+ "subject_id" ,
61+ "subject_label" ,
62+ "predicate_id" ,
63+ "object_id" ,
64+ "object_label" ,
65+ "mapping_justification" ,
66+ "author_id" ,
67+ "mapping_tool" ,
68+ "predicate_modifier" ,
69+ ]
70+
5971
6072class _CuratedTuple (NamedTuple ):
6173 """A tuple for writing manual curations to SSSOM TSV."""
@@ -283,8 +295,8 @@ def append_true_mapping_tuples(mappings: Iterable[SemanticMapping]) -> None:
283295
284296
285297def write_true_mappings (mappings : Iterable [SemanticMapping ], * , path : Path | None = None ) -> None :
286- """Write mappigns to the true mappings file."""
287- _write_helper (mappings , path = path or POSITIVES_SSSOM_PATH , mode = "w" , t = "curated" )
298+ """Write mappings to the true mappings file."""
299+ _write_helper (mappings , path or POSITIVES_SSSOM_PATH , mode = "w" , t = "curated" )
288300
289301
290302def lint_true_mappings (* , path : Path | None = None , standardize : bool ) -> None :
@@ -316,7 +328,7 @@ def append_false_mappings(
316328 """Append new lines to the false mappings table."""
317329 if path is None :
318330 path = NEGATIVES_SSSOM_PATH
319- _write_helper (mappings = mappings , path = path , mode = "a" , t = "curated" )
331+ _write_helper (mappings , path = path , mode = "a" , t = "curated" )
320332 if sort :
321333 lint_false_mappings (path = path , standardize = standardize )
322334
@@ -412,7 +424,7 @@ def append_predictions(
412424
413425 if path is None :
414426 path = PREDICTIONS_SSSOM_PATH
415- _write_helper (mappings , path , mode = "a" , t = "predicted" )
427+ _write_helper (mappings , path = path , mode = "a" , t = "predicted" )
416428 if sort :
417429 lint_predictions (path = path , standardize = standardize )
418430
@@ -441,8 +453,7 @@ def lint_predictions(
441453 additional_curated_mappings or [],
442454 ),
443455 )
444- mappings = _remove_redundant (mappings )
445- mappings = sorted (mappings )
456+ mappings = _clean_mappings (mappings )
446457 write_predictions (mappings , path = path )
447458
448459
@@ -454,6 +465,11 @@ def remove_mappings(
454465 return (mapping for mapping in mappings if get_canonical_tuple (mapping ) not in skip_tuples )
455466
456467
468+ def _clean_mappings (mappings : Iterable [SemanticMapping ]):
469+ m = sorted (mappings )
470+ return _remove_redundant (m )
471+
472+
457473def _remove_redundant (mappings : Iterable [SemanticMapping ]) -> Iterable [SemanticMapping ]:
458474 dd = defaultdict (list )
459475 for mapping in mappings :
0 commit comments