---
title: "IK Analyzer 中文分词器---小试牛刀"
author: "NumbCoder"
date: "2009-11-26T22:29:47Z"
tags: []
slug: "ik-analyzer"
draft: false
lastmod: "2009-11-26T22:36:52Z"
id: 528715
url: "https://numbcoder.iteye.com/blog/528715"
---

最近在跟着导师做一个有关短信过滤的大学生实践项目，之中用到了导师已经发表的关于中文语义分词的算法。一直听说Java开源社区的Lucene搜索很强大，很想研究一下。没想到意外收获到了IK Analyzer，中国人自己也的开源分词器，自己用了下，真的是很好很强大呀。对作者是由衷的钦佩啊！

     看了他提供的API，写了个小例子试了，切词的精准度还是蛮高的。强力推荐。

```java

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

import org.wltea.analyzer.IKSegmentation;
import org.wltea.analyzer.Lexeme;

public class SearchDemo {
	public static void main(String []args){
		Reader read= null;
		try {
			 read =new FileReader("D:/wz/workspace/SearchDemo/src/test.txt");
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		IKSegmentation iks = new IKSegmentation(read);
		
		while(true){
			Lexeme lex=null;
			try {
				lex = iks.next();
				if(lex != null)
				System.out.print(lex.getLexemeText()+"|");
				if(lex == null)
					return;
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

}

```

IK Analyzer作者：linliangyi2007 (林良益)  博客： http://linliangyi2007.iteye.com/