Skip to content

Commit

Permalink
renamed DocumentSplitter split() to splitAll() (langchain4j#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
langchain4j authored Jul 25, 2023
1 parent 6e240e4 commit 5666328
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public interface DocumentSplitter {

List<TextSegment> split(Document document);

default List<TextSegment> split(List<Document> documents) {
default List<TextSegment> splitAll(List<Document> documents) {
return documents.stream()
.flatMap(document -> split(document).stream())
.collect(toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void ingest(Document... documents) {
}

public void ingest(List<Document> documents) {
List<TextSegment> segments = splitter.split(documents);
List<TextSegment> segments = splitter.splitAll(documents);
List<Embedding> embeddings = embeddingModel.embedAll(segments);
embeddingStore.addAll(embeddings, segments);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void should_split_documents_then_embed_them_and_store_in_embedding_store(
textSegment("Second sentence."),
textSegment("Third sentence.")
);
when(splitter.split(documents)).thenReturn(segments);
when(splitter.splitAll(documents)).thenReturn(segments);

EmbeddingModel embeddingModel = mock(EmbeddingModel.class);
List<Embedding> embeddings = asList(
Expand All @@ -51,7 +51,7 @@ public void should_split_documents_then_embed_them_and_store_in_embedding_store(
ingestor.ingest(documents);


verify(splitter).split(documents);
verify(splitter).splitAll(documents);
verifyNoMoreInteractions(splitter);

verify(embeddingModel).embedAll(segments);
Expand Down

0 comments on commit 5666328

Please sign in to comment.