Commit 5cd291e3 by 石头

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	serverside/cihai-wechat/src/main/java/com/dookay/cihai/wechat/controller/HomeController.java
2 parents 3fbd46dc dec545c2
......@@ -58,7 +58,7 @@ public final class AipWordUtilBean {
private static final String SCORE_KEY_PREFIX = "WORD_SCORE:";
private static final double CRITICAL_VALUE = 0.4D;
private static final double RELATE_CRITICAL_VALUE = 0.6D;
private static final double RELATE_CRITICAL_VALUE = 0.65D;
/**
* 内部错误
......
......@@ -21,6 +21,7 @@ import com.dookay.cihai.core.theme.domain.ThemeDomain;
import com.dookay.cihai.core.theme.query.ThemeQuery;
import com.dookay.cihai.core.theme.service.IThemeService;
import com.dookay.cihai.core.word.domain.WordDomain;
import com.dookay.cihai.core.word.domain.CustomDictionaryDomain;
import com.dookay.cihai.core.word.query.CustomDictionaryQuery;
import com.dookay.cihai.core.word.query.WordQuery;
import com.dookay.cihai.core.word.service.ICustomDictionaryService;
......@@ -35,6 +36,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
/**
* @author 石磊
* @date 2017/12/6
......@@ -78,13 +81,16 @@ public class HomeController extends BaseController {
public JsonResult search(String keyword) {
System.out.println("进入搜索");
String result = null;
CustomDictionaryQuery query1 = new CustomDictionaryQuery();
query1.setWord(keyword);
boolean inDic = false;
List<CustomDictionaryDomain> dictionaryDomainList = customDictionaryService.getList(new CustomDictionaryQuery());
for (CustomDictionaryDomain dic : dictionaryDomainList) {
if (keyword.contains(dic.getWord())) {
result = dic.getWord();
inDic = true;
}
}
try {
int count = customDictionaryService.count(query1);
if (count > 0) {
result = keyword;
} else {
if (!inDic) {
result = aipWordUtilBean.extractQueryKeyword(keyword);
}
ThemeQuery query = new ThemeQuery();
......
......@@ -23,6 +23,7 @@ import com.dookay.cihai.core.theme.domain.ThemeDomain;
import com.dookay.cihai.core.theme.service.IThemeService;
import com.dookay.coral.common.web.controller.BaseController;
import com.dookay.coral.common.web.response.JsonResult;
import com.dookay.coral.common.web.utils.HtmlUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
......@@ -57,8 +58,16 @@ public class ThemeController extends BaseController {
@RequestMapping(value = "/detail/{id}", method = RequestMethod.GET)
public ModelAndView detail(@PathVariable Long id) {
ThemeDomain themeDomain = themeService.get(id);
String document = themeDomain.getIntroduce();
document = HtmlUtils.removeTag(document);
List<WordCount> wordCounts = aipWordUtilBean.extractNounWordsWithCount(document)
.stream().sorted(Comparator.comparing(WordCount::getValue).reversed())
.filter(w -> !w.getLabel().equals(themeDomain.getTitle()))
.limit(10)
.collect(Collectors.toList());
ModelAndView mv = new ModelAndView("portal/theme/detail");
mv.addObject("theme", themeDomain);
mv.addObject("wordCounts", wordCounts);
return mv;
}
......@@ -73,6 +82,7 @@ public class ThemeController extends BaseController {
public JsonResult related(@PathVariable Long id) {
ThemeDomain themeDomain = themeService.get(id);
String document = themeDomain.getIntroduce();
document = HtmlUtils.removeTag(document);
List<WordCount> wordCounts = aipWordUtilBean.extractNounWordsWithCount(document);
List<WordCount> collect = wordCounts.stream().sorted(Comparator.comparingDouble(l -> Math.random())).limit(8).collect(Collectors.toList());
JSONObject result = new JSONObject();
......@@ -92,6 +102,7 @@ public class ThemeController extends BaseController {
public JsonResult map(@PathVariable Long id) {
ThemeDomain themeDomain = themeService.get(id);
String document = themeDomain.getIntroduce();
document = HtmlUtils.removeTag(document);
List<String> keywords = aipWordUtilBean.extractKeyWords(themeDomain.getTitle(), document, 15);
List<WordSequence> wordSequences = keywords.stream().map(l -> new WordSequence(keywords.indexOf(l), l)).collect(Collectors.toList());
List<WordRelation> wordRelations = aipWordUtilBean.generateWordsMap(keywords);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!