Exemplo n.º 1
0
 /**
  * Read match data from a file. Format should be: sourceRelation TAB instanceID TAB field1 TAB ...
  * fieldn LF
  */
 public MatchData(String filename) throws InputFormatException {
   this.filename = filename;
   sourceNames = new ArrayList();
   sourceLists = new HashMap();
   try {
     BufferedReader in = new BufferedReader(new FileReader(filename));
     String line;
     int lineNum = 0;
     while ((line = in.readLine()) != null) {
       lineNum++;
       String tok[] = line.split("\t", -1);
       int toklen = tok.length;
       if (toklen < 1) throw new InputFormatException(filename, lineNum, "no source");
       String src = tok[0];
       if (toklen < 2) throw new InputFormatException(filename, lineNum, "no id");
       String id = tok[1];
       if (toklen < 3) throw new InputFormatException(filename, lineNum, "no text fields");
       String text = tok[2];
       for (int i = 3; i < toklen; i++) {
         text += "\t" + tok[i];
       }
       addInstance(src, id, text);
     }
     in.close();
   } catch (IOException e) {
     throw new InputFormatException(filename, 0, e.toString());
   }
 }