duhongyu месяцев назад: 8
Родитель
Сommit
f74b33fb15

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

@@ -149,26 +149,32 @@ public class HomeController extends BaseController {
149 149
     @ApiOperation("导出Excel")
150 150
     @Log(title = "导出excel", businessType = BusinessType.EXPORT)
151 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 180
         ExcelHelper<ExcelSentiment> excel = new ExcelHelper<>(ExcelSentiment.class);

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

@@ -62,7 +62,6 @@ public class IvrController extends BaseController {
62 62
         if (ivrService.getCount(qw) > 0) {
63 63
             return Error("此名称已经存在");
64 64
         }
65
-
66 65
         //input.setCreateBy(CurrentUser().getUserName());
67 66
         input.setCreateTime(new Date());
68 67
         input.setDelFlag("0");

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

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

+ 1 - 1
hwzj-service/pom.xml

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

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

@@ -105,13 +105,13 @@ public class QcResultServiceImpl extends BaseServiceImpl<QcResultMapper, QcResul
105 105
        //qw.apply("IFNULL(user_name,'') != ''");
106 106
         qw.apply("IFNULL(file_path,'') != ''");
107 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 112
        // qw.eq(QcResult::getUserName,"8002");
113 113
        // qw.ge (QcResult::getCallid,580);
114
-        qw.orderByDesc(QcResult::getQcId);
114
+        qw.orderByAsc(QcResult::getQcId);
115 115
         PageInput pageInput=new PageInput();
116 116
         pageInput.setPageNum(1);
117 117
         pageInput.setPageSize(100);
@@ -145,7 +145,7 @@ public class QcResultServiceImpl extends BaseServiceImpl<QcResultMapper, QcResul
145 145
                 String FileUrl="";String URL="";
146 146
                 //获取录音路径
147 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 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,13 +1,8 @@
1 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 3
 import api.service.call.ITranslateService;
8 4
 import api.service.patient.ILabelService;
9 5
 import api.service.quality.IQualityModelService;
10
-
11 6
 import opennlp.tools.doccat.*;
12 7
 import opennlp.tools.tokenize.SimpleTokenizer;
13 8
 import opennlp.tools.util.CollectionObjectStream;
@@ -15,14 +10,30 @@ import opennlp.tools.util.ObjectStream;
15 10
 import opennlp.tools.util.model.ModelUtil;
16 11
 import org.apache.poi.ss.usermodel.*;
17 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 27
 import org.springframework.beans.factory.annotation.Autowired;
21 28
 import org.springframework.stereotype.Service;
22 29
 import org.springframework.transaction.annotation.Transactional;
23 30
 import java.io.*;
24 31
 import java.util.*;
25 32
 
33
+
34
+
35
+
36
+
26 37
 @Transactional
27 38
 @Service
28 39
 public class QualityModelServiceImpl implements IQualityModelService {
@@ -58,7 +69,7 @@ public class QualityModelServiceImpl implements IQualityModelService {
58 69
             );
59 70
             // 3. 训练模型
60 71
             DoccatModel model = DocumentCategorizerME.train(
61
-                    "en",
72
+                    "zh",
62 73
                     sampleStream,
63 74
                     ModelUtil.createDefaultTrainingParameters(),
64 75
                     factory
@@ -80,7 +91,14 @@ public class QualityModelServiceImpl implements IQualityModelService {
80 91
     @Override
81 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 103
     private String GetSentiment(String text) {
86 104
         try {
@@ -103,6 +121,13 @@ public class QualityModelServiceImpl implements IQualityModelService {
103 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 132
     private static List<DocumentSample> loadExcelData(String filePath) {
108 133
         List<DocumentSample> samples = new ArrayList<>();
@@ -150,21 +175,6 @@ public class QualityModelServiceImpl implements IQualityModelService {
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
 

BIN
sentiment_model.bin