-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
62 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import unittest | ||
|
||
from semantic_chunkers.splitters.regex import RegexSplitter | ||
|
||
|
||
class TestRegexSplitter(unittest.TestCase): | ||
def setUp(self): | ||
self.splitter = RegexSplitter() | ||
|
||
def test_split_by_double_newline(self): | ||
doc = "This is the first paragraph.\n\nThis is the second paragraph." | ||
expected = ["This is the first paragraph.", "This is the second paragraph."] | ||
result = self.splitter(doc) | ||
self.assertEqual(result, expected) | ||
|
||
def test_split_by_single_newline(self): | ||
doc = "This is the first line.\nThis is the second line." | ||
expected = ["This is the first line.", "This is the second line."] | ||
result = self.splitter(doc) | ||
self.assertEqual(result, expected) | ||
|
||
def test_split_by_period(self): | ||
doc = "This is the first sentence. This is the second sentence." | ||
expected = ["This is the first sentence.", "This is the second sentence."] | ||
result = self.splitter(doc) | ||
self.assertEqual(result, expected) | ||
|
||
def test_complex_split(self): | ||
doc = """ | ||
First paragraph.\n\nSecond paragraph.\nThird line in second paragraph. Fourth line.\n\nFifth paragraph.""" | ||
expected = [ | ||
"First paragraph.", | ||
"Second paragraph.", | ||
"Third line in second paragraph.", | ||
"Fourth line.", | ||
"Fifth paragraph.", | ||
] | ||
result = self.splitter(doc) | ||
self.assertEqual(result, expected) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |