Git Product home page Git Product logo

ictclas4j's Introduction

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>1</title>
</head>

<body bgcolor="#99CCFF">

<table border="1" width="100%">
  <tr>
    <td width="100%"><b><font size="6" color="#0000FF">ICTCLAS4J中文分词系统使用说明</font></b></td>
  </tr>
  <tr>
    <td width="100%">
      <p style="line-height: 200%"><font size="4">1.ictclas4j是在中科院开源分词系统<a href="http://www.i3s.ac.cn">FreeICTCLAS</a>的基础上重新实现和改进而来<br>
      2.任何人不得将此用于商业用途,仅限个人学习研究之用<br>
      3.该分词程序的最终解释权张新波(sinboy)和中科院张华平所有<br>
      4.对使用中遇到的问题,请到<a href="http://groups.google.com/group/ictclas">ictclas论坛组</a>内交流<br>
      5.也可直接Email给我:[email protected]</font></td>
  </tr>
</table>

<p></p>
<table border="1" width="100%">
  <tr>
    <td width="100%"><b><font size="6" color="#0000FF">ICTCLAS4J大事记&nbsp; </font></b>2007-06-04</td>
  </tr>
  <tr>
    <td width="100%">
      <div>
        <p style="line-height: 200%">&nbsp;&nbsp;&nbsp;&nbsp; FreeICTCLAS中文分词系统从2006年3月就开始接触<WBR>
        ,之后通过研读相关论文和源代码,写了一系列的学习笔记<WBR>
        ,给很多同样的中文分词爱好者提供了一个可参考的文档资料<WBR>
        。但因为工作及其它原因(嘿嘿,说白就了就是比较偷懒<WBR>
        ,没有坚持下去),把该项目做成一个java版的原始想法一度中断<WBR>
        。之后,也曾多次尝试重新拾起,完成我的一个心愿<WBR>
        ,但复杂的工作都让我半途而费。
      </div>
      <div>
        <p style="line-height: 200%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4月份的时候,一个爱好才MSN上问我相关问题<WBR>
        ,又激起了我的原始想法,同时看到吕震宇老师只用了半个月的时间就<WBR>
        完成了C#版本的工作,并且写了完成的系列文章,又大大刺激我的神<WBR>
        经。想想我的系列文章只到半道,ictclas4j的程序也是半拉<WBR>
        子工程,真是惭愧之极。于是下定决定,一定要把这个项目完成<WBR>
        ,给自己也给关心ictclas的朋友一个交待。
      </div>
      <div>
        <p style="line-height: 200%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
        经过三个星期的不懈努力,到现在为止,基本上完整的实现了原Fre<WBR>
        eICTCLAS所实现的功能。原VC++实现的程序比我想象的更<WBR>
        复杂,中间涉及大量的临时性的数据结构和大量的全局变量<WBR>
        ,搞的我非常头大,好几次都有放弃的想法。不过谢天谢地<WBR>
        ,我这次终于坚持下来了。从java程序的角度从出<WBR>
        ,我对原来的数据结构做了大量调整和优化,去掉了很多不必要的中间<WBR>
        变量。经过优化后,在整个分词过后中只用到两个对象:Atom<WBR>
        、SegNode,原子和分词结点,整个分词过程就是对SegNo<WBR>
        de的不断调整和改进,最终得到分词结果。
      </div>
      <div>
        <p style="line-height: 200%">&nbsp;&nbsp;&nbsp;&nbsp; 
        因为到现在为止,我只是做了一些简单的测试,可能还有很多的BUG<WBR>
        在里面(对标点符号的处理就是一问题),并且分词的速度还远远达不<WBR>
        到我的要求,程序还有很多改进的地方,所以暂时源代码还不会放上来<WBR>
        ,但我想最迟一个星期之内,我可以上传到论坛供大家测试。同时<WBR>
        ,我已在Google Code上申请了ictclas4j的开源项目,期望有兴趣的朋友<WBR>
        加入进来共同改进。
      </div>
      <div>
        <p style="line-height: 200%">&nbsp;&nbsp;&nbsp;&nbsp; 
        附近中的文件是ictclas4j程序在分词过程输出的完整分词步<WBR>
        骤记录,对大家直观理解该分词原是应该是一个有益的帮助<WBR>
        。这个想法也得益于吕震宇的SharpICTCLAS<WBR>
        ,在此表示感谢!同时感谢DanceFire的几篇精辟入理的分析<WBR>
        文章,给了我很大的帮助。
      </div>
      <p> </td>
  </tr>
