![JAR search and dependency download from the Maven repository](/logo.png)
edu.stanford.nlp.objectbank.DelimitRegExIterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stanford-parser Show documentation
Show all versions of stanford-parser Show documentation
Stanford Parser processes raw text in English, Chinese, German, Arabic, and French, and extracts constituency parse trees.
The newest version!
package edu.stanford.nlp.objectbank;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import edu.stanford.nlp.io.RuntimeIOException;
import edu.stanford.nlp.util.AbstractIterator;
/**
* An Iterator that reads the contents of a Reader, delimited by the specified
* delimiter, and then subsequently processed by an Function to produce
* Objects of type T.
*
* @author Jenny Finkel getFactory(String delim) {
return DelimitRegExIteratorFactory.defaultDelimitRegExIteratorFactory(delim);
}
/**
* Returns a factory that vends DelimitRegExIterators that reads the contents of the
* given Reader, splits on the specified delimiter, applies op, then returns the result.
*/
public static IteratorFromReaderFactory getFactory(String delim, Function op) {
return new DelimitRegExIteratorFactory<>(delim, op);
}
public static class DelimitRegExIteratorFactory implements IteratorFromReaderFactory /*, Serializable */ {
private static final long serialVersionUID = 6846060575832573082L;
private final String delim;
@SuppressWarnings("serial")
private final Function op;
public static DelimitRegExIteratorFactory defaultDelimitRegExIteratorFactory(String delim) {
return new DelimitRegExIteratorFactory<>(delim, new IdentityFunction<>());
}
public DelimitRegExIteratorFactory(String delim, Function op) {
this.delim = delim;
this.op = op;
}
@Override
public Iterator getIterator(Reader r) {
return new DelimitRegExIterator<>(r, delim, op);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy