Updates
Browse files
app.py
CHANGED
@@ -59,14 +59,28 @@ def deduplicate_embeddings(
|
|
59 |
|
60 |
def display_word_differences(x: str, y: str) -> str:
|
61 |
"""
|
62 |
-
Display the word-level differences between two texts
|
|
|
63 |
|
64 |
:param x: First text.
|
65 |
:param y: Second text.
|
66 |
-
:return: A string showing word-level differences.
|
67 |
"""
|
68 |
diff = ndiff(x.split(), y.split())
|
69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
def load_dataset_texts(dataset_name: str, dataset_split: str, text_column: str) -> list[str]:
|
72 |
"""
|
|
|
59 |
|
60 |
def display_word_differences(x: str, y: str) -> str:
|
61 |
"""
|
62 |
+
Display the word-level differences between two texts, formatted to avoid
|
63 |
+
misinterpretation of Markdown syntax.
|
64 |
|
65 |
:param x: First text.
|
66 |
:param y: Second text.
|
67 |
+
:return: A string showing word-level differences, wrapped in a code block.
|
68 |
"""
|
69 |
diff = ndiff(x.split(), y.split())
|
70 |
+
# Wrap differences in a code block to prevent interpretation as Markdown
|
71 |
+
formatted_diff = "\n".join(word for word in diff if word.startswith(("+", "-")))
|
72 |
+
return f"```\n{formatted_diff}\n```"
|
73 |
+
|
74 |
+
# def display_word_differences(x: str, y: str) -> str:
|
75 |
+
# """
|
76 |
+
# Display the word-level differences between two texts.
|
77 |
+
|
78 |
+
# :param x: First text.
|
79 |
+
# :param y: Second text.
|
80 |
+
# :return: A string showing word-level differences.
|
81 |
+
# """
|
82 |
+
# diff = ndiff(x.split(), y.split())
|
83 |
+
# return " ".join(word for word in diff if word.startswith(("+", "-")))
|
84 |
|
85 |
def load_dataset_texts(dataset_name: str, dataset_split: str, text_column: str) -> list[str]:
|
86 |
"""
|