</table>

</body>

</html>

ictclas4j's People

Contributors

jpz6311whu avatar

Watchers

 avatar

ictclas4j's Issues

UTF-8编码造成分词不正确的问题

 我用0.9.1版本在eclipse下试了一下,用的UTF-8编码源代码,但分词结果不正确:
输入:浙江皕盛塑胶有限公司
输出:浙/vg 江/vg 皕/vg 盛/g 塑/g 胶/g 有/g 限/g 公/g 司/v 
这个真是太奇怪了,源程序根本就没动,新建了一个test文件�
��掉用分词
SegTag st = new SegTag(2);
SegResult sr = st.split(“浙江皕盛塑胶有限公司”);
System.out.println("rawResult:"+rawResult);
这个test源文件的编码是UTF-8.

可是我如果把test文件改成GB18030的编码输出就是正确的了:浙
江/ns 皕/a 盛/a 塑
胶/n 有限公司/n 

这个是个bug么?大家知道怎么解决这个问题么?开始以为是��
�码的问题,试了好多方
法都不行,sinboy也好久没来了,不知道能不能看到,有知道��
�朋友帮忙解答一下,
感激不禁~~~




Original issue reported on code.google.com by [email protected] on 1 Sep 2009 at 7:05

这个分词的两大缺点

1.词典的路径老是找不着,能否写成可配置的,或者干脆写成
jar包,引入到classpath里,用
户引入jar包就能用是最好了。
2.词典每加载一次就在内存里加入一次词典,很占内存,怎样
把它写成一个单例模式,只加载一
次就可以了?

Original issue reported on code.google.com by [email protected] on 26 May 2009 at 3:02

BUG

What steps will reproduce the problem?
1.
 Segment seg = new Segment(1);
 SegResult sr = seg.split(src);
2. 当src包括有字符"/"的时候,将进入死循环. 
3. 正在尝试解决~~

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 7 May 2010 at 8:51

segGraph.insert(usn, true); 会吃掉一些字

对"欧阳炎炎、欧阳修、西门吹雪"进行分词时 
产生的结果是 "欧阳/nr 炎炎/z 、/w 修/nr 、/w 西门/nr 吹/v 雪/n 
"
"欧阳修"的"欧阳" 被 segGraph.insert "吃掉了".注释掉就会没问题
请问segGraph.insert的作用是什么.
去掉会有什么后果?

注:segGraph.insert 分别在 
PosTagger 中 528行 segGraph.insert(usn, true);
PosTagger 中 600行 segGraph.insert(newsn, true);


Original issue reported on code.google.com by ph.lemon on 9 Jun 2007 at 1:08

ictclas4j速度慢的问题,根本原因在于代码问题

ictclas4j的编码,等于是把中科院的free 
ictclas(c++版本)翻译了一遍,没有考虑c和
java语言的区别。
java语言中默认编码是UTF-16,字符是16位,字符串的处理方式��
�以字符为基本单位,而不是以
字节为基本单位。而ictclas本身是c语言实现的,字符串的基本
处理单位是字节。
这就导致了ictclas4j中,很多操作是字节<-->字符之间相互转换�
��典型的是大量调用
String.getBytes(),StringBuffer.append(),StringBuffer.toString()方法。这�
��个
方法都消耗大量的cpu时间。
在java中,String就是字符数组,直接的index(),charAt(),length()等方
法访问速度都很
快。因此,我们应该舍弃老式的c方法,使用java内置的方法,
这样会显著加快执行速度。

我的想法是将所有词典和词性库都存放为xml文件,方便直接��
�改。访问词典匹配词时,不是按
gb2312的字符编码去访问下标,而是直接用hash表去匹配,主键�
��汉字,值就是WordTable。

