|
@@ -1,19 +1,14 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
import com.diagbot.dto.FeatureConceptDTO;
|
|
|
-import com.diagbot.entity.Concept;
|
|
|
-import com.diagbot.enums.ConceptTypeEnum;
|
|
|
-import com.diagbot.enums.LexiconTypeEnum;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
-import com.diagbot.util.EntityUtil;
|
|
|
import com.diagbot.util.ListUtil;
|
|
|
-import com.google.common.collect.Lists;
|
|
|
+import com.diagbot.util.ParamConvertUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @Description:
|
|
@@ -24,8 +19,6 @@ import java.util.Map;
|
|
|
public class FeatureFacade {
|
|
|
@Autowired
|
|
|
private NLPFacade nlpFacade;
|
|
|
- @Autowired
|
|
|
- private ConceptFacade conceptFacade;
|
|
|
|
|
|
/**
|
|
|
* 症状关键词提取
|
|
@@ -34,33 +27,16 @@ public class FeatureFacade {
|
|
|
* @return
|
|
|
*/
|
|
|
public List<FeatureConceptDTO> getSymptomFeature(String text) {
|
|
|
- List<FeatureConceptDTO> symptomFeatureDTOList = Lists.newLinkedList();
|
|
|
- List<Map<String, Object>> symptomFeatureList = nlpFacade.symptomFeaturePageData(text);
|
|
|
- List<String> symptomNameList = Lists.newLinkedList();
|
|
|
- for (Map<String, Object> symptomFeature : symptomFeatureList) {
|
|
|
- if (symptomFeature != null) {
|
|
|
- String symptomName = symptomFeature.get("feature_name").toString();
|
|
|
- if (!symptomNameList.contains(symptomName) && symptomFeature.get("feature_type").toString().equals("1")) {
|
|
|
- symptomNameList.add(symptomName);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ List<FeatureConceptDTO> symptomFeatureList = nlpFacade.symptomFeaturePageData(text);
|
|
|
if (!ListUtil.isNotEmpty(symptomFeatureList)) {
|
|
|
throw new CommonException(CommonErrorCode.NOT_EXISTS, "未提取到特征词");
|
|
|
}
|
|
|
- List<Concept> concepts = conceptFacade.getListByNamesAndType(symptomNameList, LexiconTypeEnum.SYMPTOM.getKey());
|
|
|
- Map<String, Concept> conceptMap = EntityUtil.makeEntityMap(concepts, "libName");
|
|
|
- for (String name : symptomNameList) {
|
|
|
- FeatureConceptDTO featureConceptDTO = new FeatureConceptDTO();
|
|
|
- featureConceptDTO.setName(name);
|
|
|
- featureConceptDTO.setLibType(LexiconTypeEnum.SYMPTOM.getKey());
|
|
|
- featureConceptDTO.setType(ConceptTypeEnum.Symptom.getKey());
|
|
|
- if (conceptMap.containsKey(name) && conceptMap.get(name) != null) {
|
|
|
- Concept concept = conceptMap.get(name);
|
|
|
- featureConceptDTO.setConceptId(concept.getId());
|
|
|
+
|
|
|
+ for (FeatureConceptDTO featureConceptDTO : symptomFeatureList) {
|
|
|
+ if (null != featureConceptDTO.getLibType()) {
|
|
|
+ featureConceptDTO.setType(ParamConvertUtil.libConvert2Concept(featureConceptDTO.getLibType()));
|
|
|
}
|
|
|
- symptomFeatureDTOList.add(featureConceptDTO);
|
|
|
}
|
|
|
- return symptomFeatureDTOList;
|
|
|
+ return symptomFeatureList;
|
|
|
}
|
|
|
}
|