|
|
|
@ -12,6 +12,7 @@ import com.alibaba.dashscope.utils.Constants;
|
|
|
|
|
import org.dom4j.DocumentException;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
|
|
|
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
|
|
|
@ -19,7 +20,6 @@ import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
|
|
|
|
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
|
|
|
|
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
@ -47,6 +47,10 @@ public class A15 {
|
|
|
|
|
return result.getOutput().getChoices().getFirst().getMessage().getContent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String removeEmptyLines(String text) {
|
|
|
|
|
// 使用正则表达式分割字符串,然后过滤掉空行
|
|
|
|
|
return text.replace("\n\n", "\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws IOException, DocumentException, NoApiKeyException, InputRequiredException {
|
|
|
|
|
String filePath = "D:\\dsWork\\YunNanDsBase\\Doc\\县区研究报告\\保山市\\昌宁县人口变化及其对教育的影响.docx";
|
|
|
|
@ -56,20 +60,34 @@ public class A15 {
|
|
|
|
|
XWPFDocument document = new XWPFDocument(inputStream);
|
|
|
|
|
List<XWPFParagraph> paragraphs = document.getParagraphs();
|
|
|
|
|
|
|
|
|
|
String[] a = {"学前教育发展规模现状", "小学教育发展规模现状", "初中教育发展规模现状", "高中教育发展规模现状", "基础教育资源配置现状"};
|
|
|
|
|
//接下我将遍历 word文档 中的每一段文字,如果遍历到的文字中包含上面数组的某一个字符串,开始截取此学段的文字
|
|
|
|
|
for (XWPFParagraph paragraph : paragraphs) {
|
|
|
|
|
List<XWPFRun> runs = paragraph.getRuns();
|
|
|
|
|
for (XWPFRun run : runs) {
|
|
|
|
|
String text = run.getText(0);
|
|
|
|
|
if (text != null) {
|
|
|
|
|
content = content + text;
|
|
|
|
|
content += text;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String question = "我将给你提供一大段文字,帮我总结下学前教育幼儿入园情况,划分两个阶段:(1)学前教育过去几年入园情况 (2)学前教育幼儿入园未来发展预测。语言尽量精简。";
|
|
|
|
|
question += "示例: 1. 与2022年相比,寻甸县未来几年,学前教育幼儿入园人数增长不大,至2035年预计在6800左右,仅增加几百人";
|
|
|
|
|
question += "2. 未来镇区幼儿入园人数将逐年增加,而乡村幼儿入园人数将明显减少。";
|
|
|
|
|
question += "下面是文字内容:";
|
|
|
|
|
question += content;
|
|
|
|
|
System.out.println(callTongYiQianWen(question));
|
|
|
|
|
List<Integer> posList = new ArrayList<>();
|
|
|
|
|
for (String s : a) {
|
|
|
|
|
int pos = content.indexOf(s);
|
|
|
|
|
posList.add(pos);
|
|
|
|
|
}
|
|
|
|
|
List<String> res = new ArrayList<>();
|
|
|
|
|
for (int i = 0; i < posList.size() - 1; i++) {
|
|
|
|
|
int start = posList.get(i) + a[i].length(), end = posList.get(i + 1);
|
|
|
|
|
res.add(content.substring(start, end));
|
|
|
|
|
}
|
|
|
|
|
for (String re : res) {
|
|
|
|
|
String question = "我将给你提供一大段文字,帮我总结下入园或招生情况,划分两个阶段:(1)过去几年入园、招生情况 (2)入园、招生未来发展预测。尽量保留文中原话,一个阶段不要超过30字。不要使用markdown语法。";
|
|
|
|
|
question += "示例: 1. 与2022年相比,寻甸县未来几年,学前教育幼儿入园人数增长不大,至2035年预计在6800左右,仅增加几百人";
|
|
|
|
|
question += "2. 未来镇区幼儿入园人数将逐年增加,而乡村幼儿入园人数将明显减少。";
|
|
|
|
|
question += "下面是文字内容:";
|
|
|
|
|
question += re;
|
|
|
|
|
System.out.println(removeEmptyLines(callTongYiQianWen(question)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|