Skip to content

Instantly share code, notes, and snippets.

@vthacker
Created February 3, 2015 11:53

Revisions

  1. Varun Thacker created this gist Feb 3, 2015.
    21 changes: 21 additions & 0 deletions gistfile1.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    import java.io.IOException;
    import java.nio.charset.Charset;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    import java.nio.file.StandardOpenOption;
    import java.util.ArrayList;
    import java.util.List;

    public class ParseWordNet {

    public static void main(String args[]) throws IOException {
    List<String> lines = Files.readAllLines(Paths.get(System.getProperty("inputFile")), Charset.defaultCharset());
    List<String> text = new ArrayList<>();
    for (String line : lines) {
    int start = line.indexOf('\'')+1;
    int end = line.lastIndexOf('\'');
    text.add(line.substring(start, end).replace("''", "'"));
    }
    Files.write(Paths.get(System.getProperty("outputFile")), text, Charset.defaultCharset(), StandardOpenOption.CREATE);
    }
    }