2025-03-03 13:40:06 +08:00
|
|
|
//import com.electromagnetic.industry.software.manage.Application;
|
2025-04-03 14:39:40 +08:00
|
|
|
//import jakarta.annotation.Resource;
|
2025-03-03 13:40:06 +08:00
|
|
|
//import org.junit.jupiter.api.Test;
|
2025-04-03 16:30:57 +08:00
|
|
|
//import org.springframework.ai.document.Document;
|
2025-04-08 09:14:23 +08:00
|
|
|
//import org.springframework.ai.document.DocumentReader;
|
|
|
|
|
//import org.springframework.ai.reader.TextReader;
|
|
|
|
|
//import org.springframework.ai.transformer.splitter.TokenTextSplitter;
|
2025-04-03 14:39:40 +08:00
|
|
|
//import org.springframework.ai.vectorstore.VectorStore;
|
2025-03-03 13:40:06 +08:00
|
|
|
//import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
|
//
|
2025-04-08 09:14:23 +08:00
|
|
|
//import java.io.File;
|
|
|
|
|
//import java.net.MalformedURLException;
|
|
|
|
|
//import java.nio.file.Path;
|
2025-04-03 14:39:40 +08:00
|
|
|
//import java.util.List;
|
2025-03-03 13:40:06 +08:00
|
|
|
//
|
|
|
|
|
//@SpringBootTest(classes = Application.class)
|
|
|
|
|
//public class Test1 {
|
|
|
|
|
//
|
|
|
|
|
// @Resource
|
2025-04-03 14:39:40 +08:00
|
|
|
// private VectorStore vectorStore;
|
2025-03-03 13:40:06 +08:00
|
|
|
//
|
|
|
|
|
// @Test
|
2025-04-08 09:14:23 +08:00
|
|
|
// public void testTree() throws MalformedURLException {
|
|
|
|
|
// String path = "D:/明朝那些事儿.txt";
|
|
|
|
|
// File file = new File(path);
|
|
|
|
|
// Path tempFile = file.toPath();
|
|
|
|
|
// DocumentReader documentReader = new TextReader(String.valueOf(tempFile.toUri().toURL()));
|
|
|
|
|
// List<Document> documents = new TokenTextSplitter().apply(documentReader.get());
|
|
|
|
|
// documents = documents.subList(0, 200);
|
|
|
|
|
// vectorStore.write(documents);
|
|
|
|
|
//
|
2025-04-08 11:58:52 +08:00
|
|
|
/// / Path tempFile = Paths.get(file.getAbsolutePath());
|
|
|
|
|
/// / DocumentReader documentReader = new TextReader(String.valueOf(tempFile.toUri().toURL()));
|
|
|
|
|
/// / List<Document> documents = documentReader.get();
|
|
|
|
|
/// / vectorStore.write(documents);
|
2025-03-03 13:40:06 +08:00
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//}
|