title: java lang Class Cast Exception
body: <p>I have written a code which can reduce the grammatical boundaries for a text, but when I run the program this exception comes up     </p>
  
  <pre><code>java.lang.ClassCastException
  </code></pre>
  
  <p>here is the class that i run,</p>
  
  <pre><code>public class paerser {
  public static void main (String [] arg){
      LexicalizedParser lp = new LexicalizedParser("grammar/englishPCFG.ser.gz");
          lp.setOptionFlags("-maxLength", "500", "-retainTmpSubcategories");
          TreebankLanguagePack tlp = new PennTreebankLanguagePack();
         GrammaticalStructureFactory gsf = tlp.grammaticalStructureFactory();
         String text = "John, who was the CEO of a company, played golf.";
         edu.stanford.nlp.trees.Tree parse = lp.apply(Arrays.asList(text));
         GrammaticalStructure gs = gsf.newGrammaticalStructure(parse);
         List&lt;TypedDependency&gt; tdl = gs.typedDependenciesCCprocessed();
         System.out.println(tdl);
  
  }
  }
  </code></pre>
  
  <p>Updated,</p>
  
  <p>here is the full stack trace ...</p>
  
  <pre><code>Loading parser from serialized file grammar/englishPCFG.ser.gz ... done [1.5 sec].
  Following exception caught during parsing:
  java.lang.ClassCastException: java.lang.String cannot be cast to edu.stanford.nlp.ling.HasWord
      at edu.stanford.nlp.parser.lexparser.ExhaustivePCFGParser.parse(ExhaustivePCFGParser.java:346)
      at edu.stanford.nlp.parser.lexparser.LexicalizedParser.parse(LexicalizedParser.java:386)
      at edu.stanford.nlp.parser.lexparser.LexicalizedParser.apply(LexicalizedParser.java:304)
      at paerser.main(paerser.java:19)
  Recovering using fall through strategy: will construct an (X ...) tree.
  Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be  cast to edu.stanford.nlp.ling.HasWord
      at edu.stanford.nlp.parser.lexparser.LexicalizedParser.apply(LexicalizedParser.java:317)
      at paerser.main(paerser.java:19)
  </code></pre>