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

📄 complexalgorithmtest.java

📁 使用最大正向匹配算法
💻 JAVA
字号:
package org.solol.mmseg.test;

import org.solol.mmseg.core.AlgorithmException;
import org.solol.mmseg.core.AlgorithmFactory;
import org.solol.mmseg.core.Config;
import org.solol.mmseg.core.IAlgorithm;
import org.solol.mmseg.core.IWord;
import org.solol.mmseg.internal.Word;

import junit.framework.TestCase;

public class ComplexAlgorithmTest extends TestCase {
	
	private IAlgorithm algorithm;
	
	protected void setUp() throws Exception {
		algorithm = AlgorithmFactory.getFactory().createAlgorithm(Config.THREE_WORD);
	}

	protected void tearDown() throws Exception {

	}

	public final void testMMRule() {
		// MMRule -> Rule1
		try {
			String content = "眼看就要来了";
			IWord word1 = new Word("眼看",Word.CJK_WORD);
			
			IWord word = algorithm.next(content.toCharArray());
			assertEquals(word1, word);
		} catch (AlgorithmException e) {
			e.printStackTrace();
		}		
	}
	public final void testLAWLRule() {
//		 LAWLRule -> Rule2
		try {
			String content = "国际化";
			IWord word1 = new Word("国际化",Word.CJK_WORD);	
			
			IWord word = algorithm.next(content.toCharArray());
			assertEquals(word1, word);
		} catch (AlgorithmException e) {
			e.printStackTrace();
		}		
	}
	
	public final void testSVWLRule() {
//		 SVWLRule -> Rule3
		try {
			String content = "研究生命起源";
			IWord word1 = new Word("研究",Word.CJK_WORD);	
			
			IWord word = algorithm.next(content.toCharArray());
			assertEquals(word1, word);
		} catch (AlgorithmException e) {
			e.printStackTrace();
		}		
	}
	
	public final void testLSDMFOCWRule() {
//		 LSDMFOCWRule -> Rule4
		try {
			String content = "是一个";
			IWord word1 = new Word("是",Word.CJK_WORD);		
			
			IWord word = algorithm.next(content.toCharArray());
			assertEquals(word1, word);
		} catch (AlgorithmException e) {
			e.printStackTrace();
		}
	}

}

⌨️ 快捷键说明

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