Skip to content
Snippets Groups Projects
Commit db8e0b92 authored by 家乐 袁's avatar 家乐 袁
Browse files

Merge branch '201250084' into 'master'

更新了dataminging部分的接口

See merge request 0010-qingyun/backend!26
parents 945884ae 7e5c4d64
No related branches found
Tags v1.0.44
No related merge requests found
Pipeline #63837 passed
No preview for this file type
......@@ -22,7 +22,7 @@
<artifactId>sentistrength_backend</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/sentiStrength-v1.0.25.jar</systemPath>
<systemPath>${project.basedir}/lib/sentiStrength-v1.0.26.jar</systemPath>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
......
package com.sentistrength.model.vo.dataMining;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class ResultAndSummaryFileReturnVO {
/**
* 类成员变量 resultFile String类型List
* 结果文件
*/
private List<String> resultFile;
/**
* 类成员变量summaryFile String类型List
* 总结文件
*/
private List<String> summaryFile;
}
......@@ -79,16 +79,15 @@ public class DataMiningServiceImpl implements DataMiningService {
@Override
public List<String> removeDataColumn(RemoveDataColumnVO removeDataColumnVO) {
List<String> outFile;
List<String> inFile = handleList(removeDataColumnVO.getInFile());
List<String> inFile = removeDataColumnVO.getInFile();
if (inFile.size() == 0) {
throw new MyServiceException("DS001", "Arff文件为空");
}
try {
outFile = uk.ac.wlv.wkaclass.Arff.deleteColumnFromArff(inFile, removeDataColumnVO.getColToRemove());
}catch (Exception e){
throw new MyServiceException("DS004", "Arff文件某一列删除出错");
}catch (Exception e) {
throw new MyServiceException("DS004", "Arff文件删除出错");
}
return outFile;
}
......@@ -101,7 +100,7 @@ public class DataMiningServiceImpl implements DataMiningService {
@Override
public List<String> moveColumn(MoveColumnVO moveColumnVO) {
List<String> outFile;
List<String> inFile = handleList(moveColumnVO.getInFile());
List<String> inFile = moveColumnVO.getInFile();
if (inFile.size() == 0) {
throw new MyServiceException("DS001", "Arff文件为空");
}
......@@ -122,7 +121,7 @@ public class DataMiningServiceImpl implements DataMiningService {
@Override
public List<String> deleteColAndMove(DeleteColAndMoveVO deleteColAndMoveVO) {
List<String> outFile;
List<String> inFile = handleList(deleteColAndMoveVO.getInFile());
List<String> inFile = deleteColAndMoveVO.getInFile();
if (inFile.size() == 0) {
throw new MyServiceException("DS001", "Arff文件为空");
}
......@@ -142,7 +141,7 @@ public class DataMiningServiceImpl implements DataMiningService {
*/
@Override
public List<Double> calculateInformationGain(CalculateInformationGainFileVO calculateInformationGainFileVO) {
List<String> inFile = handleList(calculateInformationGainFileVO.getInFile());
List<String> inFile = calculateInformationGainFileVO.getInFile();
if (inFile.size() == 0) {
throw new MyServiceException("DS001", "Arff文件为空");
}
......@@ -168,9 +167,9 @@ public class DataMiningServiceImpl implements DataMiningService {
* @return List<String> 生成结果文件若干行
*/
@Override
public Map<List<String>, List<String>> selectTopNFeatures(SelectTopNFeaturesVO selectTopNFeaturesVO) {
public ResultAndSummaryFileReturnVO selectTopNFeatures(SelectTopNFeaturesVO selectTopNFeaturesVO) {
Map<List<String>, List<String>> outFile;
List<String> inFile = handleList(selectTopNFeaturesVO.getInFile());
List<String> inFile = selectTopNFeaturesVO.getInFile();
if (inFile.size() == 0) {
throw new MyServiceException("DS001", "Arff文件为空");
}
......@@ -179,7 +178,11 @@ public class DataMiningServiceImpl implements DataMiningService {
} catch (Exception e) {
throw new MyServiceException("DS008", "用信息增益最高的N个Attributes新建Arff文件出错");
}
return outFile;
ResultAndSummaryFileReturnVO resultAndSummaryFileReturnVO = null;
for(Map.Entry<List<String>, List<String>> entry : outFile.entrySet()){
resultAndSummaryFileReturnVO = new ResultAndSummaryFileReturnVO(entry.getKey(),entry.getValue());
}
return resultAndSummaryFileReturnVO;
}
/**
......@@ -203,11 +206,11 @@ public class DataMiningServiceImpl implements DataMiningService {
@Override
public List<String> mergeLabelledAndUnlabelled(MergeLabelledAndUnlabelledVO mergeLabelledAndUnlabelledVO) {
List<String> outFile;
List<String> labelledFile = handleList(mergeLabelledAndUnlabelledVO.getLabelledFile());
List<String> labelledFile = mergeLabelledAndUnlabelledVO.getLabelledFile();
if (labelledFile.size() == 0) {
throw new MyServiceException("DS001", "Arff文件为空");
}
List<String> unlabelledFile = handleList(mergeLabelledAndUnlabelledVO.getUnlabelledFile());
List<String> unlabelledFile = mergeLabelledAndUnlabelledVO.getUnlabelledFile();
if (unlabelledFile.size() == 0) {
throw new MyServiceException("DS001", "Arff文件为空");
}
......@@ -219,21 +222,6 @@ public class DataMiningServiceImpl implements DataMiningService {
return outFile;
}
/**
* 删除arff文件中的空行
*
* @param inFile 输入的Arff文件若干行
* @return List<String> 删除后的Arff文件若干行
*/
public List<String> handleList(List<String> inFile) {
for (int i = 0; i < inFile.size(); i++) {
if (inFile.get(i).equals("")) {
inFile.remove(i);
i--;
}
}
return inFile;
}
/**
* 根据训练集和分类器预测未标记文件
......@@ -259,14 +247,18 @@ public class DataMiningServiceImpl implements DataMiningService {
* @return Map<List < String>,List<String>> 结果文件和总结文件
*/
@Override
public Map<List<String>, List<String>> directClassifyAllArff(DirectClassifyAllArffVO directClassifyAllArffVO) {
public ResultAndSummaryFileReturnVO directClassifyAllArff(DirectClassifyAllArffVO directClassifyAllArffVO) {
Map<List<String>, List<String>> outFile;
try {
outFile = uk.ac.wlv.wkaclass.WekaDirectTrainClassifyEvaluate.directClassifyAllArff(directClassifyAllArffVO.getTrainFileName(), directClassifyAllArffVO.getTrainFile(), directClassifyAllArffVO.getEvalFile(), directClassifyAllArffVO.getClassifierName(), directClassifyAllArffVO.getClassifierExclude());
} catch (Exception e) {
throw new MyServiceException("DS011", "根据输入的训练文件和测试文件训练分类器并测试出错");
}
return outFile;
ResultAndSummaryFileReturnVO resultAndSummaryFileReturnVO = null;
for (Map.Entry<List<String>, List<String>> entry : outFile.entrySet()){
resultAndSummaryFileReturnVO = new ResultAndSummaryFileReturnVO(entry.getKey(), entry.getValue());
}
return resultAndSummaryFileReturnVO;
}
/**
......@@ -276,7 +268,7 @@ public class DataMiningServiceImpl implements DataMiningService {
* @return Map<List < String>, List<String>> 生成的结果和总结文件
*/
@Override
public Map<List<String>, List<String>> classifyAllArff(ClassifyAllArffVO classifyAllArffVO) {
public ResultAndSummaryFileReturnVO classifyAllArff(ClassifyAllArffVO classifyAllArffVO) {
Map<List<String>, List<String>> outFile;
Random random = new Random();
int randomSeed = random.nextInt();
......@@ -285,7 +277,11 @@ public class DataMiningServiceImpl implements DataMiningService {
} catch (Exception e) {
throw new MyServiceException("DS012", "有选择的信息增益交叉验证出错");
}
return outFile;
ResultAndSummaryFileReturnVO resultAndSummaryFileReturnVO = null;
for(Map.Entry<List<String>, List<String>> entry : outFile.entrySet()){
resultAndSummaryFileReturnVO = new ResultAndSummaryFileReturnVO(entry.getKey(), entry.getValue());
}
return resultAndSummaryFileReturnVO;
}
/**
......@@ -295,7 +291,7 @@ public class DataMiningServiceImpl implements DataMiningService {
* @return Map<List < String>, List<String>> 生成的结果和总结文件
*/
@Override
public Map<List<String>, List<String>> classifyAllArffWithoutSelection(ClassifyAllArffWithoutSelectionVO classifyAllArffWithoutSelectionVO) {
public ResultAndSummaryFileReturnVO classifyAllArffWithoutSelection(ClassifyAllArffWithoutSelectionVO classifyAllArffWithoutSelectionVO) {
Map<List<String>, List<String>> outFile;
Random random = new Random();
int randomSeed = random.nextInt();
......@@ -304,6 +300,10 @@ public class DataMiningServiceImpl implements DataMiningService {
} catch (Exception e) {
throw new MyServiceException("DS013", "无选择的信息增益交叉验证出错");
}
return outFile;
ResultAndSummaryFileReturnVO resultAndSummaryFileReturnVO = null;
for(Map.Entry<List<String>, List<String>> entry : outFile.entrySet()){
resultAndSummaryFileReturnVO = new ResultAndSummaryFileReturnVO(entry.getKey(), entry.getValue());
}
return resultAndSummaryFileReturnVO;
}
}
......@@ -61,7 +61,7 @@ public interface DataMiningService {
* @param selectTopNFeaturesVO 选择topN特征VO
* @return List<String> 生成结果文件若干行
*/
Map<List<String>, List<String>> selectTopNFeatures(SelectTopNFeaturesVO selectTopNFeaturesVO);
ResultAndSummaryFileReturnVO selectTopNFeatures(SelectTopNFeaturesVO selectTopNFeaturesVO);
/**
* 设置配置
......@@ -92,7 +92,7 @@ public interface DataMiningService {
* @param directClassifyAllArffVO 据输入的训练文件和测试文件训练分类器并测试VO
* @return 生成的结果文件和测试文件
*/
Map<List<String>, List<String>> directClassifyAllArff(DirectClassifyAllArffVO directClassifyAllArffVO);
ResultAndSummaryFileReturnVO directClassifyAllArff(DirectClassifyAllArffVO directClassifyAllArffVO);
/**
* 有选择的信息增益交叉验证
......@@ -100,7 +100,7 @@ public interface DataMiningService {
* @param classifyAllArffVO 有选择的信息增益交叉验证VO
* @return Map<List < String>, List<String>> 生成的结果和总结文件
*/
Map<List<String>, List<String>> classifyAllArff(ClassifyAllArffVO classifyAllArffVO);
ResultAndSummaryFileReturnVO classifyAllArff(ClassifyAllArffVO classifyAllArffVO);
/**
* 无选择的信息增益交叉验证
......@@ -108,5 +108,5 @@ public interface DataMiningService {
* @param classifyAllArffWithoutSelectionVO 无选择的信息增益交叉验证VO
* @return Map<List < String>, List<String>> 生成的结果和总结文件
*/
Map<List<String>, List<String>> classifyAllArffWithoutSelection(ClassifyAllArffWithoutSelectionVO classifyAllArffWithoutSelectionVO);
ResultAndSummaryFileReturnVO classifyAllArffWithoutSelection(ClassifyAllArffWithoutSelectionVO classifyAllArffWithoutSelectionVO);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment