Jelajahi Sumber

1、加密算法增加字符集
2、传入知识图谱数据增加标准术语和词性

louhr 6 tahun lalu
induk
melakukan
3a0e2cf3a7

+ 2 - 0
bigdata-web/src/main/java/org/diagbot/bigdata/work/ParamsDataProxy.java

@@ -194,6 +194,8 @@ public class ParamsDataProxy {
                 } else {
                     searchData.getFilters().put(map.get("feature_name"), map);
                 }
+                map.put("property", String.valueOf(featureMap.get("property")));
+                map.put("concept", String.valueOf(featureMap.get("concept")));
             }
         }
     }

+ 2 - 0
nlp/src/main/java/org/diagbot/nlp/feature/extract/CaseToken.java

@@ -105,6 +105,8 @@ public abstract class CaseToken {
             fMap.put("feature_type", featureType);
             fMap.put("negative", key);
             fMap.put("sn", String.valueOf(sn++));
+            fMap.put("property", lexeme.getProperty());
+            fMap.put("concept", lexeme.getConcept());
             featuresList.add(fMap);
         }
     }

+ 2 - 2
nlp/src/main/java/org/diagbot/nlp/participle/cfg/DefaultConfig.java

@@ -97,9 +97,9 @@ public class DefaultConfig implements Configuration {
                 if (theWord != null && !"".equals(theWord.trim())) {
                     if (i == 5) {
                         logger.info("读取文件第六行解密前:" + theWord.trim());
-                        logger.info("读取文件第六行解密后:" + new String(encrypDES.decryptor(theWord.trim())));
+                        logger.info("读取文件第六行解密后:" + encrypDES.decryptor(theWord.trim()));
                     }
-                    fileContents.add(new String(encrypDES.decryptor(theWord.trim())));
+                    fileContents.add(encrypDES.decryptor(theWord.trim()));
                 }
                 i++;
             } while (theWord != null);

+ 1 - 1
nlp/src/main/resources/push-tc.dict

@@ -2371,7 +2371,7 @@ m69a4x/0L74hGqmV/bsQkQ==
 o+64/6lWlVwbsVzvksU32UvBAr4WBXPTXnxmhPdKEuw=
 smBLYgNa4yz1csFOl7z+mA==
 912O8QwqajrYLVA30XnYOA4mcPdV+/L/B451+nWReBM=
-MioQfYpcsS5MUwH8OdE0LldZqE11ANohg5hJgFXoh/yHvkBDsy1Bug==
+MioQfYpcsS5MUwH8OdE0LldZqE11ANohCrq+ApjNvNM=
 E54guvu04Mc576fFk05fLDgDx8qs11DG
 oGp4lSS5zorXHcaEgjO75KBqeJUkuc6KbLUhJW/WJt4=
 221a9lsaxVFAs/ILVSahm5VGC0afuaicA200GsQgR08=

File diff ditekan karena terlalu besar
+ 609 - 537
nlp/src/main/resources/tc.dict


+ 7 - 6
public/src/main/java/org/diagbot/pub/utils/security/EncrypDES.java

@@ -4,6 +4,7 @@ import org.apache.commons.codec.binary.Base64;
 
 import javax.crypto.*;
 import javax.crypto.spec.DESKeySpec;
+import java.io.UnsupportedEncodingException;
 import java.security.InvalidKeyException;
 import java.security.NoSuchAlgorithmException;
 
@@ -25,7 +26,7 @@ public class EncrypDES {
     private byte[] cipherByte;
 
     public EncrypDES() throws Exception {
-        DESKeySpec desKey = new DESKeySpec(key.getBytes());
+        DESKeySpec desKey = new DESKeySpec(key.getBytes("utf-8"));
         SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
         // 生成密钥
         deskey = keyFactory.generateSecret(desKey);
@@ -43,10 +44,10 @@ public class EncrypDES {
      * @throws BadPaddingException
      */
     public String encrytor(String str) throws InvalidKeyException,
-            IllegalBlockSizeException, BadPaddingException {
+            IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException {
         // 根据密钥,对Cipher对象进行初始化,ENCRYPT_MODE表示加密模式
         c.init(Cipher.ENCRYPT_MODE, deskey);
-        byte[] src = str.getBytes();
+        byte[] src = str.getBytes("utf-8");
         // 加密,结果保存进cipherByte
         cipherByte = c.doFinal(src);
         return Base64.encodeBase64String(cipherByte);
@@ -61,13 +62,13 @@ public class EncrypDES {
      * @throws IllegalBlockSizeException
      * @throws BadPaddingException
      */
-    public byte[] decryptor(String str) throws InvalidKeyException,
-            IllegalBlockSizeException, BadPaddingException {
+    public String decryptor(String str) throws InvalidKeyException,
+            IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException {
         byte[] buff = Base64.decodeBase64(str);
         // 根据密钥,对Cipher对象进行初始化,DECRYPT_MODE表示加密模式
         c.init(Cipher.DECRYPT_MODE, deskey);
         cipherByte = c.doFinal(buff);
-        return cipherByte;
+        return new String(cipherByte, "utf-8");
     }
 }