⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fmm.java

📁 中文分词开源项目JAVA?形姆执士聪钅縅AVA?形姆执士聪钅縅AVA中文分词开源项目JAVA
💻 JAVA
字号:
/**
 * 
 */
package WordSegment;

import java.util.Vector;

/**
 * @author Truman
 *
 */
public class FMM extends SegStrategy {

	/* (non-Javadoc)
	 * @see WordSegment.SegStrategy#Segment(java.lang.String, WordSegment.Dictionary)
	 */
	//@Override
	public Vector Segment(String sentence, Dictionary dic) {
		int maxLength = dic.getMaxLength();	//the length of the longest word in the dictionary
		int pos = 0;
		int targetLength = maxLength;
		int restLength = sentence.length();
		Vector<String> seged = new Vector<String>();

		while (restLength > 0)
		{
			if (targetLength > restLength)
				targetLength = restLength;
			String tempStr = sentence.substring(pos, pos + targetLength);
			if (dic.checkWord(tempStr) || targetLength == 1)
			{
				seged.add(tempStr);
				pos += targetLength;
				targetLength = maxLength;
				restLength = sentence.length() - pos;
			}
			else
				targetLength--;
		}
		return seged;
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -