Skip to content

Commit

Permalink
fixbug: Expand sentence-ending punctuation check in _create_statement…
Browse files Browse the repository at this point in the history
…s method (#1523)

**Description**

This pull request addresses an issue where non-English punctuation
(e.g., "。", "!") was not properly handled in the `_create_statements`
function, causing sentences in languages like Chinese to be ignored and
potentially leading to incorrect faithfulness scores.

**Changes Made**

Updated the condition:

```python
if sentence.strip().endswith("."):
```

to

```python
if sentence.strip().endswith(('.', '。', '!', '!')):
```

This ensures that sentences with non-English punctuation are included in
the processing.

**Impact**

This change allows the system to correctly process sentences in
languages like Chinese, preventing empty `sentences_with_index`
variables and ensuring accurate faithfulness scores.

---

Let me know if this works or if you need further edits! Thanks!

Co-authored-by: jeff yang <[email protected]>
  • Loading branch information
Jeff-67 and jeff yang authored Oct 17, 2024
1 parent a095804 commit 685347d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/ragas/metrics/_faithfulness.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ async def _create_statements(
sentences_with_index = {
i: sentence
for i, sentence in enumerate(sentences)
if sentence.strip().endswith(".")
if sentence.strip().endswith(('.', '。', '!', '!'))
}

statements_simplified = await self.statement_prompt.generate(
Expand Down

0 comments on commit 685347d

Please sign in to comment.