Skip to content

Commit

Permalink
New mode to run on a .info file with pre-created parse trees.
Browse files Browse the repository at this point in the history
  • Loading branch information
nchambers committed Sep 18, 2018
1 parent 74dcee6 commit 9c59e9c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 7 deletions.
24 changes: 24 additions & 0 deletions runcaevoparsed.sh
@@ -0,0 +1,24 @@
#!/bin/bash
#
# If you have a .info file with parse trees already.
# This will identify the events and add TLINKs.
#
# runcaevoparsed.sh <info-file>
#


props=default.properties
sieves=default.sieves

# Having extra space at the end of the string seems to make maven angry.
# Don't add arguments from $@ unless we have to.
if (( $# > 0 )); then
args="-info $1 parsed"
echo "args: $args"
mvn exec:java -Dexec.mainClass=caevo.Main -Dprops=$props -Dsieves=$sieves -Dexec.args="$args"
else
echo "./runcaevoparsed.sh <info-file-just-parses>"
fi



25 changes: 18 additions & 7 deletions src/main/java/caevo/Main.java
Expand Up @@ -5,6 +5,7 @@
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -61,8 +62,8 @@ public class Main {
private TimexClassifier timexClassifier;
public static WordNet wordnet;

SieveDocuments thedocs;
SieveDocuments thedocsUnchanged; // for evaluating if TLinks are in the input
SieveDocuments thedocs = null;
SieveDocuments thedocsUnchanged = null; // for evaluating if TLinks are in the input
Closure closure;
String outpath = "sieve-output.xml";
boolean debug = true;
Expand Down Expand Up @@ -112,7 +113,13 @@ public Main(String[] args) {
if (infopath != null) {
System.out.println("Checking for infofile at " + infopath);
thedocs = new SieveDocuments(infopath);
thedocsUnchanged = new SieveDocuments(infopath);

// For evaluation, contains gold tlinks.
System.out.println(Arrays.toString(args) + "\t" + args[args.length-1]);
if( args.length > 0 && !args[args.length-1].equalsIgnoreCase("parsed") ) {
System.out.println("unchanged loading!");
thedocsUnchanged = new SieveDocuments(infopath);
}
}

// -set on the command line?
Expand Down Expand Up @@ -312,7 +319,7 @@ public void runSieves(SieveDocuments thedocs) {
docs.writeToXML(new File(outpath));

// Evaluate it if the input file had tlinks in it.
if (thedocsUnchanged != null)
if (thedocsUnchanged != null )
Evaluate.evaluate(thedocsUnchanged, docs, sieveClasses, sieveNameToStats);
}

Expand Down Expand Up @@ -710,7 +717,7 @@ public void markupRawXML(String path) {

// Output the documents.
String outpath = path + ".info.xml";
if (Directory.isDirectory(path))
if( Directory.isDirectory(path) )
outpath = Directory.lastSubdirectory(path) + "-dir.info.xml";
docs.writeToXML(outpath);
System.out.println("Created " + outpath);
Expand Down Expand Up @@ -871,9 +878,12 @@ public static void main(String[] args) {

// The given SieveDocuments only has text and parses, so extract
// events/times first.
else if (args.length > 0
&& args[args.length - 1].equalsIgnoreCase("parsed")) {
else if (args.length > 0 && args[args.length - 1].equalsIgnoreCase("parsed")) {
System.out.println("Marking up time!");
main.markupAll();
String outfile = args[args.length-2] + ".withtime";
System.out.println("Writing output: " + outfile);
main.thedocs.writeToXML(new File(outfile));
}

// Give a text file or a directory of text files. Parses and marks it up.
Expand Down Expand Up @@ -911,3 +921,4 @@ else if (args.length > 0
}
}
}

0 comments on commit 9c59e9c

Please sign in to comment.