/** * Classify the tokens in a String. Each sentence becomes a separate document. * Doesn't override default readerAndWriter. * * @param str A String with tokens in one or more sentences of text to be classified. * @return {@link List} of classified sentences (each a List of something that * extends {@link CoreMap}). */ public List<List<IN>> classifyRaw(String str, DocumentReaderAndWriter<IN> readerAndWriter) { ObjectBank<List<IN>> documents = makeObjectBankFromString(str, readerAndWriter); return classifyObjectBank(documents); }
public List<String> segmentString(String sentence, DocumentReaderAndWriter<IN> readerAndWriter) { ObjectBank<List<IN>> docs = makeObjectBankFromString(sentence, readerAndWriter); StringWriter stringWriter = new StringWriter(); PrintWriter stringPrintWriter = new PrintWriter(stringWriter); for (List<IN> doc : docs) { classify(doc); readerAndWriter.printAnswers(doc, stringPrintWriter); stringPrintWriter.println(); } stringPrintWriter.close(); String segmented = stringWriter.toString(); return Arrays.asList(segmented.split("\\s")); }
public void classifyStdin(DocumentReaderAndWriter<IN> readerWriter) throws IOException { BufferedReader is = IOUtils.readerFromStdin(flags.inputEncoding); for (String line; (line = is.readLine()) != null; ) { Collection<List<IN>> documents = makeObjectBankFromString(line, readerWriter); if (flags.keepEmptySentences && documents.isEmpty()) { documents = Collections.<List<IN>>singletonList(Collections.<IN>emptyList()); } classifyAndWriteAnswers(documents, readerWriter, false); } }
/** * Classify the tokens in a String. Each sentence becomes a separate document. * * @param str A String with tokens in one or more sentences of text to be * classified. * @return {@link List} of classified sentences (each a List of something that * extends {@link CoreMap}). */ public List<List<IN>> classify(String str) { ObjectBank<List<IN>> documents = makeObjectBankFromString(str, plainTextReaderAndWriter()); return classifyObjectBank(documents); } /**
DocumentReaderAndWriter<IN> textDocumentReaderAndWriter = plainTextReaderAndWriter(); ObjectBank<List<IN>> documents = makeObjectBankFromString(sentences, textDocumentReaderAndWriter);
makeObjectBankFromString(sentences, plainTextReaderAndWriter());
/** * Classify the tokens in a String. Each sentence becomes a separate document. * Doesn't override default readerAndWriter. * * @param str A String with tokens in one or more sentences of text to be classified. * @return {@link List} of classified sentences (each a List of something that * extends {@link CoreMap}). */ public List<List<IN>> classifyRaw(String str, DocumentReaderAndWriter<IN> readerAndWriter) { ObjectBank<List<IN>> documents = makeObjectBankFromString(str, readerAndWriter); return classifyObjectBank(documents); }
public List<String> segmentString(String sentence, DocumentReaderAndWriter<IN> readerAndWriter) { ObjectBank<List<IN>> docs = makeObjectBankFromString(sentence, readerAndWriter); StringWriter stringWriter = new StringWriter(); PrintWriter stringPrintWriter = new PrintWriter(stringWriter); for (List<IN> doc : docs) { classify(doc); readerAndWriter.printAnswers(doc, stringPrintWriter); stringPrintWriter.println(); } stringPrintWriter.close(); String segmented = stringWriter.toString(); return Arrays.asList(segmented.split("\\s")); }
public void classifyStdin(DocumentReaderAndWriter<IN> readerWriter) throws IOException { BufferedReader is = IOUtils.readerFromStdin(flags.inputEncoding); for (String line; (line = is.readLine()) != null; ) { Collection<List<IN>> documents = makeObjectBankFromString(line, readerWriter); if (flags.keepEmptySentences && documents.isEmpty()) { documents = Collections.<List<IN>>singletonList(Collections.<IN>emptyList()); } classifyAndWriteAnswers(documents, readerWriter, false); } }
public void classifyStdin(DocumentReaderAndWriter<IN> readerWriter) throws IOException { BufferedReader is = IOUtils.readerFromStdin(flags.inputEncoding); for (String line; (line = is.readLine()) != null;) { Collection<List<IN>> documents = makeObjectBankFromString(line, readerWriter); if (flags.keepEmptySentences && documents.size() == 0) { documents = Collections.<List<IN>> singletonList(Collections .<IN> emptyList()); } classifyAndWriteAnswers(documents, readerWriter); } }
public List<String> segmentString(String sentence, DocumentReaderAndWriter<IN> readerAndWriter) { ObjectBank<List<IN>> docs = makeObjectBankFromString(sentence, readerAndWriter); StringWriter stringWriter = new StringWriter(); PrintWriter stringPrintWriter = new PrintWriter(stringWriter); for (List<IN> doc : docs) { classify(doc); readerAndWriter.printAnswers(doc, stringPrintWriter); stringPrintWriter.println(); } stringPrintWriter.close(); String segmented = stringWriter.toString(); return Arrays.asList(segmented.split("\\s")); }
public List<String> segmentString(String sentence, DocumentReaderAndWriter<IN> readerAndWriter) { ObjectBank<List<IN>> docs = makeObjectBankFromString(sentence, readerAndWriter); StringWriter stringWriter = new StringWriter(); PrintWriter stringPrintWriter = new PrintWriter(stringWriter); for (List<IN> doc : docs) { classify(doc); readerAndWriter.printAnswers(doc, stringPrintWriter); stringPrintWriter.println(); } stringPrintWriter.close(); String segmented = stringWriter.toString(); return Arrays.asList(segmented.split("\\s")); }
/** * Classify the tokens in a String. Each sentence becomes a separate * document. Doesn't override default readerAndWriter. * * @param str * A String with tokens in one or more sentences of text to be * classified. * @return {@link List} of classified sentences (each a List of something * that extends {@link CoreMap}). */ public List<List<IN>> classifyRaw(String str, DocumentReaderAndWriter<IN> readerAndWriter) { ObjectBank<List<IN>> documents = makeObjectBankFromString(str, readerAndWriter); List<List<IN>> result = new ArrayList<List<IN>>(); for (List<IN> document : documents) { classify(document); List<IN> sentence = new ArrayList<IN>(); for (IN wi : document) { // TaggedWord word = new TaggedWord(wi.word(), wi.answer()); // sentence.add(word); sentence.add(wi); } result.add(sentence); } return result; }
/** * Classify the tokens in a String. Each sentence becomes a separate * document. * * @param str * A String with tokens in one or more sentences of text to be * classified. * @return {@link List} of classified sentences (each a List of something * that extends {@link CoreMap}). */ public List<List<IN>> classify(String str) { ObjectBank<List<IN>> documents = makeObjectBankFromString(str, plainTextReaderAndWriter); List<List<IN>> result = new ArrayList<List<IN>>(); for (List<IN> document : documents) { classify(document); List<IN> sentence = new ArrayList<IN>(); for (IN wi : document) { // TaggedWord word = new TaggedWord(wi.word(), wi.answer()); // sentence.add(word); sentence.add(wi); } result.add(sentence); } return result; }
/** * Classify the tokens in a String. Each sentence becomes a separate document. * Doesn't override default readerAndWriter. * * @param str * A String with tokens in one or more sentences of text to be * classified. * @return {@link List} of classified sentences (each a List of something that * extends {@link CoreMap}). */ public List<List<IN>> classifyRaw(String str, DocumentReaderAndWriter readerAndWriter) { ObjectBank<List<IN>> documents = makeObjectBankFromString(str, readerAndWriter); List<List<IN>> result = new ArrayList<List<IN>>(); for (List<IN> document : documents) { classify(document); List<IN> sentence = new ArrayList<IN>(); for (IN wi : document) { // TaggedWord word = new TaggedWord(wi.word(), wi.answer()); // sentence.add(word); sentence.add(wi); } result.add(sentence); } return result; }
/** * Classify the tokens in a String. Each sentence becomes a separate document. * * @param str A String with tokens in one or more sentences of text to be * classified. * @return {@link List} of classified sentences (each a List of something that * extends {@link CoreMap}). */ public List<List<IN>> classify(String str) { ObjectBank<List<IN>> documents = makeObjectBankFromString(str, plainTextReaderAndWriter()); return classifyObjectBank(documents); } /**
/** * Classify the tokens in a String. Each sentence becomes a separate document. * * @param str * A String with tokens in one or more sentences of text to be * classified. * @return {@link List} of classified sentences (each a List of something that * extends {@link CoreMap}). */ public List<List<IN>> classify(String str) { DocumentReaderAndWriter<IN> readerAndWriter = new PlainTextDocumentReaderAndWriter<IN>(); readerAndWriter.init(flags); ObjectBank<List<IN>> documents = makeObjectBankFromString(str, readerAndWriter); List<List<IN>> result = new ArrayList<List<IN>>(); for (List<IN> document : documents) { classify(document); List<IN> sentence = new ArrayList<IN>(); for (IN wi : document) { // TaggedWord word = new TaggedWord(wi.word(), wi.answer()); // sentence.add(word); sentence.add(wi); } result.add(sentence); } return result; }
.fromShortName(outputFormat); ObjectBank<List<IN>> documents = makeObjectBankFromString(sentences, plainTextReaderAndWriter);
makeObjectBankFromString(sentences, readerAndWriter);
makeObjectBankFromString(sentences, plainTextReaderAndWriter());