📄 complexalgorithm.java
字号:
/**
*
*/
package org.solol.mmseg.internal;
import java.util.ArrayList;
import java.util.List;
import org.solol.mmseg.core.AlgorithmException;
import org.solol.mmseg.core.DictionaryFactory;
import org.solol.mmseg.core.IChunk;
import org.solol.mmseg.core.IWord;
/**
* @author solo L
*
*/
public final class ComplexAlgorithm extends AbstractAlgorithm {
public ComplexAlgorithm() throws AlgorithmException {
super();
}
public ComplexAlgorithm(DictionaryFactory dictionaryFactory) {
super(dictionaryFactory);
}
protected IChunk[] createChunks(char[] chars, int index) {
List chunkList = new ArrayList(5);
IWord[] words0 = findMatchWords(chars, index);
for (int i = 0; i < words0.length; i++) {
int index0 = index + words0[i].getLength();
if (index0 < chars.length) {
IWord[] words1 = findMatchWords(chars, index0);
for (int j = 0; j < words1.length; j++) {
int index1 = index0 + words1[j].getLength();
if (index1 < chars.length) {
IWord[] words2 = findMatchWords(chars, index1);
for (int k = 0; k < words2.length; k++) {
chunkList.add(new Chunk(new IWord[] { words0[i],
words1[j], words2[k] }));
}
} else if (index1 == chars.length) {
chunkList.add(new Chunk(new IWord[] { words0[i],
words1[j] }));
}
}
} else if (index0 == chars.length) {
chunkList.add(new Chunk(new IWord[] { words0[i] }));
}
}
IChunk[] chunks = new IChunk[chunkList.size()];
chunkList.toArray(chunks);
chunkList.clear();
return chunks;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -