Skip to content

Commit

Permalink
move dependency conversion utility to GrammaticalStructureConversionU…
Browse files Browse the repository at this point in the history
…tils, use same method for all converters
  • Loading branch information
sebschu authored and Stanford NLP committed Jul 9, 2016
1 parent 49c6e52 commit 3a0b91c
Show file tree
Hide file tree
Showing 15 changed files with 1,161 additions and 1,549 deletions.
22 changes: 9 additions & 13 deletions src/edu/stanford/nlp/ie/AbstractSequenceClassifier.java
Expand Up @@ -657,21 +657,20 @@ public List<Triple<String, Integer, Integer>> classifyToCharacterOffsets(String
} }


/** /**
* Have a word segmenter segment a String into a list of words. * ONLY USE IF LOADED A CHINESE WORD SEGMENTER!!!!!
* ONLY USE IF YOU LOADED A CHINESE WORD SEGMENTER!!!!!
* *
* @param sentence The string to be classified * @param sentence
* The string to be classified
* @return List of words * @return List of words
*/ */
// This method is currently [2016] only called in a very small number of places:
// the parser's jsp webapp, ChineseSegmenterAnnotator, and SegDemo.
// Maybe we could eliminate it?
public List<String> segmentString(String sentence) { public List<String> segmentString(String sentence) {
return segmentString(sentence, defaultReaderAndWriter); return segmentString(sentence, defaultReaderAndWriter);
} }


public List<String> segmentString(String sentence, DocumentReaderAndWriter<IN> readerAndWriter) { public List<String> segmentString(String sentence,
ObjectBank<List<IN>> docs = makeObjectBankFromString(sentence, readerAndWriter); DocumentReaderAndWriter<IN> readerAndWriter) {
ObjectBank<List<IN>> docs = makeObjectBankFromString(sentence,
readerAndWriter);


StringWriter stringWriter = new StringWriter(); StringWriter stringWriter = new StringWriter();
PrintWriter stringPrintWriter = new PrintWriter(stringWriter); PrintWriter stringPrintWriter = new PrintWriter(stringWriter);
Expand All @@ -686,7 +685,7 @@ public List<String> segmentString(String sentence, DocumentReaderAndWriter<IN> r
return Arrays.asList(segmented.split("\\s")); return Arrays.asList(segmented.split("\\s"));
} }


/* /**
* Classify the contents of {@link SeqClassifierFlags scf.testFile}. The file * Classify the contents of {@link SeqClassifierFlags scf.testFile}. The file
* should be in the format expected based on {@link SeqClassifierFlags * should be in the format expected based on {@link SeqClassifierFlags
* scf.documentReader}. * scf.documentReader}.
Expand All @@ -708,10 +707,7 @@ public List<String> segmentString(String sentence, DocumentReaderAndWriter<IN> r
* @return The same {@link List}, but with the elements annotated with their * @return The same {@link List}, but with the elements annotated with their
* answers (stored under the * answers (stored under the
* {@link edu.stanford.nlp.ling.CoreAnnotations.AnswerAnnotation} * {@link edu.stanford.nlp.ling.CoreAnnotations.AnswerAnnotation}
* key). The answers will be the class labels defined by the CRF * key).
* Classifier. They might be things like entity labels (in BIO
* notation or not) or something like "1" vs. "0" on whether to
* begin a new token here or not (in word segmentation).
*/ */
public abstract List<IN> classify(List<IN> document); public abstract List<IN> classify(List<IN> document);


Expand Down
2 changes: 1 addition & 1 deletion src/edu/stanford/nlp/ie/crf/CRFClassifier.java
Expand Up @@ -960,7 +960,7 @@ protected static Index<CRFLabel> allLabels(int window, Index<String> classIndex)
* Makes a CRFDatum by producing features and a label from input data at a * Makes a CRFDatum by producing features and a label from input data at a
* specific position, using the provided factory. * specific position, using the provided factory.
* *
* @param info The input data. Particular feature factories might look for arbitrary keys in the IN items. * @param info The input data
* @param loc The position to build a datum at * @param loc The position to build a datum at
* @param featureFactories The FeatureFactories to use to extract features * @param featureFactories The FeatureFactories to use to extract features
* @return The constructed CRFDatum * @return The constructed CRFDatum
Expand Down

0 comments on commit 3a0b91c

Please sign in to comment.