duhongyu 8 月之前
父節點
當前提交
f74b33fb15

+ 23 - 17
hwzj-api/src/main/java/api/controller/HomeController.java

149
     @ApiOperation("导出Excel")
149
     @ApiOperation("导出Excel")
150
     @Log(title = "导出excel", businessType = BusinessType.EXPORT)
150
     @Log(title = "导出excel", businessType = BusinessType.EXPORT)
151
     @PostMapping("/excelSentiment")
151
     @PostMapping("/excelSentiment")
152
-    public  void  excelSentiment()  {
153
-
154
-        LambdaQueryWrapper<Label> lambdaQueryWrapper=new LambdaQueryWrapper<>();
155
-        lambdaQueryWrapper.ge(Label::getLabelId,16);
156
-        var list=labelService.getList(lambdaQueryWrapper);
157
-        List<ExcelSentiment> sentiments=new ArrayList<>();
158
-        if (list!=null&&list.size()>0)
152
+    public  void  excelSentiment() throws JsonProcessingException {
153
+        var mobile=translateService.getList();
154
+       List<ExcelSentiment> sentiments=new ArrayList<>();
155
+        if (mobile!=null&&mobile.size()>0)
159
         {
156
         {
160
-            for(Label item:list)
157
+            ObjectMapper mapper = new ObjectMapper();
158
+            for(Translate item:mobile)
161
             {
159
             {
162
-                ExcelSentiment excelSentiment=new ExcelSentiment();
163
-                excelSentiment.setContent(item.getLabelName());
164
-                if (item.getPatientCount() == 0L) {
165
-                    excelSentiment.setSeat("消极");
166
-                } else if (item.getPatientCount() == 2L) {
167
-                    excelSentiment.setSeat("积极");
168
-                } else {
169
-                    excelSentiment.setSeat("中立");
160
+                if(StringHelper.isNotEmpty(item.getTranslate()))
161
+                {
162
+                    RepTranslate [] translate = mapper.readValue(item.getTranslate(), RepTranslate[].class);
163
+                    for (RepTranslate iv :translate)
164
+                    {
165
+                        if(iv.getSpeech().length()>10&&iv.getNumber().length()<=4)
166
+                        {
167
+                            if(Objects.equals(modelService.OpenNLPDetection(iv.getSpeech()), "消极"))
168
+                            {
169
+                                ExcelSentiment excelSentiment=new ExcelSentiment();
170
+                                excelSentiment.setContent(iv.getSpeech());
171
+                                excelSentiment.setSeat("消极");
172
+                                sentiments.add(excelSentiment);
173
+                            }
174
+                        }
175
+                    }
170
                 }
176
                 }
171
-                sentiments.add(excelSentiment);
177
+
172
             }
178
             }
173
         }
179
         }
174
         ExcelHelper<ExcelSentiment> excel = new ExcelHelper<>(ExcelSentiment.class);
180
         ExcelHelper<ExcelSentiment> excel = new ExcelHelper<>(ExcelSentiment.class);

+ 0 - 1
hwzj-api/src/main/java/api/controller/call/IvrController.java

62
         if (ivrService.getCount(qw) > 0) {
62
         if (ivrService.getCount(qw) > 0) {
63
             return Error("此名称已经存在");
63
             return Error("此名称已经存在");
64
         }
64
         }
65
-
66
         //input.setCreateBy(CurrentUser().getUserName());
65
         //input.setCreateBy(CurrentUser().getUserName());
67
         input.setCreateTime(new Date());
66
         input.setCreateTime(new Date());
68
         input.setDelFlag("0");
67
         input.setDelFlag("0");

+ 2 - 2
hwzj-api/src/main/resources/application.yml

3
     date-format: yyyy-MM-dd HH:mm:ss
3
     date-format: yyyy-MM-dd HH:mm:ss
4
     time-zone: GMT+8
4
     time-zone: GMT+8
5
   profiles:
5
   profiles:
6
-    active: production
7
-    #active: dev
6
+    #active: production
7
+    active: dev
8
   servlet:
8
   servlet:
9
     multipart:
9
     multipart:
10
       max-file-size: 20MB #单个文件最大为20M
10
       max-file-size: 20MB #单个文件最大为20M

+ 1 - 1
hwzj-service/pom.xml

47
             <artifactId>opennlp-tools</artifactId>
47
             <artifactId>opennlp-tools</artifactId>
48
             <version>1.9.3</version>
48
             <version>1.9.3</version>
49
         </dependency>
49
         </dependency>
50
-
50
+    
51
 
51
 
52
 
52
 
53
     </dependencies>
53
     </dependencies>

+ 6 - 6
hwzj-service/src/main/java/api/service/quality/impl/QcResultServiceImpl.java

105
        //qw.apply("IFNULL(user_name,'') != ''");
105
        //qw.apply("IFNULL(user_name,'') != ''");
106
         qw.apply("IFNULL(file_path,'') != ''");
106
         qw.apply("IFNULL(file_path,'') != ''");
107
          qw.eq(QcResult::getIsQuality,0);
107
          qw.eq(QcResult::getIsQuality,0);
108
-         if (!Objects.equals(callId, ""))
109
-         {
110
-             qw.eq(QcResult::getCallid,callId);
111
-         }
108
+//         if (!Objects.equals(callId, ""))
109
+//         {
110
+//             qw.eq(QcResult::getCallid,callId);
111
+//         }
112
        // qw.eq(QcResult::getUserName,"8002");
112
        // qw.eq(QcResult::getUserName,"8002");
113
        // qw.ge (QcResult::getCallid,580);
113
        // qw.ge (QcResult::getCallid,580);
114
-        qw.orderByDesc(QcResult::getQcId);
114
+        qw.orderByAsc(QcResult::getQcId);
115
         PageInput pageInput=new PageInput();
115
         PageInput pageInput=new PageInput();
116
         pageInput.setPageNum(1);
116
         pageInput.setPageNum(1);
117
         pageInput.setPageSize(100);
117
         pageInput.setPageSize(100);
145
                 String FileUrl="";String URL="";
145
                 String FileUrl="";String URL="";
146
                 //获取录音路径
146
                 //获取录音路径
147
                 if (!StringHelper.isEmpty(call.getFilePath())) {
147
                 if (!StringHelper.isEmpty(call.getFilePath())) {
148
-                    URL="http://10.0.0.3:9000/"+call.getFilePath();
148
+                    URL="http://1.194.161.64:9000/"+call.getFilePath();
149
                     FileUrl= downloadFile(URL,"files/luYin/"+ DateHelper.getDate());
149
                     FileUrl= downloadFile(URL,"files/luYin/"+ DateHelper.getDate());
150
                 }
150
                 }
151
 
151
 

+ 34 - 24
hwzj-service/src/main/java/api/service/quality/impl/QualityModelServiceImpl.java

1
 package api.service.quality.impl;
1
 package api.service.quality.impl;
2
-
3
-import api.entity.database.call.Translate;
4
-import api.entity.database.patient.Label;
5
-import api.entity.input.quality.RepTranslate;
6
-import api.entity.view.quality.ExcelSentiment;
2
+import api.entity.view.quality.TextSample;
7
 import api.service.call.ITranslateService;
3
 import api.service.call.ITranslateService;
8
 import api.service.patient.ILabelService;
4
 import api.service.patient.ILabelService;
9
 import api.service.quality.IQualityModelService;
5
 import api.service.quality.IQualityModelService;
10
-
11
 import opennlp.tools.doccat.*;
6
 import opennlp.tools.doccat.*;
12
 import opennlp.tools.tokenize.SimpleTokenizer;
7
 import opennlp.tools.tokenize.SimpleTokenizer;
13
 import opennlp.tools.util.CollectionObjectStream;
8
 import opennlp.tools.util.CollectionObjectStream;
15
 import opennlp.tools.util.model.ModelUtil;
10
 import opennlp.tools.util.model.ModelUtil;
16
 import org.apache.poi.ss.usermodel.*;
11
 import org.apache.poi.ss.usermodel.*;
17
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
12
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
18
-import org.apache.sis.util.resources.Vocabulary;
19
 
13
 
14
+import org.deeplearning4j.datasets.datavec.RecordReaderDataSetIterator;
15
+import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
16
+import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
17
+import org.deeplearning4j.nn.conf.layers.EmbeddingLayer;
18
+import org.deeplearning4j.nn.conf.layers.LSTM;
19
+import org.deeplearning4j.nn.conf.layers.RnnOutputLayer;
20
+import org.deeplearning4j.nn.weights.WeightInit;
21
+import org.nd4j.evaluation.classification.Evaluation;
22
+import org.nd4j.linalg.activations.Activation;
23
+
24
+import org.nd4j.linalg.dataset.api.iterator.DataSetIterator;
25
+import org.nd4j.linalg.learning.config.Adam;
26
+import org.nd4j.linalg.lossfunctions.LossFunctions;
20
 import org.springframework.beans.factory.annotation.Autowired;
27
 import org.springframework.beans.factory.annotation.Autowired;
21
 import org.springframework.stereotype.Service;
28
 import org.springframework.stereotype.Service;
22
 import org.springframework.transaction.annotation.Transactional;
29
 import org.springframework.transaction.annotation.Transactional;
23
 import java.io.*;
30
 import java.io.*;
24
 import java.util.*;
31
 import java.util.*;
25
 
32
 
33
+
34
+
35
+
36
+
26
 @Transactional
37
 @Transactional
27
 @Service
38
 @Service
28
 public class QualityModelServiceImpl implements IQualityModelService {
39
 public class QualityModelServiceImpl implements IQualityModelService {
58
             );
69
             );
59
             // 3. 训练模型
70
             // 3. 训练模型
60
             DoccatModel model = DocumentCategorizerME.train(
71
             DoccatModel model = DocumentCategorizerME.train(
61
-                    "en",
72
+                    "zh",
62
                     sampleStream,
73
                     sampleStream,
63
                     ModelUtil.createDefaultTrainingParameters(),
74
                     ModelUtil.createDefaultTrainingParameters(),
64
                     factory
75
                     factory
80
     @Override
91
     @Override
81
     public  String OpenNLPDetection(String text)
92
     public  String OpenNLPDetection(String text)
82
     {
93
     {
83
-        return  GetSentiment(text);
94
+        if(isNumeric(text))
95
+        {
96
+            return "中立";
97
+        }
98
+        else
99
+        {
100
+            return  GetSentiment(text);
101
+        }
84
     }
102
     }
85
     private String GetSentiment(String text) {
103
     private String GetSentiment(String text) {
86
         try {
104
         try {
103
             return e.getMessage();
121
             return e.getMessage();
104
         }
122
         }
105
     }
123
     }
124
+    //判断是否为纯数字
125
+    public boolean isNumeric(String str) {
126
+        if (str == null || str.isEmpty()) {
127
+            return false;
128
+        }
129
+        return str.matches("[0-9]+");  // 匹配1个或多个数字
130
+    }
106
 
131
 
107
     private static List<DocumentSample> loadExcelData(String filePath) {
132
     private static List<DocumentSample> loadExcelData(String filePath) {
108
         List<DocumentSample> samples = new ArrayList<>();
133
         List<DocumentSample> samples = new ArrayList<>();
150
 
175
 
151
 
176
 
152
 
177
 
153
-    // 文本向量化方法(需与训练时完全一致)
154
-    private double[] vectorizeText1(String text) {
155
-        // 此处应实现与训练一致的向量化逻辑
156
-        // 示例:简单词频统计(需替换为实际处理逻辑)
157
-        double[] features = new double[100];
158
-        String[] words = text.toLowerCase().split("\\s+");
159
-        for (String word : words) {
160
-            int index = Math.abs(word.hashCode()) % 100;
161
-            features[index] += 1.0;
162
-        }
163
-        return features;
164
-    }
165
-
166
-
167
-
168
 
178
 
169
 
179
 
170
 
180
 

二進制
sentiment_model.bin