|
@@ -72,22 +72,16 @@ public class CacheFileManager {
|
|
|
}
|
|
|
|
|
|
//所有词典库 不能用concat_group 大小写不区分
|
|
|
- sql = "select l_1.name l_1_name, l_1.type_id type_id, l_2.name l_2_name, \n" +
|
|
|
- "kc.lib_name, dis.is_chronic, dis.is_infections, group_concat(l_1.name) group_name, l_1.concept_id \n" +
|
|
|
- "from kl_library_info l_1\n" +
|
|
|
- "left join kl_library_info l_2 on l_1.concept_id = l_2.concept_id and l_2.is_concept = 1\n" +
|
|
|
- "left join kl_concept kc on l_1.concept_id = kc.id\n" +
|
|
|
- "left join kl_disease dis on l_1.concept_id = dis.concept_id\n" +
|
|
|
- "where kc.is_deleted = 'N' and l_1.type_id = 18 group by l_1.concept_id";
|
|
|
+ sql = "select dis.name, dis.is_chronic, dis.is_infections, dis.name group_name from kl_disease dis " +
|
|
|
+ "where kc.is_deleted = 'N' order by name";
|
|
|
|
|
|
FileWriter fw = new FileWriter(path + "concept_diag_properties.dict");
|
|
|
rs = st.executeQuery(sql);
|
|
|
while (rs.next()) {
|
|
|
- r1 = rs.getString(4);
|
|
|
- r2 = rs.getString(5);
|
|
|
- r3 = rs.getString(6);
|
|
|
- r4 = rs.getString(7);
|
|
|
- r5 = rs.getString(8);
|
|
|
+ r1 = rs.getString(1);
|
|
|
+ r2 = rs.getString(2);
|
|
|
+ r3 = rs.getString(3);
|
|
|
+ r4 = rs.getString(4);
|
|
|
|
|
|
// r1 = CryptUtil.decrypt_char(r1==null?"":r1);
|
|
|
r1 = r1==null?"":r1;
|
|
@@ -95,7 +89,7 @@ public class CacheFileManager {
|
|
|
r3 = r3==null?"0":r3;
|
|
|
// r4 = CryptUtil.decrypt_char(r4==null?"":r4);
|
|
|
r4 = r4==null?"":r4;
|
|
|
- r5 = map.get(r5) == null ? "" : map.get(r5);
|
|
|
+ r5 = map.get(r1) == null ? "" : map.get(r1);
|
|
|
|
|
|
fw.write(encrypDES.encrytor(r1 + "|" + r2 + "|" + r3 + "|" + r4 + "|" + r5));
|
|
|
fw.write("\n");
|
|
@@ -103,12 +97,7 @@ public class CacheFileManager {
|
|
|
fw.close();
|
|
|
|
|
|
//需要部位的症状信息
|
|
|
- sql = "select l_1.name l_1_name \n" +
|
|
|
- "from kl_library_info l_1\n" +
|
|
|
- "left join kl_library_info l_2 on l_1.concept_id = l_2.concept_id and l_2.is_concept = 1\n" +
|
|
|
- "left join kl_concept kc on l_1.concept_id = kc.id\n" +
|
|
|
- "left join kl_clinic cli on l_1.concept_id = cli.concept_id\n" +
|
|
|
- "where kc.is_deleted = 'N' and l_1.type_id = 1 and cli.has_bodypart = '1' group by l_1.concept_id";
|
|
|
+ sql = "select name from kl_clinic where has_bodypart = '1'";
|
|
|
|
|
|
fw = new FileWriter(path + "concept_clinic_bodypart_properties.dict");
|
|
|
rs = st.executeQuery(sql);
|
|
@@ -123,7 +112,7 @@ public class CacheFileManager {
|
|
|
fw.close();
|
|
|
|
|
|
//性质词典
|
|
|
- sql = "select name from kl_library_info where type_id = 4";
|
|
|
+ sql = "select name from kl_modification where type_id = 4";
|
|
|
fw = new FileWriter(path + "concept_prop.dict");
|
|
|
rs = st.executeQuery(sql);
|
|
|
while (rs.next()) {
|
|
@@ -136,12 +125,38 @@ public class CacheFileManager {
|
|
|
fw.close();
|
|
|
|
|
|
//程度词典
|
|
|
- sql = "select name from kl_library_info where type_id = 6";
|
|
|
+ sql = "select name from kl_modification where type_id = 6";
|
|
|
fw = new FileWriter(path + "concept_degree.dict");
|
|
|
rs = st.executeQuery(sql);
|
|
|
while (rs.next()) {
|
|
|
r1 = rs.getString(1);
|
|
|
r1 = r1==null?"":r1;
|
|
|
+// r1 = CryptUtil.decrypt_char(r1==null?"":r1);
|
|
|
+ fw.write(encrypDES.encrytor(r1));
|
|
|
+ fw.write("\n");
|
|
|
+ }
|
|
|
+ fw.close();
|
|
|
+
|
|
|
+ //加剧词典
|
|
|
+ sql = "select name from kl_modification where type_id = 1";
|
|
|
+ fw = new FileWriter(path + "concept_aggravate.dict");
|
|
|
+ rs = st.executeQuery(sql);
|
|
|
+ while (rs.next()) {
|
|
|
+ r1 = rs.getString(1);
|
|
|
+ r1 = r1==null?"":r1;
|
|
|
+// r1 = CryptUtil.decrypt_char(r1==null?"":r1);
|
|
|
+ fw.write(encrypDES.encrytor(r1));
|
|
|
+ fw.write("\n");
|
|
|
+ }
|
|
|
+ fw.close();
|
|
|
+
|
|
|
+ //缓解词典
|
|
|
+ sql = "select name from kl_modification where type_id = 2";
|
|
|
+ fw = new FileWriter(path + "concept_relief.dict");
|
|
|
+ rs = st.executeQuery(sql);
|
|
|
+ while (rs.next()) {
|
|
|
+ r1 = rs.getString(1);
|
|
|
+ r1 = r1==null?"":r1;
|
|
|
// r1 = CryptUtil.decrypt_char(r1==null?"":r1);
|
|
|
fw.write(encrypDES.encrytor(r1));
|
|
|
fw.write("\n");
|
|
@@ -158,27 +173,22 @@ public class CacheFileManager {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private List<Map.Entry<String, String>> rsToMap(ResultSet rs, boolean isJoin) throws SQLException {
|
|
|
- String r1 = "";
|
|
|
- String r2 = "";
|
|
|
- Map<String, String> libraryMap = new HashMap<>(10);
|
|
|
- while (rs.next()) {
|
|
|
-// r1 = CryptUtil.decrypt_char(rs.getString(1));
|
|
|
-// r2 = CryptUtil.decrypt_char(rs.getString(2));
|
|
|
- if (libraryMap.get(r1) == null) {
|
|
|
- libraryMap.put(r1, r2);
|
|
|
- } else if (isJoin && libraryMap.get(r1) != null) {
|
|
|
- libraryMap.put(r1, libraryMap.get(r1) + "," + r2);
|
|
|
- }
|
|
|
- }
|
|
|
+ public void insertFeature(List<String> record, String tableName, String col) {
|
|
|
+ MysqlJdbc nlpJdbc = new MysqlJdbc(user, password, url);
|
|
|
|
|
|
- List<Map.Entry<String, String>> libraryList = new ArrayList<Map.Entry<String, String>>(libraryMap.entrySet());
|
|
|
- Collections.sort(libraryList, new Comparator<Map.Entry<String, String>>() {
|
|
|
- public int compare(Map.Entry<String, String> o1, Map.Entry<String, String> o2) {
|
|
|
- return o1.getKey().compareTo(o2.getKey());
|
|
|
+ List<String> hasLabelsList = new ArrayList<>();
|
|
|
+ List<Map<String, String>> queryResult = nlpJdbc.query(tableName, new String[]{"name"});
|
|
|
+ for (Map<String, String> map : queryResult) {
|
|
|
+ hasLabelsList.add(map.get(col));
|
|
|
+ }
|
|
|
+ List<Map<String, Object>> data = new ArrayList<>();
|
|
|
+ for (String s : record) {
|
|
|
+ Map<String, Object> obj = new HashMap<>();
|
|
|
+ if (!hasLabelsList.contains(s)) {
|
|
|
+ obj.put(col, s);
|
|
|
+ data.add(obj);
|
|
|
}
|
|
|
- });
|
|
|
-
|
|
|
- return libraryList;
|
|
|
+ }
|
|
|
+ nlpJdbc.insert(data, tableName, new String[]{col});
|
|
|
}
|
|
|
}
|