}



  /**
   * Converts a Sentence/List/String into a Tree.  If it can't be parsed,
   * it is made into a trivial tree in which each word is attached to a
   * dummy tag ("X") and then to a start nonterminal (also "X").
   *
   * @param in The input Sentence/List/String
   * @return A Tree that is the parse tree for the sentence.  If the parser
   *         fails, a new Tree is synthesized which attaches all words to the
   *         root.
   * @throws IllegalArgumentException If argument isn't a List or String
   */
  public Tree apply(Object in) {
    List<? extends HasWord> lst;
    if (in instanceof String) {
      TokenizerFactory<? extends HasWord> tf = op.tlpParams.treebankLanguagePack().getTokenizerFactory();
      Tokenizer<? extends HasWord> tokenizer = tf.getTokenizer(new BufferedReader(new StringReader((String) in)));
      lst = tokenizer.tokenize();
    } else if (in instanceof List) {
      lst = (List<? extends HasWord>) in;
    } else {
      throw new IllegalArgumentException("Can only parse Sentence/List/String");
    }

    try {
      if (parse(lst)) {
        Tree bestparse = getBestParse();
        bestparse.setScore(getPCFGScore() % -10000.0); // -10000 denotes unknown words
        return bestparse;
      }
    } catch (Exception e) {
      System.err.println("Following exception caught during parsing:");
      e.printStackTrace();
      System.err.println("Recovering using fall through strategy: will construct an (X ...) tree.");
    }
    // if can't parse or exception, fall through
    TreeFactory lstf = new LabeledScoredTreeFactory();
    List<Tree> lst2 = new ArrayList<Tree>();
    for (HasWord obj : lst) {
      String s = obj.word();
      Tree t = lstf.newLeaf(s);
      Tree t2 = lstf.newTreeNode("X", Collections.singletonList(t));
      lst2.add(t2);
    }