forked from vector4wang/spring-boot-quick
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathICTCLAS50.java
More file actions
74 lines (67 loc) · 2.55 KB
/
ICTCLAS50.java
File metadata and controls
74 lines (67 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package com.quick.simhash;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.StringTokenizer;
public class ICTCLAS50
{
static {
try {
String libpath = System.getProperty("java.library.path");
String path = null;
StringTokenizer st = new StringTokenizer(libpath, System.getProperty("path.separator"));
if ( st.hasMoreElements() ) {
path = st.nextToken();
}
// copy all dll files to java lib path
File dllFile = null;
InputStream inputStream = null;
FileOutputStream outputStream = null;
byte[] array = null;
dllFile = new File(new File(path), "ICTCLAS50.dll");
if (!dllFile.exists()) {
System.out.println("222" + path);
inputStream = ICTCLAS50.class.getResource("/lib/ICTCLAS50.dll").openStream();
outputStream = new FileOutputStream(dllFile);
array = new byte[1024];
for (int i = inputStream.read(array); i != -1; i = inputStream.read(array)) {
outputStream.write(array, 0, i);
}
outputStream.close();
}
} catch (Exception e) {
e.printStackTrace();
}
try {
// load JniCall.dll
System.loadLibrary("ICTCLAS50");
} catch (Error e) {
e.printStackTrace();
}
}
//public enum eCodeType
//¡¢
// CODE_TYPE_UNKNOWN,//type unknown
// CODE_TYPE_ASCII,//ASCII
// CODE_TYPE_GB,//GB2312,GBK,GB10380
// CODE_TYPE_UTF8,//UTF-8
// CODE_TYPE_BIG5//BIG5
//}
public native boolean ICTCLAS_Init(byte[] sPath);
public native boolean ICTCLAS_Exit();
public native int ICTCLAS_ImportUserDictFile(byte[] sPath,int eCodeType);
public native int ICTCLAS_SaveTheUsrDic();
public native int ICTCLAS_SetPOSmap(int nPOSmap);
public native boolean ICTCLAS_FileProcess(byte[] sSrcFilename, int eCodeType, int bPOSTagged,byte[] sDestFilename);
public native byte[] ICTCLAS_ParagraphProcess(byte[] sSrc, int eCodeType, int bPOSTagged);
public native byte[] nativeProcAPara(byte[] sSrc, int eCodeType, int bPOStagged);
/* Use static intializer */
// static
// {
// String libpath = System.getProperty("java.library.path");
//// //String dir = "D:\\myfc\\javaAPI\\ICTCLAS50.dll";
////// System.loadLibrary("ICTCLAS50");
// System.load(libpath+File.separator+"ICTCLAS50.dll");
//
// }
}