All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aliasi.test.unit.tokenizer.ConstantTokenizer Maven / Gradle / Ivy

Go to download

This is the original Lingpipe: http://alias-i.com/lingpipe/web/download.html There were not made any changes to the source code.

There is a newer version: 4.1.2-JL1.0
Show newest version
package com.aliasi.test.unit.tokenizer;

import com.aliasi.tokenizer.Tokenizer;

public class ConstantTokenizer extends Tokenizer {
    private final String[] mTokens;
    private final String[] mWhitespaces;
    private int mNextToken = 0;
    public ConstantTokenizer(String[] tokens,
                             String[] whitespaces) {
        if (whitespaces.length != tokens.length + 1)
            throw new IllegalArgumentException("lengths bad");
        mTokens = tokens;
        mWhitespaces = whitespaces;
    }
    @Override
    public String nextToken() {
        if (mNextToken >= mTokens.length) {
            return null;
        }
        return mTokens[mNextToken++];
    }
    @Override
    public String nextWhitespace() {
        return mWhitespaces[mNextToken];
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy