SharpICTCLAS雖說是開源的
想得到更為准確的分詞結果
先自己寫了個類
代碼
using System;
using System
using System
using System
namespace test
{
[StructLayout(LayoutKind
public struct result_t
{
[FieldOffset(
public int start;
[FieldOffset(
public int length;
[FieldOffset(
public int sPos;
[FieldOffset(
public int sPosLow;
[FieldOffset(
public int POS_id;
[FieldOffset(
public int word_ID;
[FieldOffset(
public int word_type;
[FieldOffset(
public int weight;
}
class ICTCLAS
{
const string path = @
[DllImport(path
public static extern bool Init(String sInitDirPath);
[DllImport(path
public static extern String ParagraphProcess(String sParagraph
[DllImport(path
public static extern bool Exit();
[DllImport(path
public static extern int ImportUserDict(String sFilename);
[DllImport(path
public static extern bool FileProcess(String sSrcFilename
[DllImport(path
public static extern bool FileProcessEx(String sSrcFilename
[DllImport(path
public static extern int GetParagraphProcessAWordCount(String sParagraph);
//ICTCLAS_GetParagraphProcessAWordCount
[DllImport(path
public static extern void ParagraphProcessAW(int nCount
[DllImport(path
public static extern int AddUserWord(String sWord);
[DllImport(path
public static extern int SaveTheUsrDic();
[DllImport(path
static extern int DelUsrWord(String sWord);
public ICTCLAS
{
}
}
}
調用
代碼
if (!ICTCLAS
{
System
return;
}
System
String pResult;
pResult = ICTCLAS
System
ICTCLAS
注
使用的時候把ICTCLAS
如何把pResult搞成昨天博文裡的wordResult格式還是個問題
附上
代碼
using System;
using System
using System
namespace win_csharp
{
[StructLayout(LayoutKind
public struct result_t
{
[FieldOffset(
public int start;
[FieldOffset(
public int length;
[FieldOffset(
public int POS_id;
[FieldOffset(
public int word_ID;
}
/// <summary>
/// Class
/// </summary>
class Class
{
const string path = @
[DllImport(path
public static extern bool ICTCLAS_Init(String sInitDirPath);
[DllImport(path
public static extern String ICTCLAS_ParagraphProcess(String sParagraph
[DllImport(path
public static extern bool ICTCLAS_Exit();
/// <summary>
/// 應用程序的主入口點
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此處添加代碼以啟動應用程序
//
if (!ICTCLAS_Init(null))
{
System
return;
}
System
String pResult;
pResult = ICTCLAS_ParagraphProcess(
System
ICTCLAS_Exit();
}
}
}
參考
From:http://tw.wingwit.com/Article/program/net/201311/12707.html