Examples of Markable


Examples of org.apache.ctakes.coreference.type.Markable

  private LinkedList<Markable> fs2ll(FSList fs) {
    LinkedList<Markable> ll = new LinkedList<Markable>();
    while(fs instanceof NonEmptyFSList){
      NonEmptyFSList node = (NonEmptyFSList) fs;
      BooleanLabeledFS feat = (BooleanLabeledFS) node.getHead();
      Markable antecedent = (Markable) feat.getFeature();
      ll.add(antecedent);
      fs = node.getTail();
    }
    return ll;
  }
View Full Code Here

Examples of org.apache.ctakes.coreference.type.Markable

  private void loadSystemPairs(List<Annotation> lm){
    Vector<int[]> sysPairs = new Vector<int[]>();
    // build system chains...
    for (int p = 1; p < lm.size(); ++p) {
      Markable m1 = (Markable) lm.get(p);
      int id1 = m1.getId();
      if (!sysSpan2id.containsKey(m1.getBegin()+"-"+m1.getEnd())) {
        sysSpan2id.put(m1.getBegin()+"-"+m1.getEnd(), id1);
        sysSpans.add(new Span(new int[]{m1.getBegin(), m1.getEnd()}));
      }
      for(int q = p-1; q >= 0; q--){
        Markable m2 = (Markable) lm.get(q);
        int id2 = m2.getId();
        if (!sysSpan2id.containsKey(m2.getBegin()+"-"+m2.getEnd())) {
          sysSpan2id.put(m2.getBegin()+"-"+m2.getEnd(), id2);
          sysSpans.add(new Span(new int[]{m2.getBegin(), m2.getEnd()}));
        }
        sysPairs.add(new int[]{id1, id2});

      }
    }
View Full Code Here

Examples of org.apache.ctakes.coreference.type.Markable

    }
    return ll;
  }
 
  private MarkableProb processPronoun(Markable anaphor, LinkedList<Markable> anteList, JCas jcas){
    Markable ante = null;
    double bestProb = 0.0;
    List<Markable> resortedList = anteList;
    for(Markable antecedent : resortedList){
      svm_node[] nodes = vecCreator.getNodeFeatures(anaphor, antecedent, jcas);
     
View Full Code Here

Examples of org.apache.ctakes.coreference.type.Markable

    }
    return new MarkableProb(ante, bestProb);
  }

  private MarkableProb processNE(Markable anaphor, List<Markable> anteList, JCas jcas){
    Markable ante = null;
    double bestProb = 0.0;
    for(Markable antecedent : anteList){
      svm_node[] nodes = vecCreator.getNodeFeatures(anaphor, antecedent, jcas, true);
      double prob = 0.0;
      prob = mod_coref.predict(nodes);
View Full Code Here

Examples of org.apache.ctakes.coreference.type.Markable

  private MarkableProb processDem(Markable anaphor, List<Markable> anteList, JCas jcas){
    double bestProb = 0.0;
    TreebankNode n = MarkableTreeUtils.markableNode(jcas, anaphor.getBegin(), anaphor.getEnd());
    TreebankNode parent = (n != null ? n.getParent() : null);
    TreebankNode gparent = (parent != null ? parent.getParent() : null);
    Markable ante = null;
    for(Markable antecedent: anteList){
      if(n!=null && parent != null && gparent != null && n.getNodeType().equals("WHNP") && parent.getNodeType().equals("SBAR")
          && gparent.getNodeType().equals("NP") && gparent.getChildren(1) == parent && gparent.getChildren(0).getNodeType().equals("NP")){
        TreebankNode anteNode = gparent.getChildren(0);
        Markable trueAnte = MarkableTreeUtils.nodeMarkable(jcas, anteNode.getBegin(), anteNode.getEnd());
        if(trueAnte == antecedent){
          bestProb = 1.0;
          ante = antecedent;
          break;
        }
View Full Code Here

Examples of org.apache.ctakes.coreference.type.Markable

//      sysId2AlignId.put(sysSpan2id.get(sysSpans.get(i).toString()), id[i]+maxSpanID);
//    }
    // now iterate over system markables and add the ones that match gold standard as
    // true, otherwise false
    for (int p = 1; p < lm.size(); ++p) {
      Markable m = (Markable) lm.get(p);
      Annotation mc = m.getContent();

      // if m is a pronoun
      if (m instanceof PronounMarkable &&
        ((BaseToken) mc).getPartOfSpeech().startsWith("PRP")){
          createPronPairs(lm, p, jcas);
View Full Code Here

Examples of org.apache.ctakes.coreference.type.Markable

    pairList.setAnaphor(m);
    NonEmptyFSList head = new NonEmptyFSList(jcas);
    pairList.setAntecedentList(head);
    NonEmptyFSList tail = null;
    for (int q = p-1; q>=0; --q) {
      Markable a = (Markable) lm.get(q); // Candidate antecedent

      // Don't link to a expletive
//      if (dnr.contains(m)) continue;
      // Look no more than 10 sentences
      int sentdist = sentDist(jcas, a, m);
      if (sentdist>CorefConsts.NEDIST) break;
//      else if (sentdist>PRODIST && m instanceof PronounMarkable) continue;
      // filter out if both are NEs but of diff types
      if (m.getContent() instanceof IdentifiedAnnotation &&
          a.getContent() instanceof IdentifiedAnnotation &&
          ((IdentifiedAnnotation)m.getContent()).getTypeID() != ((IdentifiedAnnotation)a.getContent()).getTypeID())
        continue;

      // filter out "which" that crosses sentence boundary
      if (a.getCoveredText().equalsIgnoreCase("which") &&
          sentDist(jcas, a, m)>=1)
        continue;
      // ban pairs that one markable is a sub/superspan of the other
      if ((a.getBegin()<=m.getBegin() && a.getEnd()>=m.getEnd()) ||
          m.getBegin()<=a.getBegin() && m.getEnd()>=a.getEnd())
        continue;
      // Create a vector
      BooleanLabeledFS labeledAntecedent = new BooleanLabeledFS(jcas);
      labeledAntecedent.setFeature(a);
      if(tail == null){
View Full Code Here

Examples of org.apache.ctakes.coreference.type.Markable

    NonEmptyFSList head = new NonEmptyFSList(jcas);
    pairList.setAntecedentList(head);
    NonEmptyFSList tail = null;

    for (int q = p-1; q>=0; --q) {
      Markable a = (Markable) lm.get(q); // Candidate antecedent
      if (sentDist(jcas, a, m)>CorefConsts.PRODIST) break; // Look no more than 3 sentences

      // Create a vector
      BooleanLabeledFS labeledAntecedent = new BooleanLabeledFS(jcas);
      labeledAntecedent.setFeature(a);
View Full Code Here

Examples of org.apache.ctakes.coreference.type.Markable

    NonEmptyFSList head = new NonEmptyFSList(jcas);
    pairList.setAntecedentList(head);
    NonEmptyFSList tail = null;
   
    for (int q = p-1; q>=0; --q) {
      Markable a = (Markable) lm.get(q); // Candidate antecedent
      if (sentDist(jcas, a, m)>CorefConsts.PRODIST) break// Look no more than 3 sentences

      if ((a.getBegin()<=m.getBegin() && a.getEnd()>=m.getEnd()) ||
          m.getBegin()<=a.getBegin() && m.getEnd()>=a.getEnd())
        continue;

      // Create a pair
      BooleanLabeledFS labeledAntecedent = new BooleanLabeledFS(jcas);
      labeledAntecedent.setFeature(a);
View Full Code Here

Examples of org.apache.ctakes.coreference.type.Markable

    }
   
    // now check if any of the NE markables share the exact same boundaries:
    FSIterator<Annotation> neIter = jcas.getAnnotationIndex(Markable.type).iterator();
    while(neIter.hasNext()){
      Markable nem = (Markable) neIter.next();
      innerMap = npMap.get(nem.getBegin());
      if(innerMap != null && innerMap.containsKey(nem.getEnd())){ 
        // found one!  Check if it has an NP parent and a PP sibling:
        TreebankNode node = innerMap.get(nem.getEnd());
        TreebankNode parent = node.getParent();
        if(parent.getChildren().size() == 2 && parent.getChildren(0) == node && parent.getNodeType().equals("NP") && parent.getChildren(1).getNodeType().equals("PP")){
          //   Jackpot!  Expand the original markable to be the whole NP -> NP PP construction.
          nem.setEnd(parent.getEnd());
        }
      }
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.