6
¿Cómo puedo tokenizar una cadena en clase java con stanford parser?stanford nlp tokenizer
Solo puedo encontrar ejemplos de documentProcessor y PTBTokenizer tomando texto de un archivo externo.
DocumentPreprocessor dp = new DocumentPreprocessor("hello.txt");
for (List sentence : dp) {
System.out.println(sentence);
}
// option #2: By token
PTBTokenizer ptbt = new PTBTokenizer(new FileReader("hello.txt"),
new CoreLabelTokenFactory(), "");
for (CoreLabel label; ptbt.hasNext();) {
label = (CoreLabel) ptbt.next();
System.out.println(label);
}
Gracias.
se puede escribir el código para el constructor y cómo puedo usar lector con esto. Gracias – Naveen
no importa, esto me está dando tokens: Lista rawWords = tokenizerFactory.getTokenizer (new StringReader (sentence)). Tokenize(); System.out.println (rawWords.get (0) .value()); –
Naveen
Me tomé un tiempo para abrir NetBeans, crear un nuevo proyecto, etc ... luego oscurecer ... maldición ... – CapelliC