当前位置: 首页>>代码示例>>Java>>正文


Java TokenSequenceRemoveStopwords类代码示例

本文整理汇总了Java中cc.mallet.pipe.TokenSequenceRemoveStopwords的典型用法代码示例。如果您正苦于以下问题:Java TokenSequenceRemoveStopwords类的具体用法?Java TokenSequenceRemoveStopwords怎么用?Java TokenSequenceRemoveStopwords使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TokenSequenceRemoveStopwords类属于cc.mallet.pipe包,在下文中一共展示了TokenSequenceRemoveStopwords类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPipelist

import cc.mallet.pipe.TokenSequenceRemoveStopwords; //导入依赖的package包/类
private static List<Pipe> getPipelist(Collection<String> stopwords) {
	// Begin by importing documents from text to feature sequences
	List<Pipe> pipeList = new ArrayList<Pipe>();

	// Pipes: lowercase, tokenize, remove stopwords, map to features
	pipeList.add(new CharSequenceLowercase());
	pipeList.add(new CharSequence2TokenSequence(Pattern.compile("\\p{L}[\\p{L}\\p{P}]+\\p{L}")));
	
	TokenSequenceRemoveStopwords stopwordsRemovalPipe = 
			new TokenSequenceRemoveStopwords(new File("mallet/stoplists/en.txt"), "UTF-8", false, false, false);
	if(!stopwords.isEmpty()) {
		stopwordsRemovalPipe.addStopWords(stopwords.toArray(new String[stopwords.size()]));
	}
	pipeList.add(stopwordsRemovalPipe);
	pipeList.add(new TokenSequence2FeatureSequence());
			
	return pipeList;
}
 
开发者ID:MKLab-ITI,项目名称:mgraph-summarization,代码行数:19,代码来源:LDA.java

示例2: createInstanceList

import cc.mallet.pipe.TokenSequenceRemoveStopwords; //导入依赖的package包/类
/**
 * Creates a list of Malelt instances from a list of documents
 * @param texts a list of documents
 * @return a list of Mallet instances
 * @throws IOException
 */
private InstanceList createInstanceList(List<String> texts) throws IOException
{
	ArrayList<Pipe> pipes = new ArrayList<Pipe>();
	pipes.add(new CharSequence2TokenSequence());
	pipes.add(new TokenSequenceLowercase());
	pipes.add(new TokenSequenceRemoveStopwords());
	pipes.add(new TokenSequence2FeatureSequence());
	InstanceList instanceList = new InstanceList(new SerialPipes(pipes));
	instanceList.addThruPipe(new ArrayIterator(texts));
	return instanceList;
}
 
开发者ID:socialsensor,项目名称:topic-detection,代码行数:18,代码来源:LDA.java

示例3: getPipe

import cc.mallet.pipe.TokenSequenceRemoveStopwords; //导入依赖的package包/类
/**
 * 
 * @param model
 * @param targetProcessing
 * @return
 */
private Pipe getPipe() {
	ArrayList<Pipe> pipes = new ArrayList<Pipe>();
	pipes.add(new Target2Label());
	pipes.add(new SaveDataInSource());
	pipes.add(new Input2CharSequence("UTF-8"));
	pipes.add(new CharSequence2TokenSequence(Pattern.compile("\\p{Alpha}+")));
	pipes.add(new TokenSequenceLowercase());
	pipes.add(new TokenSequenceRemoveStopwords(false, false));
	pipes.add(new TokenSequence2FeatureSequence());
	// pipes.add(new PrintInputAndTarget());
	return new SerialPipes(pipes);
}
 
开发者ID:hakchul77,项目名称:irnlp_toolkit,代码行数:19,代码来源:MalletWrapper.java

示例4: testThree

import cc.mallet.pipe.TokenSequenceRemoveStopwords; //导入依赖的package包/类
public void testThree ()
{
	InstanceList il = new InstanceList (
		new SerialPipes(new Pipe[] {
			new Target2Label(),
			new CharSequence2TokenSequence(),
			new TokenSequenceLowercase(),
			new TokenSequenceRemoveStopwords(),
			new TokenSequence2FeatureSequence(),
			new FeatureSequence2FeatureVector()
		}));
	Iterator<Instance> pi = new FileIterator(new File("foo/bar"), null, Pattern.compile("^([^/]*)/"));
	il.addThruPipe (pi);
}
 
开发者ID:mimno,项目名称:Mallet,代码行数:15,代码来源:TestRainbowStyle.java

示例5: buildPipe

import cc.mallet.pipe.TokenSequenceRemoveStopwords; //导入依赖的package包/类
public Pipe buildPipe() {
    ArrayList pipeList = new ArrayList();

    // Read data from File objects
    pipeList.add(new Input2CharSequence("UTF-8"));

    // Regular expression for what constitutes a token.
    //  This pattern includes Unicode letters, Unicode numbers, 
    //   and the underscore character. Alternatives:
    //    "\\S+"   (anything not whitespace)
    //    "\\w+"    ( A-Z, a-z, 0-9, _ )
    //    "[\\p{L}\\p{N}_]+|[\\p{P}]+"   (a group of only letters and numbers OR
    //                                    a group of only punctuation marks)
    Pattern tokenPattern =
        Pattern.compile("[\\p{L}\\p{N}_]+");

    // Tokenize raw strings
    pipeList.add(new CharSequence2TokenSequence(tokenPattern));

    // Normalize all tokens to all lowercase
    pipeList.add(new TokenSequenceLowercase());

    // Remove stopwords from a standard English stoplist.
    //  options: [case sensitive] [mark deletions]
    pipeList.add(new TokenSequenceRemoveStopwords(false, false));

    // Rather than storing tokens as strings, convert 
    //  them to integers by looking them up in an alphabet.
    pipeList.add(new TokenSequence2FeatureSequence());

    // Do the same thing for the "target" field: 
    //  convert a class label string to a Label object,
    //  which has an index in a Label alphabet.
    pipeList.add(new Target2Label());

    // Now convert the sequence of features to a sparse vector,
    //  mapping feature IDs to counts.
    pipeList.add(new FeatureSequence2FeatureVector());

    // Print out the features and the label
    //pipeList.add(new PrintInputAndTarget());

    return new SerialPipes(pipeList);
}
 
开发者ID:guanxin0520,项目名称:dhnowFilter,代码行数:45,代码来源:EvaluateClassifier.java


注:本文中的cc.mallet.pipe.TokenSequenceRemoveStopwords类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。