forked from fozziethebeat/C-Cat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding bug fixes and updating mains for adding relations
- Loading branch information
1 parent
456d639
commit 5de7863
Showing
21 changed files
with
614 additions
and
162 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
wordnet/src/main/java/gov/llnl/ontology/mains/SaveTaggedSenseTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package gov.llnl.ontology.mains; | ||
|
||
import gov.llnl.ontology.text.Sentence; | ||
import gov.llnl.ontology.text.corpora.SenseEvalAllWordsDocumentReader; | ||
import gov.llnl.ontology.util.AnnotationUtil; | ||
import gov.llnl.ontology.util.StringPair; | ||
import gov.llnl.ontology.text.tag.OpenNlpMEPOSTagger; | ||
|
||
import com.google.common.collect.Sets; | ||
|
||
import edu.stanford.nlp.ling.CoreAnnotations.StemAnnotation; | ||
import edu.stanford.nlp.ling.CoreAnnotations.ValueAnnotation; | ||
import edu.stanford.nlp.pipeline.Annotation; | ||
|
||
import edu.ucla.sspace.util.ReflectionUtil; | ||
import edu.ucla.sspace.util.WorkQueue; | ||
|
||
import opennlp.tools.postag.POSTagger; | ||
|
||
import java.io.PrintWriter; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
|
||
/** | ||
* @author Keith Stevens | ||
*/ | ||
public class SaveTaggedSenseTask { | ||
|
||
public static void main(String[] args) throws Exception { | ||
String testCorpusName = args[0]; | ||
String outputPostFix = args[1]; | ||
|
||
POSTagger tagger = new OpenNlpMEPOSTagger(); | ||
|
||
SenseEvalAllWordsDocumentReader reader = | ||
new SenseEvalAllWordsDocumentReader(); | ||
reader.parse(testCorpusName); | ||
|
||
List<Sentence> sentences = reader.sentences(); | ||
final String[] output = new String[sentences.size()]; | ||
int s = 0; | ||
WorkQueue workQueue = new WorkQueue(); | ||
Object key = workQueue.registerTaskGroup(sentences.size()); | ||
for (final Sentence sentence : sentences) { | ||
int i = 0; | ||
final Set<Integer> focusIndices = Sets.newHashSet(); | ||
String[] tokens = new String[sentence.numTokens()]; | ||
for (Annotation annot : sentence) { | ||
tokens[i] = AnnotationUtil.word(annot); | ||
if (tokens[i].indexOf(" ") != -1) | ||
tokens[i] = annot.get(StemAnnotation.class); | ||
|
||
if (annot.get(ValueAnnotation.class) != null) { | ||
focusIndices.add(i); | ||
} | ||
++i; | ||
} | ||
|
||
i = 0; | ||
String[] tags = tagger.tag(tokens); | ||
for (Annotation annot : sentence) | ||
AnnotationUtil.setPos(annot, tags[i++]); | ||
} | ||
|
||
StringPair lines = Sentence.writeSentences(sentences); | ||
PrintWriter writer = new PrintWriter(outputPostFix); | ||
writer.println(lines.x); | ||
writer.println(lines.y); | ||
writer.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.