目前已经把词典和词性库转换为xml了,下一步,我打算把Dicti
onary和PosTagger中的访问方
法转换为相应的方法,按字匹配,不是按字节和gb2312编码去��
�配。

对java来说,GFCommon类完全可以去掉

Original issue reported on code.google.com by [email protected] on 31 Oct 2007 at 8:22

Attachments:

Utility.readBytes 读取提速 可把字典加载速度提高1-2倍

Utility.readBytes 可做如下调整,可以加速读取速度.
public static byte[] readBytes(DataInputStream in, int len) {
        if (in != null && len > 0) {
            byte[] b = new byte[len];
            try {
//              for (int i = 0; i < len; i++)
//                  b[i] = in.readByte();
                in.read(b);
            } catch (IOException e) {
                e.printStackTrace();
            }

            return b;
        }

        return null;
    }


Original issue reported on code.google.com by ph.lemon on 9 Jun 2007 at 12:22

关于1.1.0版本中的一些建议

我不是来提bug或提高性能的,只是提几个小建议:
1、1.1.0版本,你使用了maven来进行管理,但你没有把data下面��
�词典打包进去(我不知道你是不是刻意这样做的),应该把�
��个data文件夹放到main/src/resources下面。因为现在你使用maven打
出的jar包中没有字典,我在使用时还要把词典单独找到下载��
�本地,如果不知道SegTag的接口,根据不知道怎么引用字典文�
��(不过赞一个的是:你使得SegTag支持了自定义的词典文件)
。

2、在SegTag(int 
segPathCount)里面,使用默认词典时,应该使用自己jar包中的词�
��,应该使用InputStream方式,我修改了一下如下(没有调用load
(InputStream input,boolean isReset)方法):
    public boolean load(String filename, boolean isReset) {
        int[] nBuffer = new int[3];
        try {
            if (filename == null || filename.trim().isEmpty()) {
                return false;
            }
            InputStream input = null;
            if (filename.trim().toLowerCase().startsWith("classpath:")) {// 类路径
                filename = filename.substring("classpath:".length()).trim();
                if (filename.isEmpty()) {
                    return false;
                }
                if (!filename.startsWith("/")) {
                    filename = "/" + filename;
                }
                input = this.getClass().getResourceAsStream(filename);
                if (input == null) {
                    input = this.getClass().getResourceAsStream(
                            filename.substring(1));
                }
                if (input == null) {
                    input = Thread.currentThread().getContextClassLoader()
                            .getResourceAsStream(filename);
                }
                if (input == null) {
                    input = Thread.currentThread().getContextClassLoader()
                            .getResourceAsStream(filename.substring(1));
                }
                if (input == null) {
                    throw new RuntimeException("找不到资源:" + filename);
                }
            } else {// 文件
                File file = new File(filename);
                if (!file.isFile() || !file.canRead()) {
                    return false;// fail while opening the file
                }
                input = new FileInputStream(file);
            }
            delModified();

            DataInputStream in = new DataInputStream(input);
……
然后在SegTag中默认的就是这样:
    public SegTag(int segPathCount) {
        this.segPathCount = segPathCount;
        coreDict = new Dictionary("classpath:/data/coreDict.dct");

        bigramDict = new Dictionary("classpath:/data/BigramDict.dct");
        personTagger = new PosTagger(Utility.TAG_TYPE.TT_PERSON,
                "classpath:/data/nr", coreDict);
        transPersonTagger = new PosTagger(Utility.TAG_TYPE.TT_TRANS_PERSON,
                "classpath:/data/tr", coreDict);
        placeTagger = new PosTagger(Utility.TAG_TYPE.TT_TRANS_PERSON,
                "classpath:/data/ns", coreDict);
        lexTagger = new PosTagger(Utility.TAG_TYPE.TT_NORMAL,
                "classpath:/data/lexical", coreDict);
    }

以上,谢谢~

Original issue reported on code.google.com by [email protected] on 8 May 2015 at 3:34

分词陷入死循环

What steps will reproduce the problem?
1. String fileContent = 
"**科学院计算技术研究所在多年研究基础上," +  
                "耗时一年研制出了ICTCLAS汉语词法分析系统"; 
2.  SegTag segTag = new SegTag(1);// 分词路径的数目          
        SegResult segResult = segTag.split(fileContent);  
        String classifyContent = segResult.getFinalResult();  
        System.out.println("分词结果\n"+classifyContent);  
3.

What is the expected output? What do you see instead?
java.io.EOFException
    at java.io.DataInputStream.readByte(DataInputStream.java:250)
    at org.ictclas4j.utility.Utility.readBytes(Utility.java:689)
    at org.ictclas4j.bean.ContextStat.load(ContextStat.java:120)
    at org.ictclas4j.bean.ContextStat.load(ContextStat.java:101)
    at org.ictclas4j.segment.PosTagger.<init>(PosTagger.java:45)
    at org.ictclas4j.segment.SegTag.<init>(SegTag.java:37)
    at com.dou.Excercise.TestIctjar.main(TestIctjar.java:39)

What version of the product are you using? On what operating system?

我使用的是ictclas4j-1.0.jar
Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 13 Nov 2013 at 2:51

句子分拆的問題

我們在使用Language tool 
(http://www.languagetool.org/)時,發現以下問題. Language tool 
的開發者通知我們在這回報問題。

以下是有問題的句子:
1) "教育「普羅化」由 91 年《學校管理新措施》的官僚放權"
2) "在不到 10 年的時間內更換了四個皇帝"
3) "- 3 於 1984 
年的教育統籌委員會第一號報告書中,聽取國際顧問團的建��
�認為應推 廣母語教學以提升學與教的質素。"

