|
@@ -55,35 +55,35 @@ public class RelationExtractionModel extends AlgorithmCNNExecutor {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Triad> execute(String content, List<Lemma> lemmas) {
|
|
|
- List<Lemma[]> combinations = new ArrayList<>();
|
|
|
- // 组合
|
|
|
- for(int i=0; i < lemmas.size() - 1; i++){ // 两两组合成实体对
|
|
|
- for (int j = i + 1; j< lemmas.size(); j++){
|
|
|
- Lemma[] pair = new Lemma[2];
|
|
|
- pair[0] = lemmas.get(i);
|
|
|
- pair[1] = lemmas.get(j);
|
|
|
- combinations.add(pair);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- List<Triad> triads = new ArrayList<>();
|
|
|
-
|
|
|
- // 遍历组合
|
|
|
- for (Lemma[] LemmaPair: combinations) {
|
|
|
- int[][] example = dataSet.getExample(content, LemmaPair[0], LemmaPair[1]);
|
|
|
- // 调用模型
|
|
|
- float[][] relation = this.run(example, 1);
|
|
|
-
|
|
|
- if (relation[0][0] < relation[0][1] ){ // 返回有关系的样本
|
|
|
- Triad triad = new Triad();
|
|
|
- triad.setL_1(LemmaPair[0]);
|
|
|
- triad.setL_2(LemmaPair[1]);
|
|
|
- triad.setRelation("有");
|
|
|
- triads.add(triad);
|
|
|
- }
|
|
|
+ public List<Triad> execute(String content, List<Triad> triads) {
|
|
|
+// List<Lemma[]> combinations = new ArrayList<>();
|
|
|
+// // 组合
|
|
|
+// for(int i=0; i < lemmas.size() - 1; i++){ // 两两组合成实体对
|
|
|
+// for (int j = i + 1; j< lemmas.size(); j++){
|
|
|
+// Lemma[] pair = new Lemma[2];
|
|
|
+// pair[0] = lemmas.get(i);
|
|
|
+// pair[1] = lemmas.get(j);
|
|
|
+// combinations.add(pair);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// List<Triad> triads = new ArrayList<>();
|
|
|
|
|
|
- }
|
|
|
+// // 遍历组合
|
|
|
+// for (Lemma[] LemmaPair: combinations) {
|
|
|
+// int[][] example = dataSet.getExample(content, LemmaPair[0], LemmaPair[1]);
|
|
|
+// // 调用模型
|
|
|
+// float[][] relation = this.run(example, 1);
|
|
|
+//
|
|
|
+// if (relation[0][0] < relation[0][1] ){ // 返回有关系的样本
|
|
|
+// Triad triad = new Triad();
|
|
|
+// triad.setL_1(LemmaPair[0]);
|
|
|
+// triad.setL_2(LemmaPair[1]);
|
|
|
+// triad.setRelation("有");
|
|
|
+// triads.add(triad);
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
return triads;
|
|
|
}
|
|
|
|