Skip to content

Commit

Permalink
Fix some things.
Browse files Browse the repository at this point in the history
  • Loading branch information
mayhewsw committed Jun 15, 2018
1 parent fd85f32 commit ead8370
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion scripts/buildindex.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ cpath="target/classes:target/dependency/*:config"
INPATH=$1
OUTPATH=$2

java -classpath ${cpath} -Xmx16g io.github.mayhewsw.TextFileIndexer -infolder $INPATH -indexfolder $OUTPATH -test
java -classpath ${cpath} -Xmx16g io.github.mayhewsw.TextFileIndexer -infolder $INPATH -indexfolder $OUTPATH -test -testonly
18 changes: 14 additions & 4 deletions src/main/java/io/github/mayhewsw/TextFileIndexer.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static void buildindex(String filedir, String indexDir) throws IOExceptio
* @param fname
* @return
*/
private static String read(String fname){
public static String read(String fname){
StringBuilder sb = new StringBuilder();
try (BufferedReader br = Files.newBufferedReader(Paths.get(fname), StandardCharsets.UTF_8)) {
for (String line = null; (line = br.readLine()) != null;) {
Expand Down Expand Up @@ -248,18 +248,28 @@ public static void main(String[] args) throws Exception {
.desc("Whether or not to test the index after creation")
.build();


Option testonlyopt = Option.builder("testonly")
.desc("Should we build index before testing, or only test.")
.build();

options.addOption(help);
options.addOption(infolder);
options.addOption(indexfolder);
options.addOption(testopt);
options.addOption(testonlyopt);

CommandLineParser parser = new DefaultParser();
CommandLine cmd = parser.parse(options, args);

buildsentenceindex(cmd.getOptionValue("infolder"), cmd.getOptionValue("indexfolder"));

if(cmd.hasOption("test")) {
if(cmd.hasOption("testonly")) {
testindex(cmd.getOptionValue("indexfolder"));

}else {
buildsentenceindex(cmd.getOptionValue("infolder"), cmd.getOptionValue("indexfolder"));
if (cmd.hasOption("test")) {
testindex(cmd.getOptionValue("indexfolder"));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ public String loaddata(@RequestParam(value = "dataname") String dataname, Model
File tapath = new File(outfolder);
File[] filelist = tapath.listFiles();
for(File f : filelist){
TextAnnotation ta = SerializationHelper.deserializeTextAnnotationFromFile(f.getAbsolutePath());
TextAnnotation ta = SerializationHelper.deserializeFromJson(TextFileIndexer.read(f.getAbsolutePath()));

View sents = ta.getView(ViewNames.SENTENCE);
talist.add(ta);

Expand Down

0 comments on commit ead8370

Please sign in to comment.