|
@@ -83,13 +83,13 @@ public class EntityExtractTest {
|
|
|
|
|
|
if (results_pair.size() > 0) {
|
|
if (results_pair.size() > 0) {
|
|
MysqlJdbc nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/nlp-web?useUnicode=true&characterEncoding=UTF-8");
|
|
MysqlJdbc nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/nlp-web?useUnicode=true&characterEncoding=UTF-8");
|
|
- nlpJdbc.insert(results_pair, "re_tagging_result_part", new String[]{"sentence_id", "sentence_uuid", "sentence", "entity_1_position", "entity_2_position",
|
|
|
|
|
|
+ nlpJdbc.insert(results_pair, "re_tagging_result_compare", new String[]{"sentence_id", "sentence_uuid", "sentence", "entity_1_position", "entity_2_position",
|
|
"entity_1_name", "entity_2_name", "entity_1_prop", "entity_2_prop", "entity_1_prop_name", "entity_2_prop_name", "relation"});
|
|
"entity_1_name", "entity_2_name", "entity_1_prop", "entity_2_prop", "entity_1_prop_name", "entity_2_prop_name", "relation"});
|
|
}
|
|
}
|
|
|
|
|
|
if (results_none_pair.size() > 0) {
|
|
if (results_none_pair.size() > 0) {
|
|
MysqlJdbc nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/nlp-web?useUnicode=true&characterEncoding=UTF-8");
|
|
MysqlJdbc nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/nlp-web?useUnicode=true&characterEncoding=UTF-8");
|
|
- nlpJdbc.insert(results_none_pair, "re_tagging_result_none_part", new String[]{"sentence_id", "sentence_uuid", "sentence", "entity_1_position", "entity_2_position",
|
|
|
|
|
|
+ nlpJdbc.insert(results_none_pair, "re_tagging_result_none_compare", new String[]{"sentence_id", "sentence_uuid", "sentence", "entity_1_position", "entity_2_position",
|
|
"entity_1_name", "entity_2_name", "entity_1_prop", "entity_2_prop", "entity_1_prop_name", "entity_2_prop_name", "relation"});
|
|
"entity_1_name", "entity_2_name", "entity_1_prop", "entity_2_prop", "entity_1_prop_name", "entity_2_prop_name", "relation"});
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -97,6 +97,39 @@ public class EntityExtractTest {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void participleReload() {
|
|
|
|
+ Configuration configuration = new DefaultConfig();
|
|
|
|
+ Segment segment = configuration.loadMainDict("tc.dict");
|
|
|
|
+
|
|
|
|
+ EntityExtractTest entityExtractTest = new EntityExtractTest();
|
|
|
|
+ List<Map<String, String>> data = entityExtractTest.searchData();
|
|
|
|
+
|
|
|
|
+ Map<String, List<String>> pairList = entityExtractTest.searchPropertyPair();
|
|
|
|
+
|
|
|
|
+ Map<String, String> lexiconTypeMap = entityExtractTest.searchLexiconType();
|
|
|
|
+
|
|
|
|
+ String present = "";
|
|
|
|
+ String[] partPresents;
|
|
|
|
+ String sentenceId = "";
|
|
|
|
+ LexemePath<Lexeme> lexemes = null;
|
|
|
|
+ try {
|
|
|
|
+ for (int i = 0; i < data.size(); i++) {
|
|
|
|
+ present = data.get(i).get("xbs");
|
|
|
|
+ present = present.replaceAll("\r\n", "");
|
|
|
|
+ sentenceId = data.get(i).get("zyxh");
|
|
|
|
+ partPresents = present.split(";|;|。");
|
|
|
|
+ for (int k = 0; k < partPresents.length; k++) {
|
|
|
|
+ if (partPresents[k].length() == 0) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
public List<Map<String, String>> searchData() {
|
|
public List<Map<String, String>> searchData() {
|
|
MysqlJdbc nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/nlp-web?useUnicode=true&characterEncoding=UTF-8");
|
|
MysqlJdbc nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/nlp-web?useUnicode=true&characterEncoding=UTF-8");
|
|
List<Map<String, String>> data = nlpJdbc.query("tb_ryjl_extract", new String[]{"zyxh", "xbs"}, " limit 0, 3");
|
|
List<Map<String, String>> data = nlpJdbc.query("tb_ryjl_extract", new String[]{"zyxh", "xbs"}, " limit 0, 3");
|
|
@@ -114,6 +147,32 @@ public class EntityExtractTest {
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public List<Map<String, String>> searchTaggingResult() {
|
|
|
|
+ MysqlJdbc nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/nlp-web?useUnicode=true&characterEncoding=UTF-8");
|
|
|
|
+ List<Map<String, String>> data = nlpJdbc.query("re_tagging_result_part", new String[]{"sentence_id", "sentence_uuid", "sentence", "entity_1_name", "entity_2_name", "entity_1_position", "entity_2_position"}, " order by sentence_id, sentence_uuid");
|
|
|
|
+
|
|
|
|
+ Map<String, List<Map<String, List<Map<String, String>>>>> taggingResults = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ String sentence_id = "";
|
|
|
|
+ String sentence_uuid = "";
|
|
|
|
+
|
|
|
|
+ List<Map<String, List<Map<String, String>>>> sentence_id_list = null;
|
|
|
|
+ Map<String, List<Map<String, String>>> sentence_id_map = null;
|
|
|
|
+ List<Map<String, String>> sentence_uuid_list = null;
|
|
|
|
+ for (Map<String, String> map : data) {
|
|
|
|
+ sentence_id = map.get("sentence_id");
|
|
|
|
+ sentence_uuid = map.get("sentence_uuid");
|
|
|
|
+ if (taggingResults.get(sentence_id) == null) {
|
|
|
|
+ sentence_id_list = new ArrayList<>();
|
|
|
|
+ sentence_uuid_list = new ArrayList<>();
|
|
|
|
+ sentence_uuid_list.add(map);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return data;
|
|
|
|
+ }
|
|
|
|
+
|
|
public Map<String, List<String>> searchPropertyPair() {
|
|
public Map<String, List<String>> searchPropertyPair() {
|
|
MysqlJdbc nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/nlp-web?useUnicode=true&characterEncoding=UTF-8");
|
|
MysqlJdbc nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/nlp-web?useUnicode=true&characterEncoding=UTF-8");
|
|
List<Map<String, String>> data = nlpJdbc.query("re_lexicon_property_pair", new String[]{"prop1_id", "prop2_id"}, " where has_relation = 1");
|
|
List<Map<String, String>> data = nlpJdbc.query("re_lexicon_property_pair", new String[]{"prop1_id", "prop2_id"}, " where has_relation = 1");
|
|
@@ -229,7 +288,7 @@ public class EntityExtractTest {
|
|
|
|
|
|
public static boolean isNumberString(Lexeme l) {
|
|
public static boolean isNumberString(Lexeme l) {
|
|
if (l == null) return false;
|
|
if (l == null) return false;
|
|
- if (isFeature(l.getProperty(), new NegativeEnum[]{NegativeEnum.EVENT_TIME_DESC})) {
|
|
|
|
|
|
+ if (isFeature(l.getProperty(), new NegativeEnum[]{NegativeEnum.NUMBER_QUANTIFIER})) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
for (char c : l.getText().toCharArray()) {
|
|
for (char c : l.getText().toCharArray()) {
|
|
@@ -266,4 +325,80 @@ public class EntityExtractTest {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ class TaggingResult {
|
|
|
|
+ private String sentence_id;
|
|
|
|
+ private String sentence_uuid;
|
|
|
|
+ private String sentence;
|
|
|
|
+ private String entity_1_name;
|
|
|
|
+ private String entity_2_name;
|
|
|
|
+ private String entity_1_position;
|
|
|
|
+ private String entity_2_position;
|
|
|
|
+
|
|
|
|
+ List<TaggingResult> taggingResults = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ public String getSentence_id() {
|
|
|
|
+ return sentence_id;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setSentence_id(String sentence_id) {
|
|
|
|
+ this.sentence_id = sentence_id;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getSentence_uuid() {
|
|
|
|
+ return sentence_uuid;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setSentence_uuid(String sentence_uuid) {
|
|
|
|
+ this.sentence_uuid = sentence_uuid;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getSentence() {
|
|
|
|
+ return sentence;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setSentence(String sentence) {
|
|
|
|
+ this.sentence = sentence;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getEntity_1_name() {
|
|
|
|
+ return entity_1_name;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setEntity_1_name(String entity_1_name) {
|
|
|
|
+ this.entity_1_name = entity_1_name;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getEntity_2_name() {
|
|
|
|
+ return entity_2_name;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setEntity_2_name(String entity_2_name) {
|
|
|
|
+ this.entity_2_name = entity_2_name;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getEntity_1_position() {
|
|
|
|
+ return entity_1_position;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setEntity_1_position(String entity_1_position) {
|
|
|
|
+ this.entity_1_position = entity_1_position;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getEntity_2_position() {
|
|
|
|
+ return entity_2_position;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setEntity_2_position(String entity_2_position) {
|
|
|
|
+ this.entity_2_position = entity_2_position;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public List<TaggingResult> getTaggingResults() {
|
|
|
|
+ return taggingResults;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setTaggingResults(List<TaggingResult> taggingResults) {
|
|
|
|
+ this.taggingResults = taggingResults;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|