title: Java Stanford NLP: Find word frequency?
body: <p>I'm using the Stanford NLP Parsing toolkit. Given a word in the lexicon, how can I find its frequency*? Or, given a frequency rank, how can I determine the corresponding word?</p>
  
  <p>*in the entire language, not just the text sample.</p>
  
  <p>This is a demo of the toolkit I'm using:</p>
  
  <pre><code>class ParserDemo {
    public static void main(String[] args) {
      LexicalizedParser lp = new LexicalizedParser("englishPCFG.ser.gz");
      lp.setOptionFlags(new String[]{"-maxLength", "80", "-retainTmpSubcategories"});
  
      String[] sent = { "Sincerity", "may", "frighten", "the", "boy", "." };
      Tree parse = (Tree) lp.apply(Arrays.asList(sent));
      parse.pennPrint();
      System.out.println();
  
      TreebankLanguagePack tlp = new PennTreebankLanguagePack();
      GrammaticalStructureFactory gsf = tlp.grammaticalStructureFactory();
      GrammaticalStructure gs = gsf.newGrammaticalStructure(parse);
      Collection tdl = gs.typedDependenciesCollapsed();
      System.out.println(tdl);
      System.out.println();
  
      TreePrint tp = new TreePrint("penn,typedDependenciesCollapsed");
      tp.printTree(parse);
    }
  
  }
  </code></pre>