Source code for wimarka.utils.helper


source_tags = ["EN", "CEB", "ILO", "TGL"]
target_tags = ["CEB", "ILO", "TGL"]

[docs] def add_tag(line, tag: str): return f"[{tag.upper()}] {line}"
[docs] def check_tag(src_tag: str, tgt_tag: str): if src_tag is None or tgt_tag is None: raise ValueError("Source and target language tags must be provided.") if src_tag.upper() == tgt_tag.upper(): raise ValueError("Source and target language tags must be different.") if src_tag.upper() not in source_tags: return ValueError(f"Unsupported source language tag: {src_tag}. Supported tags are: {', '.join(source_tags)}") if tgt_tag.upper() not in target_tags: return ValueError(f"Unsupported target language tag: {tgt_tag}. Supported tags are: {', '.join(target_tags)}")
[docs] def get_column(X): return X.values.ravel()
[docs] def printEvaluationResults(results): print("Evaluation Results:\n") for i in range(len(results["source"])): print(f"Entry {i+1}:") print(f"Source: {results['source'][i]}") print(f"Target: {results['target'][i]}") print(f"Errors: {results['errors'][i]}") print(f"Fluency Score: {results['fluency_score'][i]}") print(f"Adequacy Score: {results['adequacy_score'][i]}") print(f"Overall Score: {results['overall_score'][i]}") print(f"Explanation: {results['explanation'][i]}") print(f"Corrected Translation: {results['corrected_translation'][i]}") print("-" * 25)