Package com.googlecode.clearnlp.dependency

Examples of com.googlecode.clearnlp.dependency.DEPNode


      // Convert CAS data into structures usable by ClearNLP
      for (int i = 0; i < tokens.size(); i++) {
        BaseToken token = tokens.get(i);
        String lemma = useLemmatizer ? lemmatizer.getLemma(token.getCoveredText(), token.getPartOfSpeech()) : token.getNormalizedForm();
        DEPNode node = new DEPNode(i+1, token.getCoveredText(), lemma, token.getPartOfSpeech(), new DEPFeat());
        tree.add(node);
      }

      // Run parser and convert output back to CAS friendly data types
      parser.process(tree);
View Full Code Here


          int id = idIter + 1;
          String form = casDepNode.getForm();
          String pos = casDepNode.getPostag();
          String lemma = casDepNode.getLemma();
         
          DEPNode node = new DEPNode(id, form, lemma, pos, new DEPFeat());
          tree.add(node);
          idIter++;
        }
      }

      for (int i=1; i<tree.size(); i++)
      {
        DEPNode node = tree.get(i);
        DEPNode head = tree.get(headIDs[i-1]);
        String  label = deprels[i-1];
        node.setHead(head, label);
      }
     
      tree.initSHeads();
View Full Code Here

    Map<DEPNode, Predicate> headIdToPredicate = new HashMap<DEPNode, Predicate>();
    Map<Predicate, List<SemanticArgument>> predicateArguments = new HashMap<Predicate, List<SemanticArgument>>();

    for (int i = 1; i < tree.size(); i++) {
        // Every ClearNLP parserNode will contain an srlInfo field.
        DEPNode parserNode = tree.get(i);
        BaseToken token = tokens.get(i - 1);
        String rolesetId;
       
        if ((rolesetId = parserNode.getFeat(DEPLib.FEAT_PB)) != null)
        {
          if (!headIdToPredicate.containsKey(parserNode)) {
            // We have not encountered this predicate yet, so create it
            Predicate pred = this.createPredicate(jCas, rolesetId, token);
            headIdToPredicate.put(parserNode, pred);
            pred.setRelations(new EmptyFSList(jCas));
          }
        }
    }
   
   
    // Start at node 1, since node 0 is considered the head of the sentence
    for (int i = 1; i < tree.size(); i++) {
      // Every ClearNLP parserNode will contain an srlInfo field.
      DEPNode parserNode = tree.get(i);
      BaseToken token = tokens.get(i - 1);
    
      for (DEPArc head : parserNode.getSHeads()) {
          Predicate predicate = headIdToPredicate.get(head.getNode());

          // Append this argument to the predicate's list of arguments
          if (!predicateArguments.containsKey(predicate)) {
            predicateArguments.put(predicate, new ArrayList<SemanticArgument>());
View Full Code Here

  }

  private void initRegexes() {
    // Recognizes phrases like "<disease1>, <disease2>, or FOCUS".  For appending for any FOCUS.
    DEPNode[] regnodes_NN_CONJ_NN = new DEPNode[1];
    regnodes_NN_CONJ_NN[0]    = new DEPNode(DEPLib.NULL_ID, ANY_TOKEN);
    regnodes_NN_CONJ_NN[0].setLabel(DependencyRegex.fromSet(rel_conjunctSet));
    //regnodes_NN_CONJ_NN[1]        = new DEPNode();
    //regnodes_NN_CONJ_NN[1].deprel = DependencyRegex.fromSet(rel_conjunctSet);

    // Recognizes phrases like "denies <symptom1>"
    DEPNode[] regnodes_VBNEG_OBJ = new DEPNode[2];
    regnodes_VBNEG_OBJ[0]        = new DEPNode(DEPLib.NULL_ID, fromSet(iv_negVerbsSet));
//    regnodes_VBNEG_OBJ[0].form   = DependencyRegex.fromSet(iv_negVerbsSet);
    regnodes_VBNEG_OBJ[1]     = new DEPNode(DEPLib.NULL_ID, ANY_TOKEN);
    regnodes_VBNEG_OBJ[1].setLabel(DEPLibEn.DEP_DOBJ)/* was "OBJ" in clearparser */
    int cVBNEG_OBJ = 0;
   
    // Recognizes phrases like "was not FOCUS" -- in dependency order: not was
    DEPNode[] regnodes_PRT_VB_PRD = new DEPNode[3];
    regnodes_PRT_VB_PRD[0]          = new DEPNode(DEPLib.NULL_ID, fromSet(iv_negParticlesSet));
//    regnodes_PRT_VB_PRD[0].form     = DependencyRegex.fromSet(iv_negParticlesSet);
    regnodes_PRT_VB_PRD[0].setLabel(DEPLibEn.DEP_NEG); // was: ("ADV");
    regnodes_PRT_VB_PRD[1]          = new DEPNode(DEPLib.NULL_ID, fromSet(iv_copulaSet));
//    regnodes_PRT_VB_PRD[1].form     = DependencyRegex.fromSet(iv_copulaSet);
    regnodes_PRT_VB_PRD[2]          = new DEPNode(DEPLib.NULL_ID, ANY_TOKEN);
    regnodes_PRT_VB_PRD[2].setLabel(DEPLibEn.DEP_ACOMP); // was: ("PRD");
    regnodes_PRT_VB_PRD[2].pos      = DependencyRegex.ANY_ADJECTIVE;
    int cPRT_VB_PRD = 1;
   
    // Recognizes phrases like "did not find FOCUS"  (don't think the modal verb will be on the path?)
    DEPNode[] regnodes_PRT_MOD_VB_OBJ = new DEPNode[3];
    regnodes_PRT_MOD_VB_OBJ[0]          = new DEPNode(DEPLib.NULL_ID,fromSet(iv_negParticlesSet));
//    regnodes_PRT_MOD_VB_OBJ[0].form     = DependencyRegex.fromSet(iv_negParticlesSet);
    regnodes_PRT_MOD_VB_OBJ[0].setLabel(DEPLibEn.DEP_NEG); // was: ("ADV");
    regnodes_PRT_MOD_VB_OBJ[1]          = new DEPNode(DEPLib.NULL_ID, fromSet(iv_regVerbsSet));
    regnodes_PRT_MOD_VB_OBJ[1].pos      = ANY_VERB;
    regnodes_PRT_MOD_VB_OBJ[2]          = new DEPNode(DEPLib.NULL_ID,ANY_TOKEN);
    regnodes_PRT_MOD_VB_OBJ[2].setLabel(DEPLibEn.DEP_DOBJ)
    // everything below here was replaced for this path:
/*    //
    regnodes_PRT_MOD_VB_OBJ[1]          = new DEPNode(DEPLib.NULL_ID,fromSet(iv_modalVerbsSet));
//    regnodes_PRT_MOD_VB_OBJ[1].form     = DependencyRegex.fromSet(iv_modalVerbsSet);
    regnodes_PRT_MOD_VB_OBJ[2]          = new DEPNode(DEPLib.NULL_ID,fromSet(iv_regVerbsSet));
//    regnodes_PRT_MOD_VB_OBJ[2].form     = DependencyRegex.fromSet(iv_regVerbsSet);
//    regnodes_PRT_MOD_VB_OBJ[2].setLabel(DEPLibEn.DEP_CCOMP); // was: ("VC"); really a shot in the dark
    regnodes_PRT_MOD_VB_OBJ[2].pos      = ANY_VERB;
    regnodes_PRT_MOD_VB_OBJ[3]          = new DEPNode(DEPLib.NULL_ID,ANY_TOKEN);
    regnodes_PRT_MOD_VB_OBJ[3].setLabel(DEPLibEn.DEP_DOBJ);  // was:("OBJ"); */
    int cPRT_MOD_VB_OBJ = 1;
   
    // Recognizes phrases like "did not find evidence of FOCUS"
    DEPNode[] regnodes_PRT_MOD_VB_OBJ_IN_PMOD = new DEPNode[6];
    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[0]          = new DEPNode(DEPLib.NULL_ID,fromSet(iv_negParticlesSet));
//    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[0].form     = DependencyRegex.fromSet(iv_negParticlesSet);
    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[0].setLabel(DEPLibEn.DEP_NEG); // was:("ADV");
    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[1]          = new DEPNode(DEPLib.NULL_ID,fromSet(iv_modalVerbsSet));
//    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[1].form     = DependencyRegex.fromSet(iv_modalVerbsSet);
    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[1].setLabel(DEPLibEn.DEP_CCOMP); // was: ("VC");
    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[2]          = new DEPNode(DEPLib.NULL_ID,fromSet(iv_regVerbsSet));
//    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[2].form     = DependencyRegex.fromSet(iv_regVerbsSet);
    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[3]          = new DEPNode(DEPLib.NULL_ID,fromSet(iv_regNounsSet));
//    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[3].form     = DependencyRegex.fromSet(iv_regNounsSet);
    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[3].setLabel(DEPLibEn.DEP_DOBJ); //("OBJ");
    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[4]        = new DEPNode(DEPLib.NULL_ID,fromSet(iv_regPrepositionsSet));
//    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[4].form   = DependencyRegex.fromSet(iv_regPrepositionsSet);
    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[4].pos    = "IN";
    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[5]        = new DEPNode(DEPLib.NULL_ID,ANY_TOKEN);
    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[5].setLabel(DEPLibEn.DEP_POBJ); // was: ("PMOD");   
    int cPRT_MOD_VB_OBJ_IN_PMOD = 1;
   
    // Recognizes phrases like "excluding FOCUS"
    DEPNode[] regnodes_VBN_SBJ = new DEPNode[2];
    regnodes_VBN_SBJ[0]        = new DEPNode(DEPLib.NULL_ID, fromSet(iv_negVerbsSet));
//    regnodes_VBN_SBJ[0].form   = DependencyRegex.fromSet(iv_negVerbsSet);
    regnodes_VBN_SBJ[0].pos    = "VBG"// was VBN
    regnodes_VBN_SBJ[1]       = new DEPNode(DEPLib.NULL_ID, ANY_TOKEN);
    regnodes_VBN_SBJ[1].setLabel(DEPLibEn.DEP_DOBJ); // was: ("SBJ");
    int cVBN_SBJ = 0;
   
    // Recognizes phrases like "rules out FOCUS"
    DEPNode[] regnodes_PRT_rule_OBJ = new DEPNode[3];
    regnodes_PRT_rule_OBJ[0]          = new DEPNode(DEPLib.NULL_ID, fromSet(iv_negColPartSet));
//    regnodes_PRT_rule_OBJ[0].form     = DependencyRegex.fromSet(iv_negColPartSet);
    regnodes_PRT_rule_OBJ[0].setLabel(DEPLibEn.DEP_PRT); // was: ("PRT");
    regnodes_PRT_rule_OBJ[1]          = new DEPNode(DEPLib.NULL_ID, fromSet(iv_negCollocSet));
//    regnodes_PRT_rule_OBJ[1].form     = DependencyRegex.fromSet(iv_negCollocSet);
    regnodes_PRT_rule_OBJ[2]          = new DEPNode(DEPLib.NULL_ID, ANY_TOKEN);
    regnodes_PRT_rule_OBJ[2].setLabel(DEPLibEn.DEP_DOBJ); //("OBJ");
    int cPRT_rule_OBJ = 1;
   
    //// Noun-ish rules
    // Recognizes phrases like "no pain"
    DEPNode[] regnodes_DT_NMOD   = new DEPNode[2];
    regnodes_DT_NMOD[0]          = new DEPNode(NULL_ID, fromSet(iv_negDetPlusPrepSet));
//    regnodes_DT_NMOD[0].form     = DependencyRegex.fromSet(iv_negDetPlusPrepSet);
    regnodes_DT_NMOD[0].setLabel(DEP_DET); // was: ("NMOD");
    regnodes_DT_NMOD[1]          = new DEPNode(NULL_ID, ANY_TOKEN);
    regnodes_DT_NMOD[1].pos      = DependencyRegex.ANY_NOUN;
    int cDT_NMOD = 1;

    // Recognizes phrases like "without pain"
    DEPNode[] regnodes_IN_PMOD   = new DEPNode[2];
    regnodes_IN_PMOD[0]          = new DEPNode(NULL_ID, fromSet(iv_negDetPlusPrepSet));
//    regnodes_IN_PMOD[0].form     = DependencyRegex.fromSet(iv_negDetPlusPrepSet);
    regnodes_IN_PMOD[0].setLabel(DEP_PMOD); // was: ("PMOD");
    regnodes_IN_PMOD[1]          = new DEPNode(NULL_ID, ANY_TOKEN);
    regnodes_IN_PMOD[1].pos      = DependencyRegex.ANY_NOUN;
    int cIN_PMOD = 0;
   
    // Recognizes phrases like "no history of FOCUS"
    DEPNode[] regnodes_DT_NN_IN_PMOD = new DEPNode[4];
    regnodes_DT_NN_IN_PMOD[0]        = new DEPNode(NULL_ID, fromSet(iv_negDetPlusPrepSet));
//    regnodes_DT_NN_IN_PMOD[0].form   = DependencyRegex.fromSet(iv_negDetPlusPrepSet);
//    regnodes_DT_NN_IN_PMOD[0].setLabel(DEP_PMOD + "|" + DEP_NMOD); // was: ("[NP]MOD");  // no convincing evidence that this can be restricted among the set of words listed above. (no would be det i think)
    regnodes_DT_NN_IN_PMOD[1]        = new DEPNode(NULL_ID, fromSet(iv_regNounsSet));
//    regnodes_DT_NN_IN_PMOD[1].form   = DependencyRegex.fromSet(iv_regNounsSet);
    regnodes_DT_NN_IN_PMOD[2]        = new DEPNode(NULL_ID, fromSet(iv_regPrepositionsSet));
//    regnodes_DT_NN_IN_PMOD[2].form   = DependencyRegex.fromSet(iv_regPrepositionsSet);
    regnodes_DT_NN_IN_PMOD[2].pos    = "IN";
    regnodes_DT_NN_IN_PMOD[3]        = new DEPNode(NULL_ID, ANY_TOKEN);
    regnodes_DT_NN_IN_PMOD[3].setLabel(DEP_POBJ); // was: ("PMOD");
    int cDT_NN_IN_PMOD = 1;
   
//    // Recognizes negative-adjective phrases like "is negative for carcinoma"
//    DEPNode[] regnodes_JJNEG_COP_IN_PMOD = new DEPNode[4];
//    regnodes_JJNEG_COP_IN_PMOD[0]        = new DEPNode();
//    regnodes_JJNEG_COP_IN_PMOD[0].form   = DependencyRegex.fromSet(iv_negAdjectivesSet);
//    regnodes_JJNEG_COP_IN_PMOD[1]        = new DEPNode();
//    regnodes_JJNEG_COP_IN_PMOD[1].pos    = DependencyRegex.ANY_VERB; // banking that people don't use double negatives
//    regnodes_JJNEG_COP_IN_PMOD[2]        = new DEPNode();
//    regnodes_JJNEG_COP_IN_PMOD[2].form   = DependencyRegex.fromSet(iv_regPrepositionsSet);
//    regnodes_JJNEG_COP_IN_PMOD[2].pos    = "IN";
//    regnodes_JJNEG_COP_IN_PMOD[3]        = new DEPNode();
//    regnodes_JJNEG_COP_IN_PMOD[3].deprel = "PMOD";
//    int cJJNEG_COP_IN_PMOD = 1;

    // Recognizes negative-adjective phrases like "negative for carcinoma"
    DEPNode[] regnodes_JJNEG_AMOD_PMOD = new DEPNode[3];
    regnodes_JJNEG_AMOD_PMOD[0]        = new DEPNode(NULL_ID, fromSet(iv_negAdjectivesSet));
//    regnodes_JJNEG_AMOD_PMOD[0].form   = DependencyRegex.fromSet(iv_negAdjectivesSet);
    regnodes_JJNEG_AMOD_PMOD[1]        = new DEPNode(NULL_ID, fromSet(iv_regPrepositionsSet));
//    regnodes_JJNEG_AMOD_PMOD[1].form   = DependencyRegex.fromSet(iv_regPrepositionsSet);
    regnodes_JJNEG_AMOD_PMOD[1].pos    = "IN";
    regnodes_JJNEG_AMOD_PMOD[2]        = new DEPNode(NULL_ID, ANY_TOKEN);
    regnodes_JJNEG_AMOD_PMOD[2].setLabel(DEP_POBJ); // was: ("PMOD");
    int cJJNEG_AMOD_PMOD = 0;
   
    // Recognizes negative-adjective phrases like "unlikely to have carcinoma"
    // FIXME - not sure this one works correctly -- this example parses weirdly in CVD.
    DEPNode[] regnodes_JJNEG_AMOD_IM_OBJ = new DEPNode[4];
    regnodes_JJNEG_AMOD_IM_OBJ[0]        = new DEPNode(NULL_ID, fromSet(iv_negAdjectivesSet));
//    regnodes_JJNEG_AMOD_IM_OBJ[0].form   = DependencyRegex.fromSet(iv_negAdjectivesSet);
    regnodes_JJNEG_AMOD_IM_OBJ[1]        = new DEPNode(NULL_ID, ANY_TOKEN);
    regnodes_JJNEG_AMOD_IM_OBJ[1].setLabel(DEP_AMOD); // was: ("AMOD");
    regnodes_JJNEG_AMOD_IM_OBJ[2]        = new DEPNode(NULL_ID, ANY_TOKEN);
    regnodes_JJNEG_AMOD_IM_OBJ[2].setLabel(DEP_INFMOD); // was: ("IM");
    regnodes_JJNEG_AMOD_IM_OBJ[3]        = new DEPNode(NULL_ID, ANY_TOKEN);
    regnodes_JJNEG_AMOD_IM_OBJ[3].setLabel(DEP_DOBJ); // was: ("OBJ");
    int cJJNEG_AMOD_IM_OBJ = 0;
   
    // Recognizes negative-adjective phrases like "unlikely carcinoma"
    DEPNode[] regnodes_JJNEG_NN = new DEPNode[2];
    regnodes_JJNEG_NN[0]        = new DEPNode(NULL_ID, fromSet(iv_negAdjectivesSet));
//    regnodes_JJNEG_NN[0].form   = DependencyRegex.fromSet(iv_negAdjectivesSet);
    regnodes_JJNEG_NN[1]        = new DEPNode(NULL_ID, ANY_TOKEN);
    regnodes_JJNEG_NN[1].pos    = DependencyRegex.ANY_NOUN;
    int cJJNEG_NN = 1;
   
   
    // Add the verb-ish rules to the set of regexes to search
View Full Code Here

  }

  private void initRegexes() {
    // Recognizes phrases like "<disease1>, <disease2>, or FOCUS".  For appending for any FOCUS.
    DEPNode[] regnodes_NN_CONJ_NN = new DEPNode[1];
    regnodes_NN_CONJ_NN[0]    = new DEPNode(DEPLib.NULL_ID, ANY_TOKEN);
    regnodes_NN_CONJ_NN[0].setLabel(DependencyRegex.fromSet(rel_conjunctSet));
    //regnodes_NN_CONJ_NN[1]        = new DEPNode();
    //regnodes_NN_CONJ_NN[1].deprel = DependencyRegex.fromSet(rel_conjunctSet);

    // Recognizes phrases like "denies <symptom1>"
    DEPNode[] regnodes_VBNEG_OBJ = new DEPNode[2];
    regnodes_VBNEG_OBJ[0]        = new DEPNode(DEPLib.NULL_ID, fromSet(iv_negVerbsSet));
//    regnodes_VBNEG_OBJ[0].form   = DependencyRegex.fromSet(iv_negVerbsSet);
    regnodes_VBNEG_OBJ[1]     = new DEPNode(DEPLib.NULL_ID, ANY_TOKEN);
    regnodes_VBNEG_OBJ[1].setLabel(DEPLibEn.DEP_DOBJ)/* was "OBJ" in clearparser */
    int cVBNEG_OBJ = 0;
   
    // Recognizes phrases like "was not FOCUS" -- in dependency order: not was
    DEPNode[] regnodes_PRT_VB_PRD = new DEPNode[3];
    regnodes_PRT_VB_PRD[0]          = new DEPNode(DEPLib.NULL_ID, fromSet(iv_negParticlesSet));
//    regnodes_PRT_VB_PRD[0].form     = DependencyRegex.fromSet(iv_negParticlesSet);
    regnodes_PRT_VB_PRD[0].setLabel(DEPLibEn.DEP_NEG); // was: ("ADV");
    regnodes_PRT_VB_PRD[1]          = new DEPNode(DEPLib.NULL_ID, fromSet(iv_copulaSet));
//    regnodes_PRT_VB_PRD[1].form     = DependencyRegex.fromSet(iv_copulaSet);
    regnodes_PRT_VB_PRD[2]          = new DEPNode(DEPLib.NULL_ID, ANY_TOKEN);
    regnodes_PRT_VB_PRD[2].setLabel(DEPLibEn.DEP_ACOMP); // was: ("PRD");
    regnodes_PRT_VB_PRD[2].pos      = DependencyRegex.ANY_ADJECTIVE;
    int cPRT_VB_PRD = 1;
   
    // Recognizes phrases like "did not find FOCUS"  (don't think the modal verb will be on the path?)
    DEPNode[] regnodes_PRT_MOD_VB_OBJ = new DEPNode[3];
    regnodes_PRT_MOD_VB_OBJ[0]          = new DEPNode(DEPLib.NULL_ID,fromSet(iv_negParticlesSet));
//    regnodes_PRT_MOD_VB_OBJ[0].form     = DependencyRegex.fromSet(iv_negParticlesSet);
    regnodes_PRT_MOD_VB_OBJ[0].setLabel(DEPLibEn.DEP_NEG); // was: ("ADV");
    regnodes_PRT_MOD_VB_OBJ[1]          = new DEPNode(DEPLib.NULL_ID, fromSet(iv_regVerbsSet));
    regnodes_PRT_MOD_VB_OBJ[1].pos      = ANY_VERB;
    regnodes_PRT_MOD_VB_OBJ[2]          = new DEPNode(DEPLib.NULL_ID,ANY_TOKEN);
    regnodes_PRT_MOD_VB_OBJ[2].setLabel(DEPLibEn.DEP_DOBJ)
    // everything below here was replaced for this path:
/*    //
    regnodes_PRT_MOD_VB_OBJ[1]          = new DEPNode(DEPLib.NULL_ID,fromSet(iv_modalVerbsSet));
//    regnodes_PRT_MOD_VB_OBJ[1].form     = DependencyRegex.fromSet(iv_modalVerbsSet);
    regnodes_PRT_MOD_VB_OBJ[2]          = new DEPNode(DEPLib.NULL_ID,fromSet(iv_regVerbsSet));
//    regnodes_PRT_MOD_VB_OBJ[2].form     = DependencyRegex.fromSet(iv_regVerbsSet);
//    regnodes_PRT_MOD_VB_OBJ[2].setLabel(DEPLibEn.DEP_CCOMP); // was: ("VC"); really a shot in the dark
    regnodes_PRT_MOD_VB_OBJ[2].pos      = ANY_VERB;
    regnodes_PRT_MOD_VB_OBJ[3]          = new DEPNode(DEPLib.NULL_ID,ANY_TOKEN);
    regnodes_PRT_MOD_VB_OBJ[3].setLabel(DEPLibEn.DEP_DOBJ);  // was:("OBJ"); */
    int cPRT_MOD_VB_OBJ = 1;
   
    // Recognizes phrases like "did not find evidence of FOCUS"
    DEPNode[] regnodes_PRT_MOD_VB_OBJ_IN_PMOD = new DEPNode[6];
    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[0]          = new DEPNode(DEPLib.NULL_ID,fromSet(iv_negParticlesSet));
//    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[0].form     = DependencyRegex.fromSet(iv_negParticlesSet);
    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[0].setLabel(DEPLibEn.DEP_NEG); // was:("ADV");
    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[1]          = new DEPNode(DEPLib.NULL_ID,fromSet(iv_modalVerbsSet));
//    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[1].form     = DependencyRegex.fromSet(iv_modalVerbsSet);
    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[1].setLabel(DEPLibEn.DEP_CCOMP); // was: ("VC");
    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[2]          = new DEPNode(DEPLib.NULL_ID,fromSet(iv_regVerbsSet));
//    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[2].form     = DependencyRegex.fromSet(iv_regVerbsSet);
    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[3]          = new DEPNode(DEPLib.NULL_ID,fromSet(iv_regNounsSet));
//    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[3].form     = DependencyRegex.fromSet(iv_regNounsSet);
    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[3].setLabel(DEPLibEn.DEP_DOBJ); //("OBJ");
    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[4]        = new DEPNode(DEPLib.NULL_ID,fromSet(iv_regPrepositionsSet));
//    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[4].form   = DependencyRegex.fromSet(iv_regPrepositionsSet);
    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[4].pos    = "IN";
    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[5]        = new DEPNode(DEPLib.NULL_ID,ANY_TOKEN);
    regnodes_PRT_MOD_VB_OBJ_IN_PMOD[5].setLabel(DEPLibEn.DEP_POBJ); // was: ("PMOD");   
    int cPRT_MOD_VB_OBJ_IN_PMOD = 1;
   
    // Recognizes phrases like "excluding FOCUS"
    DEPNode[] regnodes_VBN_SBJ = new DEPNode[2];
    regnodes_VBN_SBJ[0]        = new DEPNode(DEPLib.NULL_ID, fromSet(iv_negVerbsSet));
//    regnodes_VBN_SBJ[0].form   = DependencyRegex.fromSet(iv_negVerbsSet);
    regnodes_VBN_SBJ[0].pos    = "VBG"// was VBN
    regnodes_VBN_SBJ[1]       = new DEPNode(DEPLib.NULL_ID, ANY_TOKEN);
    regnodes_VBN_SBJ[1].setLabel(DEPLibEn.DEP_DOBJ); // was: ("SBJ");
    int cVBN_SBJ = 0;
   
    // Recognizes phrases like "rules out FOCUS"
    DEPNode[] regnodes_PRT_rule_OBJ = new DEPNode[3];
    regnodes_PRT_rule_OBJ[0]          = new DEPNode(DEPLib.NULL_ID, fromSet(iv_negColPartSet));
//    regnodes_PRT_rule_OBJ[0].form     = DependencyRegex.fromSet(iv_negColPartSet);
    regnodes_PRT_rule_OBJ[0].setLabel(DEPLibEn.DEP_PRT); // was: ("PRT");
    regnodes_PRT_rule_OBJ[1]          = new DEPNode(DEPLib.NULL_ID, fromSet(iv_negCollocSet));
//    regnodes_PRT_rule_OBJ[1].form     = DependencyRegex.fromSet(iv_negCollocSet);
    regnodes_PRT_rule_OBJ[2]          = new DEPNode(DEPLib.NULL_ID, ANY_TOKEN);
    regnodes_PRT_rule_OBJ[2].setLabel(DEPLibEn.DEP_DOBJ); //("OBJ");
    int cPRT_rule_OBJ = 1;
   
    //// Noun-ish rules
    // Recognizes phrases like "no pain"
    DEPNode[] regnodes_DT_NMOD   = new DEPNode[2];
    regnodes_DT_NMOD[0]          = new DEPNode(NULL_ID, fromSet(iv_negDetPlusPrepSet));
//    regnodes_DT_NMOD[0].form     = DependencyRegex.fromSet(iv_negDetPlusPrepSet);
    regnodes_DT_NMOD[0].setLabel(DEP_DET); // was: ("NMOD");
    regnodes_DT_NMOD[1]          = new DEPNode(NULL_ID, ANY_TOKEN);
    regnodes_DT_NMOD[1].pos      = DependencyRegex.ANY_NOUN;
    int cDT_NMOD = 1;

    // Recognizes phrases like "without pain"
    DEPNode[] regnodes_IN_PMOD   = new DEPNode[2];
    regnodes_IN_PMOD[0]          = new DEPNode(NULL_ID, fromSet(iv_negDetPlusPrepSet));
//    regnodes_IN_PMOD[0].form     = DependencyRegex.fromSet(iv_negDetPlusPrepSet);
    regnodes_IN_PMOD[0].setLabel(DEP_PMOD); // was: ("PMOD");
    regnodes_IN_PMOD[1]          = new DEPNode(NULL_ID, ANY_TOKEN);
    regnodes_IN_PMOD[1].pos      = DependencyRegex.ANY_NOUN;
    int cIN_PMOD = 0;
   
    // Recognizes phrases like "no history of FOCUS"
    DEPNode[] regnodes_DT_NN_IN_PMOD = new DEPNode[4];
    regnodes_DT_NN_IN_PMOD[0]        = new DEPNode(NULL_ID, fromSet(iv_negDetPlusPrepSet));
//    regnodes_DT_NN_IN_PMOD[0].form   = DependencyRegex.fromSet(iv_negDetPlusPrepSet);
//    regnodes_DT_NN_IN_PMOD[0].setLabel(DEP_PMOD + "|" + DEP_NMOD); // was: ("[NP]MOD");  // no convincing evidence that this can be restricted among the set of words listed above. (no would be det i think)
    regnodes_DT_NN_IN_PMOD[1]        = new DEPNode(NULL_ID, fromSet(iv_regNounsSet));
//    regnodes_DT_NN_IN_PMOD[1].form   = DependencyRegex.fromSet(iv_regNounsSet);
    regnodes_DT_NN_IN_PMOD[2]        = new DEPNode(NULL_ID, fromSet(iv_regPrepositionsSet));
//    regnodes_DT_NN_IN_PMOD[2].form   = DependencyRegex.fromSet(iv_regPrepositionsSet);
    regnodes_DT_NN_IN_PMOD[2].pos    = "IN";
    regnodes_DT_NN_IN_PMOD[3]        = new DEPNode(NULL_ID, ANY_TOKEN);
    regnodes_DT_NN_IN_PMOD[3].setLabel(DEP_POBJ); // was: ("PMOD");
    int cDT_NN_IN_PMOD = 1;
   
//    // Recognizes negative-adjective phrases like "is negative for carcinoma"
//    DEPNode[] regnodes_JJNEG_COP_IN_PMOD = new DEPNode[4];
//    regnodes_JJNEG_COP_IN_PMOD[0]        = new DEPNode();
//    regnodes_JJNEG_COP_IN_PMOD[0].form   = DependencyRegex.fromSet(iv_negAdjectivesSet);
//    regnodes_JJNEG_COP_IN_PMOD[1]        = new DEPNode();
//    regnodes_JJNEG_COP_IN_PMOD[1].pos    = DependencyRegex.ANY_VERB; // banking that people don't use double negatives
//    regnodes_JJNEG_COP_IN_PMOD[2]        = new DEPNode();
//    regnodes_JJNEG_COP_IN_PMOD[2].form   = DependencyRegex.fromSet(iv_regPrepositionsSet);
//    regnodes_JJNEG_COP_IN_PMOD[2].pos    = "IN";
//    regnodes_JJNEG_COP_IN_PMOD[3]        = new DEPNode();
//    regnodes_JJNEG_COP_IN_PMOD[3].deprel = "PMOD";
//    int cJJNEG_COP_IN_PMOD = 1;

    // Recognizes negative-adjective phrases like "negative for carcinoma"
    DEPNode[] regnodes_JJNEG_AMOD_PMOD = new DEPNode[3];
    regnodes_JJNEG_AMOD_PMOD[0]        = new DEPNode(NULL_ID, fromSet(iv_negAdjectivesSet));
//    regnodes_JJNEG_AMOD_PMOD[0].form   = DependencyRegex.fromSet(iv_negAdjectivesSet);
    regnodes_JJNEG_AMOD_PMOD[1]        = new DEPNode(NULL_ID, fromSet(iv_regPrepositionsSet));
//    regnodes_JJNEG_AMOD_PMOD[1].form   = DependencyRegex.fromSet(iv_regPrepositionsSet);
    regnodes_JJNEG_AMOD_PMOD[1].pos    = "IN";
    regnodes_JJNEG_AMOD_PMOD[2]        = new DEPNode(NULL_ID, ANY_TOKEN);
    regnodes_JJNEG_AMOD_PMOD[2].setLabel(DEP_POBJ); // was: ("PMOD");
    int cJJNEG_AMOD_PMOD = 0;
   
    // Recognizes negative-adjective phrases like "unlikely to have carcinoma"
    // FIXME - not sure this one works correctly -- this example parses weirdly in CVD.
    DEPNode[] regnodes_JJNEG_AMOD_IM_OBJ = new DEPNode[4];
    regnodes_JJNEG_AMOD_IM_OBJ[0]        = new DEPNode(NULL_ID, fromSet(iv_negAdjectivesSet));
//    regnodes_JJNEG_AMOD_IM_OBJ[0].form   = DependencyRegex.fromSet(iv_negAdjectivesSet);
    regnodes_JJNEG_AMOD_IM_OBJ[1]        = new DEPNode(NULL_ID, ANY_TOKEN);
    regnodes_JJNEG_AMOD_IM_OBJ[1].setLabel(DEP_AMOD); // was: ("AMOD");
    regnodes_JJNEG_AMOD_IM_OBJ[2]        = new DEPNode(NULL_ID, ANY_TOKEN);
    regnodes_JJNEG_AMOD_IM_OBJ[2].setLabel(DEP_INFMOD); // was: ("IM");
    regnodes_JJNEG_AMOD_IM_OBJ[3]        = new DEPNode(NULL_ID, ANY_TOKEN);
    regnodes_JJNEG_AMOD_IM_OBJ[3].setLabel(DEP_DOBJ); // was: ("OBJ");
    int cJJNEG_AMOD_IM_OBJ = 0;
   
    // Recognizes negative-adjective phrases like "unlikely carcinoma"
    DEPNode[] regnodes_JJNEG_NN = new DEPNode[2];
    regnodes_JJNEG_NN[0]        = new DEPNode(NULL_ID, fromSet(iv_negAdjectivesSet));
//    regnodes_JJNEG_NN[0].form   = DependencyRegex.fromSet(iv_negAdjectivesSet);
    regnodes_JJNEG_NN[1]        = new DEPNode(NULL_ID, ANY_TOKEN);
    regnodes_JJNEG_NN[1].pos    = DependencyRegex.ANY_NOUN;
    int cJJNEG_NN = 1;
   
   
    // Add the verb-ish rules to the set of regexes to search
View Full Code Here

      DEPTree tree = new DEPTree();

      // Convert CAS data into structures usable by ClearNLP
      for (int i = 0; i < tokens.size(); i++) {
        BaseToken token = tokens.get(i);
        DEPNode node = new DEPNode(i+1, token.getCoveredText());
        tree.add(node);
      }

      // Run parser and convert output back to CAS friendly data types
      postagger.process(tree);
     
      for (int i = 0; i < tokens.size(); i++) {
        BaseToken token = tokens.get(i);
        DEPNode node = tree.get(i+1);
        token.setPartOfSpeech(node.pos);
      }
     
    }
   
View Full Code Here

       
        // Set values in all the other nodes
        for (int i=1; i<clearTree.size(); i++) {
           

            DEPNode clearNode = clearTree.get(i);
            ConllDependencyNode uimaNode = uimaNodes.get(i);

            uimaNode.setId(clearNode.id);
            uimaNode.setForm(clearNode.form);
            uimaNode.setLemma(clearNode.lemma);
            uimaNode.setCpostag(clearNode.pos);
            uimaNode.setPostag(clearNode.pos);
            uimaNode.setFeats("_");
            uimaNode.setHead(uimaNodes.get(clearNode.getHead().id));
            uimaNode.setDeprel(clearNode.getLabel());
            uimaNode.setPhead(null);
            uimaNode.setPdeprel("_");

            
       }
View Full Code Here

      // Convert CAS data into structures usable by ClearNLP
      for (int i = 0; i < tokens.size(); i++) {
        BaseToken token = tokens.get(i);
        String lemma = useLemmatizer ? lemmatizer.getLemma(token.getCoveredText(), token.getPartOfSpeech()) : token.getNormalizedForm();
        DEPNode node = new DEPNode(i+1, token.getCoveredText(), lemma, token.getPartOfSpeech(), new DEPFeat());
        tree.add(node);
      }

      // Run parser and convert output back to CAS friendly data types
      parser.process(tree);
View Full Code Here

        int id = i + 1;
        String form = casDepNode.getForm();
        String pos = casDepNode.getPostag();
        String lemma = casDepNode.getLemma();
       
        DEPNode node = new DEPNode(id, form, lemma, pos, new DEPFeat());
        tree.add(node);
      }

      for (int i=1; i<tree.size(); i++)
      {
        DEPNode node = tree.get(i);
        DEPNode head = tree.get(headIDs[i-1]);
        String  label = deprels[i-1];
        node.setHead(head, label);
      }
     
      tree.initSHeads();
View Full Code Here

    Map<DEPNode, Predicate> headIdToPredicate = new HashMap<DEPNode, Predicate>();
    Map<Predicate, List<SemanticArgument>> predicateArguments = new HashMap<Predicate, List<SemanticArgument>>();

    for (int i = 1; i < tree.size(); i++) {
        // Every ClearNLP parserNode will contain an srlInfo field.
        DEPNode parserNode = tree.get(i);
        BaseToken token = tokens.get(i - 1);
        String rolesetId;
       
        if ((rolesetId = parserNode.getFeat(DEPLib.FEAT_PB)) != null)
        {
          if (!headIdToPredicate.containsKey(parserNode)) {
            // We have not encountered this predicate yet, so create it
            Predicate pred = this.createPredicate(jCas, rolesetId, token);
            headIdToPredicate.put(parserNode, pred);
            pred.setRelations(new EmptyFSList(jCas));
          }
        }
    }
   
   
    // Start at node 1, since node 0 is considered the head of the sentence
    for (int i = 1; i < tree.size(); i++) {
      // Every ClearNLP parserNode will contain an srlInfo field.
      DEPNode parserNode = tree.get(i);
      BaseToken token = tokens.get(i - 1);
    
      for (DEPArc head : parserNode.getSHeads()) {
          Predicate predicate = headIdToPredicate.get(head.getNode());

          // Append this argument to the predicate's list of arguments
          if (!predicateArguments.containsKey(predicate)) {
            predicateArguments.put(predicate, new ArrayList<SemanticArgument>());
View Full Code Here

TOP

Related Classes of com.googlecode.clearnlp.dependency.DEPNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.