以下是Language Tool開發者的回覆:
http://sourceforge.net/p/languagetool/bugs/186/

Original issue reported on code.google.com by [email protected] on 9 Aug 2013 at 7:50

dll文件的生成问题

在nutch中加入咱们的ictclas4j时,需要dll文件。在c版中的api文��
�夹下有,在咱们的程序
中没有发现。请问该如何处理阿?谢谢

Original issue reported on code.google.com by [email protected] on 1 Aug 2007 at 1:35

tokenizing text causes an endless loop

Tokenizing this text causes an endless loop: 月份牌

Stacktrace:
at org.ictclas4j.segment.NShortPath.getPaths(NShortPath.java:119)
at org.ictclas4j.segment.SegTag.split(SegTag.java:98)
at 
org.languagetool.tokenizers.zh.ChineseWordTokenizer.tokenize(ChineseWordTokenize
r.java:65)
at org.languagetool.JLanguageTool.getRawAnalyzedSentence(JLanguageTool.java:759)
[...]

I copied this report from 
http://sourceforge.net/tracker/?func=detail&aid=3564124&group_id=110216&atid=655
717, as ictclas4j is now maintained again.

Original issue reported on code.google.com by [email protected] on 15 Sep 2012 at 9:32

ictclas4j性能问题

通过和我自己实现的基于最大正向匹配算法的中文分析比较��
�发现现在的ictclas4j速度慢了很
多,至少在一个数量级以上(目前,我的算法不做词性标注��
�会节省一倍时间)。使用
netbeans + 
profiler分析org.ictclas4j.run.SegMain方法,发现问题在于几个方面��
�
1. 
代码直接从ictclas(c语言版)转换过来的,没有考虑c和java在字
符串处理和基本数据类型
操作的区别,比如字符的判断(全角、半角、中文、英文、��
�点等),应该用位操作来实现;
2. 
大量使用了java的String.getBytes()方法(在org.ictclas4j.utility.Utility
中);
3. 大量使用了StringBuffer.append()和toString()方法;

对这些地方略做改进,效率有3.5--4倍的提升。

另外,在词表查询上,渴望通过双重哈希表来提升词典查询��
�速度。

附件是通过netbeans profiler性能分析得到的ictclas4j的输出。

我争取在最近把上述问题修正了,为ictclas4j提供一个补丁。



Original issue reported on code.google.com by [email protected] on 26 Oct 2007 at 9:49

Attachments:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.