/**
  * @param term
  * @param pos
  * @param gloss
  * @return
  * @throws JwktlException
  */
 private List<String> splitIntoSentences(String term, PartOfSpeech pos, String gloss)
     throws JwktlException {
   if (gloss.length() == 0) return new Vector<String>();
   if (simplerPos(pos.getCanonicalPosTag()).equals(SimplerCanonicalPosTag.VERB))
     return splitIntoSentencesForVerb(gloss);
   // else
   return splitIntoSentencesForNoun(term, gloss);
 }
  /* (non-Javadoc)
   * @see ac.biu.cs.nlp.lexical.resource.LexicalResource#getRules(java.lang.String, ac.biu.nlp.nlp.representation.PartOfSpeech, java.lang.String, ac.biu.nlp.nlp.representation.PartOfSpeech)
   */
  @Override
  public List<LexicalRule<? extends VerbOceanRuleInfo>> getRules(
      String leftLemma, PartOfSpeech leftPos, String rightLemma, PartOfSpeech rightPos)
      throws LexicalResourceException {

    if (leftLemma == null) throw new LexicalResourceException("left lemma is null");
    if (rightLemma == null) throw new LexicalResourceException("right lemma is null");
    List<LexicalRule<? extends VerbOceanRuleInfo>> rules =
        new ArrayList<LexicalRule<? extends VerbOceanRuleInfo>>();
    if ((leftPos == null || simplerPos(leftPos.getCanonicalPosTag()) == SimplerCanonicalPosTag.VERB)
        && (rightPos == null
            || simplerPos(rightPos.getCanonicalPosTag()) == SimplerCanonicalPosTag.VERB)) {
      LexicalRule<? extends VerbOceanRuleInfo> rule =
          mapRulesByEntailmentPair.get(new EntailmentPair(leftLemma, rightLemma));
      if (rule != null) {
        rules.add(rule);
      }
    }
    return rules;
  }
 /* (non-Javadoc)
  * @see ac.biu.cs.nlp.lexical.resource.LexicalResource#getRulesForLeft(java.lang.String, ac.biu.nlp.nlp.representation.PartOfSpeech)
  */
 @Override
 public List<LexicalRule<? extends VerbOceanRuleInfo>> getRulesForLeft(
     String lemma, PartOfSpeech pos) throws LexicalResourceException {
   if (lemma == null) throw new LexicalResourceException("lemma is null");
   List<LexicalRule<? extends VerbOceanRuleInfo>> rules =
       new Vector<LexicalRule<? extends VerbOceanRuleInfo>>();
   if ((pos == null || simplerPos(pos.getCanonicalPosTag()) == SimplerCanonicalPosTag.VERB)
       && mapRulesByEntailingVerb.containsKey(lemma)) {
     rules.addAll(mapRulesByEntailingVerb.get(lemma));
   }
   return new ArrayList<LexicalRule<? extends VerbOceanRuleInfo>>(rules);
 }
  /**
   * Extract hypernyms out of the wiki sense descriptions, by prefixing them with "X is" and parsing
   * the new copular sentence, and extracting the predicate and its modifiers.
   *
   * <p>For instance, for "dog: A coward" you parse "dog is a coward" and extract the predicate
   * "coward".
   *
   * @param term
   * @param
   * @return
   * @throws WiktionaryException
   */
  public List<String> parseGloss(String term, PartOfSpeech pos, String gloss)
      throws WiktionaryException {
    if (term == null) throw new JwktlException("Got null word");
    if (gloss == null) throw new JwktlException("Got null gloss");

    List<String> hypernyms = new Vector<String>();

    List<String> sentences = splitIntoSentences(term, pos, gloss);
    // parse and parse-out-hypernyms for each sentence
    for (String sentence : sentences) {
      parser.setSentence(sentence);
      List<BasicConstructionNode> nodesList;
      BasicConstructionTreeAndParentMap treeAndParentMap;
      BasicConstructionNode parseTree;
      try {
        parser.parse();
        parseTree = parser.getMutableParseTree();
        treeAndParentMap = new BasicConstructionTreeAndParentMap(parseTree);
        nodesList = parser.getNodesOrderedByWords();

      } catch (ParserRunException e) {
        throw new WiktionaryException("Error parsing the sentence: " + sentence, e);
      } catch (TreeAndParentMapException e) {
        throw new WiktionaryException(
            "Error constructing EnglishTreeAndParentMap out of the sentence: " + sentence, e);
      }

      if (!simplerPos(pos.getCanonicalPosTag()).equals(SimplerCanonicalPosTag.VERB))
        // noun glosses are parsed differently, and the relevant subtree needs to be pinpointed
        parseTree = findParentOfWord(term, sentence, nodesList, treeAndParentMap);

      List<String> localHypernyms;
      // add the main predicate and all its governed entailed words
      try {
        localHypernyms = ParseTreeUtils.getEntailedModifiersOf(parseTree);
      } catch (ParseTreeException e) {
        throw new JwktlException("see nested", e);
      }
      hypernyms.addAll(localHypernyms);
    }

    return hypernyms;
  }
 /**
  * @param partOfSpeechObject
  * @param partOfSpeechObject2
  * @return
  */
 private boolean posMatch(PartOfSpeech textPartOfSpeech, PartOfSpeech rulePartOfSpeech) {
   return (WildcardPartOfSpeech.isWildCardPOS(rulePartOfSpeech)
       || simplerPos(textPartOfSpeech.getCanonicalPosTag())
           == simplerPos(rulePartOfSpeech.getCanonicalPosTag()));
 }