protected static ParserData getParserDataFromPetrovFiles(String grammarFile, String lexiconFile) {
    try {
      Options op = new Options();
      // TODO: do something to the options

      // for the grammar, we have to read through once and store it
      // so we can number all the states, before we create the grammar
      BufferedReader gIn = new BufferedReader(new FileReader(grammarFile));
      String line = gIn.readLine();
      Numberer stateNumberer = Numberer.getGlobalNumberer("states");
      List<UnaryRule> unaryRules = new ArrayList<UnaryRule>();
      List<BinaryRule> binaryRules = new ArrayList<BinaryRule>();
      while (line!=null) {
        String[] fields = line.split("\\s+");
        if (fields.length==4) {
          // unary rule
          double score = Double.parseDouble(fields[3]);
          UnaryRule ur = new UnaryRule(stateNumberer.number(new String(fields[0])), stateNumberer.number(new String(fields[2])), score);
          unaryRules.add(ur);
        } else if (fields.length==5){
          // binary rule
          double score = Double.parseDouble(fields[4]);
          BinaryRule br = new BinaryRule(stateNumberer.number(new String(fields[0])), stateNumberer.number(new String(fields[2])),
              stateNumberer.number(new String(fields[3])), score);
          binaryRules.add(br);
        } else {
          throw new RuntimeException("Bad line format: " + line);
        }
        line = gIn.readLine();
      }
      // now make the binary grammar
      BinaryGrammar bg = new BinaryGrammar(stateNumberer.total());
      for (BinaryRule br : binaryRules) {
        bg.addRule(br);
      }
      bg.splitRules();
      // now make the unary grammar
      UnaryGrammar ug = new UnaryGrammar(stateNumberer.total());
      for (UnaryRule ur : unaryRules) {
        ug.addRule(ur);
      }
      ug.purgeRules();

      // now we handle the lexicon
      Lexicon lex = new PetrovLexicon();
      lex.readData(new BufferedReader(new FileReader(lexiconFile)));

      return new ParserData(lex, bg, ug, null, null, op); // TODO, numbs?
    } catch (IOException e) {
      e.printStackTrace();
    }
    return null;
  }