package edu.stanford.nlp.simple; import edu.stanford.nlp.io.IOUtils; import edu.stanford.nlp.io.RuntimeIOException; import edu.stanford.nlp.pipeline.CoreNLPProtos; import java.io.IOException; import java.util.List; import java.util.Properties; /** * A {@link Sentence}, but in French. * * @author <a href="mailto:angeli@cs.stanford.edu">Gabor Angeli</a> */ public class FrenchSentence extends Sentence { /** A properties object for creating a document from a single sentence. Used in the constructor {@link Sentence#Sentence(String)} */ static Properties SINGLE_SENTENCE_DOCUMENT = new Properties() {{ try { load(IOUtils.getInputStreamFromURLOrClasspathOrFileSystem("edu/stanford/nlp/pipeline/StanfordCoreNLP-french.properties")); } catch (IOException e) { throw new RuntimeIOException(e); } setProperty("language", "french"); setProperty("annotators", ""); setProperty("ssplit.isOneSentence", "true"); setProperty("tokenize.class", "PTBTokenizer"); setProperty("tokenize.language", "fr"); }}; /** A properties object for creating a document from a single tokenized sentence. */ private static Properties SINGLE_SENTENCE_TOKENIZED_DOCUMENT = new Properties() {{ try { load(IOUtils.getInputStreamFromURLOrClasspathOrFileSystem("edu/stanford/nlp/pipeline/StanfordCoreNLP-french.properties")); } catch (IOException e) { throw new RuntimeIOException(e); } setProperty("language", "french"); setProperty("annotators", ""); setProperty("ssplit.isOneSentence", "true"); setProperty("tokenize.class", "WhitespaceTokenizer"); setProperty("tokenize.language", "fr"); setProperty("tokenize.whitespace", "true"); // redundant? }}; public FrenchSentence(String text) { super(new FrenchDocument(text), SINGLE_SENTENCE_DOCUMENT); } public FrenchSentence(List<String> tokens) { super(FrenchDocument::new, tokens, SINGLE_SENTENCE_TOKENIZED_DOCUMENT); } public FrenchSentence(CoreNLPProtos.Sentence proto) { super(FrenchDocument::new, proto, SINGLE_SENTENCE_DOCUMENT); } }