|
|
|
@ -13,7 +13,6 @@ import com.ruoyi.biemo.business.domain.*;
|
|
|
|
|
import com.ruoyi.biemo.business.service.CategoryService;
|
|
|
|
|
import com.ruoyi.biemo.business.service.DocInfoService;
|
|
|
|
|
import com.ruoyi.biemo.core.page.Page;
|
|
|
|
|
import com.ruoyi.biemo.core.page.PageFactory;
|
|
|
|
|
import com.ruoyi.biemo.mongodb.utils.MongoHelper;
|
|
|
|
|
import com.ruoyi.biemo.nlp.DependencyParserUtils;
|
|
|
|
|
import com.ruoyi.biemo.nlp.TextClassificationUtils;
|
|
|
|
@ -25,6 +24,8 @@ import com.ruoyi.common.enums.BusinessType;
|
|
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
|
|
import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
|
|
import org.springframework.data.mongodb.core.query.Query;
|
|
|
|
@ -32,12 +33,9 @@ import org.springframework.data.mongodb.core.query.Update;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import javax.swing.plaf.synth.SynthOptionPaneUI;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -58,47 +56,97 @@ public class DocInfoController extends BaseController {
|
|
|
|
|
@Autowired
|
|
|
|
|
private MongoHelper mongoHelper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/test")
|
|
|
|
|
public void test(){
|
|
|
|
|
public void test() {
|
|
|
|
|
List<Report> all2 = mongoHelper.findAll(Report.class);
|
|
|
|
|
System.out.println("ZZZ1:"+all2.size());
|
|
|
|
|
System.out.println("ZZZ11:"+all2.get(0).getId());
|
|
|
|
|
System.out.println("ZZZ1:" + all2.size());
|
|
|
|
|
System.out.println("ZZZ11:" + all2.get(0).getId());
|
|
|
|
|
List<Category> all1 = mongoHelper.findAll(Category.class);
|
|
|
|
|
System.out.println("ZZZ2:"+all1.size());
|
|
|
|
|
System.out.println("ZZZ22:"+all1.get(0).getId());
|
|
|
|
|
System.out.println("ZZZ2:" + all1.size());
|
|
|
|
|
System.out.println("ZZZ22:" + all1.get(0).getId());
|
|
|
|
|
List<DocInfo> all = mongoHelper.findAll(DocInfo.class);
|
|
|
|
|
System.out.println("ZZZ3:"+all.size());
|
|
|
|
|
System.out.println("ZZZ33:"+all.get(0).getId());
|
|
|
|
|
System.out.println("ZZZ3:" + all.size());
|
|
|
|
|
System.out.println("ZZZ33:" + all.get(0).getId());
|
|
|
|
|
DocInfo byId1 = mongoTemplate.findById("648c3996656fae4c70ccde97", DocInfo.class);
|
|
|
|
|
System.out.println("BBBDDD:"+byId1);
|
|
|
|
|
System.out.println("BBBDDD:"+byId1.getId());
|
|
|
|
|
System.out.println("BBBDDD:" + byId1);
|
|
|
|
|
System.out.println("BBBDDD:" + byId1.getId());
|
|
|
|
|
DocInfo byId = mongoHelper.findById("648c3996656fae4c70ccde97", DocInfo.class);
|
|
|
|
|
System.out.println("bbb:"+byId);
|
|
|
|
|
System.out.println("bbb:"+byId.getId());
|
|
|
|
|
System.out.println("bbb:" + byId);
|
|
|
|
|
System.out.println("bbb:" + byId.getId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询文章管理列表
|
|
|
|
|
*/
|
|
|
|
|
//@PreAuthorize("@ss.hasPermi('biemo:docInfo:list')")
|
|
|
|
|
@GetMapping("/list")
|
|
|
|
|
public Page<DocInfo> list(DocInfo docInfo)
|
|
|
|
|
{
|
|
|
|
|
Page<DocInfo> page = docInfoService.selectDocInfoPage(docInfo,PageFactory.defaultPage());
|
|
|
|
|
System.out.println(page.getRows().get(0));
|
|
|
|
|
List<DocInfo> rows = page.getRows();
|
|
|
|
|
page.getRows().forEach(doc->{
|
|
|
|
|
Category category = new Category();
|
|
|
|
|
category = categoryService.selectCategoryById(doc.getCateId());
|
|
|
|
|
if(category!=null&&category.getName()!=null){
|
|
|
|
|
doc.setCateName(category.getName());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return page;
|
|
|
|
|
// @GetMapping("/list")
|
|
|
|
|
// public Page<DocInfo> list(DocInfo docInfo) {
|
|
|
|
|
// Page<DocInfo> page = docInfoService.selectDocInfoPage(docInfo, PageFactory.defaultPage());
|
|
|
|
|
// System.out.println(page.getRows().get(0));
|
|
|
|
|
// List<DocInfo> rows = page.getRows();
|
|
|
|
|
// page.getRows().forEach(doc -> {
|
|
|
|
|
// Category category = new Category();
|
|
|
|
|
// category = categoryService.selectCategoryById(doc.getCateId());
|
|
|
|
|
// if (category != null && category.getName() != null) {
|
|
|
|
|
// doc.setCateName(category.getName());
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// return page;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
//todo 新查询,不使用ES,直接查询mongo page从0开始
|
|
|
|
|
@PostMapping("/list")
|
|
|
|
|
public Page<DocInfo> list2(@RequestBody DocInfo docInfo,
|
|
|
|
|
@RequestParam(defaultValue = "0") int page,
|
|
|
|
|
@RequestParam(defaultValue = "10") int size) {
|
|
|
|
|
List<String> schoolIds = Arrays.asList("管理员", docInfo.getSchoolId()); // 构建 schoolId 列表
|
|
|
|
|
|
|
|
|
|
//创建查询条件
|
|
|
|
|
Criteria criteria = Criteria.where("schoolId").in(schoolIds); // schoolId 过滤条件
|
|
|
|
|
|
|
|
|
|
// 添加 cateId 条件(精确匹配)
|
|
|
|
|
if (docInfo.getCateId() != null && !docInfo.getCateId().isEmpty()) {
|
|
|
|
|
criteria.and("cateId").is(docInfo.getCateId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 添加 content 条件(模糊查询)
|
|
|
|
|
if (docInfo.getContent() != null && !docInfo.getContent().isEmpty()) {
|
|
|
|
|
Pattern contentPattern = Pattern.compile("^.*" + docInfo.getContent() + ".*$", Pattern.CASE_INSENSITIVE);
|
|
|
|
|
criteria.and("content").regex(contentPattern);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 添加 title 条件(模糊查询)
|
|
|
|
|
if (docInfo.getTitle() != null && !docInfo.getTitle().isEmpty()) {
|
|
|
|
|
Pattern titlePattern = Pattern.compile("^.*" + docInfo.getTitle() + ".*$", Pattern.CASE_INSENSITIVE);
|
|
|
|
|
criteria.and("title").regex(titlePattern);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 添加 status 条件(精确匹配)
|
|
|
|
|
if (docInfo.getStatus() != null) {
|
|
|
|
|
criteria.and("status").is(docInfo.getStatus());
|
|
|
|
|
}
|
|
|
|
|
// 构建查询对象
|
|
|
|
|
Query query = new Query().addCriteria(criteria); // 添加所有条件
|
|
|
|
|
// 添加排序条件,按照 createTime 字段升序排列
|
|
|
|
|
query.with(Sort.by(Sort.Direction.DESC, "createTime"));
|
|
|
|
|
// 计算总记录数
|
|
|
|
|
long totalRecords = mongoTemplate.count(query, DocInfo.class);
|
|
|
|
|
// 设置分页条件并执行查询
|
|
|
|
|
query.with(PageRequest.of(page, size));
|
|
|
|
|
|
|
|
|
|
// 执行查询
|
|
|
|
|
List<DocInfo> docInfoList = mongoTemplate.find(query, DocInfo.class);
|
|
|
|
|
Page<DocInfo> resultPage = new Page<>(page, size, totalRecords);
|
|
|
|
|
resultPage.setRows(docInfoList); // 设置查询结果
|
|
|
|
|
resultPage.setCode(200); // 设置状态码
|
|
|
|
|
resultPage.setMsg("查询成功"); // 设置消息
|
|
|
|
|
|
|
|
|
|
return resultPage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/getWordCloudByCateId/{categoryId}")
|
|
|
|
|
public AjaxResult getWordCloudByCateId(@PathVariable String categoryId){
|
|
|
|
|
public AjaxResult getWordCloudByCateId(@PathVariable String categoryId) {
|
|
|
|
|
System.out.println("进来了 开始****************");
|
|
|
|
|
List<WordCloudItem> wordCloudItems = docInfoService.getWordCloudByCateId(categoryId);
|
|
|
|
|
|
|
|
|
@ -106,18 +154,18 @@ public class DocInfoController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/getEmotionAnalysisByCateId/{categoryId}")
|
|
|
|
|
public AjaxResult getEmotionAnalysis(@PathVariable String categoryId) throws IOException {
|
|
|
|
|
public AjaxResult getEmotionAnalysis(@PathVariable String categoryId) throws IOException {
|
|
|
|
|
EmotionResult emotionResult = docInfoService.getEmotionAnalysis(categoryId);
|
|
|
|
|
return AjaxResult.success(emotionResult);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导出文章管理列表
|
|
|
|
|
*/
|
|
|
|
|
//@PreAuthorize("@ss.hasPermi('biemo:docInfo:export')")
|
|
|
|
|
@Log(title = "文章管理", businessType = BusinessType.EXPORT)
|
|
|
|
|
@PostMapping("/export")
|
|
|
|
|
public void export(HttpServletResponse response, DocInfo docInfo)
|
|
|
|
|
{
|
|
|
|
|
public void export(HttpServletResponse response, DocInfo docInfo) {
|
|
|
|
|
List<DocInfo> list = docInfoService.selectDocInfoList(docInfo);
|
|
|
|
|
ExcelUtil<DocInfo> util = new ExcelUtil<DocInfo>(DocInfo.class);
|
|
|
|
|
util.exportExcel(response, list, "文章管理数据");
|
|
|
|
@ -128,12 +176,12 @@ public class DocInfoController extends BaseController {
|
|
|
|
|
*/
|
|
|
|
|
//@PreAuthorize("@ss.hasPermi('biemo:docInfo:query')")
|
|
|
|
|
@GetMapping(value = "/{id}")
|
|
|
|
|
public AjaxResult getInfo(@PathVariable("id") String id)
|
|
|
|
|
{
|
|
|
|
|
System.out.println("传入的ID值为=====》"+id);
|
|
|
|
|
public AjaxResult getInfo(@PathVariable("id") String id) {
|
|
|
|
|
System.out.println("传入的ID值为=====》" + id);
|
|
|
|
|
return AjaxResult.success(docInfoService.selectDocInfoById(id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量标注
|
|
|
|
|
*/
|
|
|
|
@ -160,74 +208,74 @@ public class DocInfoController extends BaseController {
|
|
|
|
|
content = MyObjects.delHTMLTag(content);
|
|
|
|
|
content = MyObjects.delSpace(content);
|
|
|
|
|
JSONArray labels = new JSONArray();
|
|
|
|
|
result.put("docInfoId",docInfoId);
|
|
|
|
|
result.put("docInfoId", docInfoId);
|
|
|
|
|
result.put("content", content);
|
|
|
|
|
result.put("connections", new JSONArray());
|
|
|
|
|
result.put("connectionCategories", MyObjects.connectionCategories);
|
|
|
|
|
result.put("labelCategories", MyObjects.labelCategories);
|
|
|
|
|
Sentence sentence = DependencyParserUtils.nerAnalysis(content);
|
|
|
|
|
List<IWord> wordList = sentence.wordList;
|
|
|
|
|
int noun=0;
|
|
|
|
|
int personalName=0;
|
|
|
|
|
int placeName=0;
|
|
|
|
|
int InstitutionalGroup=0;
|
|
|
|
|
int verb=0;
|
|
|
|
|
int adjective=0;
|
|
|
|
|
int adverb=0;
|
|
|
|
|
if(wordList!=null&&wordList.size()>0){
|
|
|
|
|
int noun = 0;
|
|
|
|
|
int personalName = 0;
|
|
|
|
|
int placeName = 0;
|
|
|
|
|
int InstitutionalGroup = 0;
|
|
|
|
|
int verb = 0;
|
|
|
|
|
int adjective = 0;
|
|
|
|
|
int adverb = 0;
|
|
|
|
|
if (wordList != null && wordList.size() > 0) {
|
|
|
|
|
int offset = 0;
|
|
|
|
|
int id = 0;
|
|
|
|
|
for(int i=0;i<wordList.size();i++){
|
|
|
|
|
for (int i = 0; i < wordList.size(); i++) {
|
|
|
|
|
String value = wordList.get(i).getValue();
|
|
|
|
|
String label = wordList.get(i).getLabel();
|
|
|
|
|
if(MyObjects.wordsMapping.get(label)!=null){
|
|
|
|
|
if (MyObjects.wordsMapping.get(label) != null) {
|
|
|
|
|
Integer startIndex = offset;
|
|
|
|
|
Integer endIndex = offset+value.length();
|
|
|
|
|
Integer endIndex = offset + value.length();
|
|
|
|
|
Integer categoryId = MyObjects.wordsMapping.get(label);
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
jsonObject.put("id",id);
|
|
|
|
|
if(categoryId==0){
|
|
|
|
|
jsonObject.put("id", id);
|
|
|
|
|
if (categoryId == 0) {
|
|
|
|
|
noun++;
|
|
|
|
|
}else if(categoryId==1){
|
|
|
|
|
} else if (categoryId == 1) {
|
|
|
|
|
personalName++;
|
|
|
|
|
}else if(categoryId==2){
|
|
|
|
|
} else if (categoryId == 2) {
|
|
|
|
|
placeName++;
|
|
|
|
|
}else if(categoryId==3){
|
|
|
|
|
} else if (categoryId == 3) {
|
|
|
|
|
InstitutionalGroup++;
|
|
|
|
|
}else if(categoryId==4){
|
|
|
|
|
} else if (categoryId == 4) {
|
|
|
|
|
verb++;
|
|
|
|
|
}else if(categoryId==5){
|
|
|
|
|
} else if (categoryId == 5) {
|
|
|
|
|
adjective++;
|
|
|
|
|
}else if(categoryId==6){
|
|
|
|
|
} else if (categoryId == 6) {
|
|
|
|
|
adverb++;
|
|
|
|
|
}
|
|
|
|
|
jsonObject.put("categoryId",categoryId);
|
|
|
|
|
jsonObject.put("startIndex",startIndex);
|
|
|
|
|
jsonObject.put("endIndex",endIndex);
|
|
|
|
|
jsonObject.put("categoryId", categoryId);
|
|
|
|
|
jsonObject.put("startIndex", startIndex);
|
|
|
|
|
jsonObject.put("endIndex", endIndex);
|
|
|
|
|
labels.add(jsonObject);
|
|
|
|
|
}
|
|
|
|
|
offset += value.length();
|
|
|
|
|
id++;
|
|
|
|
|
}
|
|
|
|
|
result.put("labels",labels);
|
|
|
|
|
result.put("labels", labels);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map map=new HashMap();
|
|
|
|
|
map.put("noun",noun);
|
|
|
|
|
map.put("personalName",personalName);
|
|
|
|
|
map.put("placeName",placeName);
|
|
|
|
|
map.put("institutionalGroup",InstitutionalGroup);
|
|
|
|
|
map.put("verb",verb);
|
|
|
|
|
map.put("adjective",adjective);
|
|
|
|
|
map.put("adverb",adverb);
|
|
|
|
|
result.put("partData",map);
|
|
|
|
|
Map map = new HashMap();
|
|
|
|
|
map.put("noun", noun);
|
|
|
|
|
map.put("personalName", personalName);
|
|
|
|
|
map.put("placeName", placeName);
|
|
|
|
|
map.put("institutionalGroup", InstitutionalGroup);
|
|
|
|
|
map.put("verb", verb);
|
|
|
|
|
map.put("adjective", adjective);
|
|
|
|
|
map.put("adverb", adverb);
|
|
|
|
|
result.put("partData", map);
|
|
|
|
|
|
|
|
|
|
//点击词性标注后直接上传 并修改状态
|
|
|
|
|
Query query = new Query(Criteria.where("_id").is(docInfoId));
|
|
|
|
|
Update update = new Update();
|
|
|
|
|
update.set("posTagStatus", "已标注");
|
|
|
|
|
mongoTemplate.upsert(query, update, DocInfo.class);
|
|
|
|
|
return AjaxResult.success("查询成功",result);
|
|
|
|
|
return AjaxResult.success("查询成功", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/getInfoDelHtmlByContent")
|
|
|
|
@ -236,35 +284,35 @@ public class DocInfoController extends BaseController {
|
|
|
|
|
content = MyObjects.delHTMLTag(content);
|
|
|
|
|
content = MyObjects.delSpace(content);
|
|
|
|
|
JSONArray labels = new JSONArray();
|
|
|
|
|
result.put("content",content);
|
|
|
|
|
result.put("connections",new JSONArray());
|
|
|
|
|
result.put("connectionCategories",MyObjects.connectionCategories);
|
|
|
|
|
result.put("labelCategories",MyObjects.labelCategories);
|
|
|
|
|
result.put("content", content);
|
|
|
|
|
result.put("connections", new JSONArray());
|
|
|
|
|
result.put("connectionCategories", MyObjects.connectionCategories);
|
|
|
|
|
result.put("labelCategories", MyObjects.labelCategories);
|
|
|
|
|
Sentence sentence = DependencyParserUtils.nerAnalysis(content);
|
|
|
|
|
List<IWord> wordList = sentence.wordList;
|
|
|
|
|
if(wordList!=null&&wordList.size()>0){
|
|
|
|
|
if (wordList != null && wordList.size() > 0) {
|
|
|
|
|
int offset = 0;
|
|
|
|
|
int id = 0;
|
|
|
|
|
for(int i=0;i<wordList.size();i++){
|
|
|
|
|
for (int i = 0; i < wordList.size(); i++) {
|
|
|
|
|
String value = wordList.get(i).getValue();
|
|
|
|
|
String label = wordList.get(i).getLabel();
|
|
|
|
|
if(MyObjects.wordsMapping.get(label)!=null){
|
|
|
|
|
if (MyObjects.wordsMapping.get(label) != null) {
|
|
|
|
|
Integer startIndex = offset;
|
|
|
|
|
Integer endIndex = offset+value.length();
|
|
|
|
|
Integer endIndex = offset + value.length();
|
|
|
|
|
Integer categoryId = MyObjects.wordsMapping.get(label);
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
jsonObject.put("id",id);
|
|
|
|
|
jsonObject.put("categoryId",categoryId);
|
|
|
|
|
jsonObject.put("startIndex",startIndex);
|
|
|
|
|
jsonObject.put("endIndex",endIndex);
|
|
|
|
|
jsonObject.put("id", id);
|
|
|
|
|
jsonObject.put("categoryId", categoryId);
|
|
|
|
|
jsonObject.put("startIndex", startIndex);
|
|
|
|
|
jsonObject.put("endIndex", endIndex);
|
|
|
|
|
labels.add(jsonObject);
|
|
|
|
|
}
|
|
|
|
|
offset += value.length();
|
|
|
|
|
id++;
|
|
|
|
|
}
|
|
|
|
|
result.put("labels",labels);
|
|
|
|
|
result.put("labels", labels);
|
|
|
|
|
}
|
|
|
|
|
return AjaxResult.success("查询成功",result);
|
|
|
|
|
return AjaxResult.success("查询成功", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/uploadPosTag")
|
|
|
|
@ -273,14 +321,14 @@ public class DocInfoController extends BaseController {
|
|
|
|
|
JSONArray labels = jsonObject.getJSONArray("labels");
|
|
|
|
|
String docInfoId = jsonObject.getString("docInfoId");
|
|
|
|
|
List<IWord> wordList = new ArrayList<>();
|
|
|
|
|
if(labels!=null&&labels.size()>0){
|
|
|
|
|
for(int i=0;i<labels.size();i++){
|
|
|
|
|
Word word = new Word(null,null);
|
|
|
|
|
if (labels != null && labels.size() > 0) {
|
|
|
|
|
for (int i = 0; i < labels.size(); i++) {
|
|
|
|
|
Word word = new Word(null, null);
|
|
|
|
|
JSONObject labelJSONObject = labels.getJSONObject(i);
|
|
|
|
|
Integer startIndex = labelJSONObject.getInteger("startIndex");
|
|
|
|
|
Integer endIndex = labelJSONObject.getInteger("endIndex");
|
|
|
|
|
Integer categoryId = labelJSONObject.getInteger("categoryId");
|
|
|
|
|
String value = content.substring(startIndex,endIndex);
|
|
|
|
|
String value = content.substring(startIndex, endIndex);
|
|
|
|
|
String label = MyObjects.wordsMappingIndex.get(categoryId);
|
|
|
|
|
word.setLabel(label);
|
|
|
|
|
word.setValue(value);
|
|
|
|
@ -300,10 +348,9 @@ public class DocInfoController extends BaseController {
|
|
|
|
|
* 新增文章管理或修改文章
|
|
|
|
|
*/
|
|
|
|
|
//@PreAuthorize("@ss.hasPermi('biemo:docInfo:add')")
|
|
|
|
|
@Log(title = "文章新增", businessType = BusinessType.INSERT)
|
|
|
|
|
// @Log(title = "文章新增", businessType = BusinessType.INSERT)
|
|
|
|
|
@RequestMapping
|
|
|
|
|
public AjaxResult add(@RequestBody DocInfo docInfo)
|
|
|
|
|
{
|
|
|
|
|
public AjaxResult add(@RequestBody DocInfo docInfo) {
|
|
|
|
|
docInfoService.insertOrUpdateDocInfo(docInfo);
|
|
|
|
|
return AjaxResult.success();
|
|
|
|
|
}
|
|
|
|
@ -314,15 +361,14 @@ public class DocInfoController extends BaseController {
|
|
|
|
|
//@PreAuthorize("@ss.hasPermi('biemo:docInfo:remove')")
|
|
|
|
|
@Log(title = "文章删除", businessType = BusinessType.DELETE)
|
|
|
|
|
@DeleteMapping("/{ids}")
|
|
|
|
|
public AjaxResult remove(@PathVariable String[] ids)
|
|
|
|
|
{
|
|
|
|
|
public AjaxResult remove(@PathVariable String[] ids) {
|
|
|
|
|
docInfoService.deleteDocInfoByIds(ids);
|
|
|
|
|
return AjaxResult.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/analysis/{id}")
|
|
|
|
|
public AjaxResult analysis(@PathVariable String id){
|
|
|
|
|
return AjaxResult.success(docInfoService.analysis(id,false));
|
|
|
|
|
public AjaxResult analysis(@PathVariable String id) {
|
|
|
|
|
return AjaxResult.success(docInfoService.analysis(id, false));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -338,29 +384,29 @@ public class DocInfoController extends BaseController {
|
|
|
|
|
|
|
|
|
|
//文章管理--批量分析
|
|
|
|
|
@GetMapping("/batchAnalysis/{ids}")
|
|
|
|
|
public AjaxResult batchAnalysis(@PathVariable String[] ids){
|
|
|
|
|
public AjaxResult batchAnalysis(@PathVariable String[] ids) {
|
|
|
|
|
return AjaxResult.success(docInfoService.batchAnalysis(ids));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//社会网络分析
|
|
|
|
|
@PostMapping("/socialNetworkAnalysis")
|
|
|
|
|
public AjaxResult batchAnalysisByIds(@RequestBody String [] ids) {
|
|
|
|
|
public AjaxResult batchAnalysisByIds(@RequestBody String[] ids) {
|
|
|
|
|
return AjaxResult.success(docInfoService.socialNetworkAnalysis(ids));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/summary/{id}")
|
|
|
|
|
public AjaxResult summary(@PathVariable String id){
|
|
|
|
|
public AjaxResult summary(@PathVariable String id) {
|
|
|
|
|
return AjaxResult.success(docInfoService.summary(id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/handleClassification/{id}")
|
|
|
|
|
public AjaxResult handleClassification(@PathVariable String id){
|
|
|
|
|
public AjaxResult handleClassification(@PathVariable String id) {
|
|
|
|
|
DocInfo docInfo = docInfoService.selectDocInfoById(id);
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
String content = docInfo.getContent();
|
|
|
|
|
content = MyObjects.delHTMLTag(content);
|
|
|
|
|
content = MyObjects.delSpace(content);
|
|
|
|
|
return AjaxResult.success("查询成功",TextClassificationUtils.getClassification(content));
|
|
|
|
|
return AjaxResult.success("查询成功", TextClassificationUtils.getClassification(content));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @PostMapping("/createEsIndex")
|
|
|
|
@ -370,34 +416,34 @@ public class DocInfoController extends BaseController {
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@PostMapping("/splitWordIds")
|
|
|
|
|
public AjaxResult splitWordIds(@RequestBody List<DocInfo> docInfoList){
|
|
|
|
|
public AjaxResult splitWordIds(@RequestBody List<DocInfo> docInfoList) {
|
|
|
|
|
for (int i = 0; i < docInfoList.size(); i++) {
|
|
|
|
|
splitWordDocInfo(docInfoList.get(i));
|
|
|
|
|
}
|
|
|
|
|
return AjaxResult.success("批量分词成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping ("/splitWordStr")
|
|
|
|
|
public AjaxResult splitWordStr(@RequestBody String str){
|
|
|
|
|
Segment segment= HanLP.newSegment();
|
|
|
|
|
@PostMapping("/splitWordStr")
|
|
|
|
|
public AjaxResult splitWordStr(@RequestBody String str) {
|
|
|
|
|
Segment segment = HanLP.newSegment();
|
|
|
|
|
List<Term> termList = segment.seg(str);
|
|
|
|
|
List<String> wordList=new ArrayList<>();
|
|
|
|
|
List<String> wordList = new ArrayList<>();
|
|
|
|
|
for (Term term : termList) {
|
|
|
|
|
String word = term.toString().substring(0, term.length());
|
|
|
|
|
wordList.add(word);
|
|
|
|
|
}
|
|
|
|
|
return AjaxResult.success("分词成功",wordList);
|
|
|
|
|
return AjaxResult.success("分词成功", wordList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping ("/splitWordDocInfo")
|
|
|
|
|
public AjaxResult splitWordDocInfo(@RequestBody DocInfo docInfo){
|
|
|
|
|
if("".equals(docInfo.getContent()) || docInfo.getContent()==null){
|
|
|
|
|
return AjaxResult.error(400,"文章不能为空");
|
|
|
|
|
@PostMapping("/splitWordDocInfo")
|
|
|
|
|
public AjaxResult splitWordDocInfo(@RequestBody DocInfo docInfo) {
|
|
|
|
|
if ("".equals(docInfo.getContent()) || docInfo.getContent() == null) {
|
|
|
|
|
return AjaxResult.error(400, "文章不能为空");
|
|
|
|
|
}
|
|
|
|
|
String title = docInfo.getContent();
|
|
|
|
|
Segment segment= HanLP.newSegment();
|
|
|
|
|
Segment segment = HanLP.newSegment();
|
|
|
|
|
List<Term> termList = segment.seg(title);
|
|
|
|
|
List<String> wordList=new ArrayList<>();
|
|
|
|
|
List<String> wordList = new ArrayList<>();
|
|
|
|
|
//遍历分词结果
|
|
|
|
|
for (Term term : termList) {
|
|
|
|
|
String word = term.toString().substring(0, term.length());
|
|
|
|
@ -406,7 +452,7 @@ public class DocInfoController extends BaseController {
|
|
|
|
|
docInfo.setAnalyzeTitle(wordList);
|
|
|
|
|
List<String> analyzeTitleList = docInfo.getAnalyzeTitle();
|
|
|
|
|
for (int i = 0; i < analyzeTitleList.size(); i++) {
|
|
|
|
|
if(StringUtils.isNotBlank(analyzeTitleList.get(i))){
|
|
|
|
|
if (StringUtils.isNotBlank(analyzeTitleList.get(i))) {
|
|
|
|
|
CustomDictionary.add(analyzeTitleList.get(i));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -414,7 +460,7 @@ public class DocInfoController extends BaseController {
|
|
|
|
|
Update update = new Update();
|
|
|
|
|
update.set("splitWordStatus", "已分词");
|
|
|
|
|
mongoTemplate.upsert(query, update, DocInfo.class);
|
|
|
|
|
return AjaxResult.success("分词成功",docInfo);
|
|
|
|
|
return AjaxResult.success("分词成功", docInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -433,7 +479,7 @@ public class DocInfoController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return AjaxResult.success("分词上传成功");
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return AjaxResult.error("格式不正确");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -443,7 +489,7 @@ public class DocInfoController extends BaseController {
|
|
|
|
|
try {
|
|
|
|
|
List<String> analyzeTitleList = docInfo.getAnalyzeTitle();
|
|
|
|
|
for (int i = 0; i < analyzeTitleList.size(); i++) {
|
|
|
|
|
if(StringUtils.isNotBlank(analyzeTitleList.get(i))){
|
|
|
|
|
if (StringUtils.isNotBlank(analyzeTitleList.get(i))) {
|
|
|
|
|
CustomDictionary.add(analyzeTitleList.get(i));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -452,7 +498,7 @@ public class DocInfoController extends BaseController {
|
|
|
|
|
update.set("splitWordStatus", "已分词");
|
|
|
|
|
mongoTemplate.upsert(query, update, DocInfo.class);
|
|
|
|
|
return AjaxResult.success("分词上传成功");
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return AjaxResult.error("格式不正确");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|