Package org.apache.ctakes.coreference.type

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


    //    int ind = 0;
    iter = jcas.getJFSIndexRepository().getAllIndexedFS(MarkablePairSet.type);
    while(iter.hasNext()){
      //      VecInstance vec = (VecInstance) iter.next();
      MarkablePairSet pair = (MarkablePairSet) iter.next();
      Markable anaphor = pair.getAnaphor();
      String corefType = (anaphor instanceof NEMarkable ? CorefConsts.NE : (anaphor instanceof DemMarkable ? CorefConsts.DEM : CorefConsts.PRON));
      //      String nodeStr = vec.getVector();
      //      int label = getLabel(nodeStr);
      FSList pairList = pair.getAntecedentList();
      while(pairList instanceof NonEmptyFSList){
        NonEmptyFSList node = (NonEmptyFSList) pairList;
        BooleanLabeledFS labeledProb = (BooleanLabeledFS) node.getHead();
        int label = labeledProb.getLabel() ? 1 : 0;
        if(anaphora){
View Full Code Here


      m2q.put((Markable)lm.get(p), p);
    }
   
    FSIterator<Annotation> iter = jcas.getAnnotationIndex(MarkablePairSet.type).iterator();
    while(iter.hasNext()){
      MarkablePairSet set = (MarkablePairSet) iter.next();
      Markable anaphor = set.getAnaphor();
      FSList fs = (FSList) set.getAntecedentList();
      MarkableProb bestAnte = null;
      LinkedList<Markable> ll = fs2ll(fs);
      if(anaphor instanceof PronounMarkable){
        bestAnte = processPronoun(anaphor, ll, jcas);
      }else if(anaphor instanceof NEMarkable){
View Full Code Here

    //    int ind = 0;
    iter = jcas.getJFSIndexRepository().getAllIndexedFS(MarkablePairSet.type);
    while(iter.hasNext()){
      //      VecInstance vec = (VecInstance) iter.next();
      MarkablePairSet pair = (MarkablePairSet) iter.next();
      Markable anaphor = pair.getAnaphor();
      String corefType = (anaphor instanceof NEMarkable ? CorefConsts.NE : (anaphor instanceof DemMarkable ? CorefConsts.DEM : CorefConsts.PRON));
      //      String nodeStr = vec.getVector();
      //      int label = getLabel(nodeStr);
      FSList pairList = pair.getAntecedentList();
      while(pairList instanceof NonEmptyFSList){
        NonEmptyFSList node = (NonEmptyFSList) pairList;
        BooleanLabeledFS labeledProb = (BooleanLabeledFS) node.getHead();
        int label = labeledProb.getLabel() ? 1 : 0;
//        if(anaphora){
View Full Code Here

      m2q.put((Markable)lm.get(p), p);
    }
     
    FSIterator<Annotation> iter = jcas.getAnnotationIndex(MarkablePairSet.type).iterator();
    while(iter.hasNext()){
      MarkablePairSet set = (MarkablePairSet) iter.next();
      Markable anaphor = set.getAnaphor();
      FSList fs = (FSList) set.getAntecedentList();
      MarkableProb bestAnte = null;
      LinkedList<Markable> ll = fs2ll(fs);
      if(anaphor instanceof PronounMarkable){
        // There is not enough training data to do this reliably... the
        // classifier for this type will decrease scores
View Full Code Here

//    maxSpanID += sa.getMaxID();
  }

  private void createCorefPairs(LinkedList<Annotation> lm, int p, JCas jcas) {
    NEMarkable m = (NEMarkable) lm.get(p); // Current markable under consideration
    MarkablePairSet pairList = new MarkablePairSet(jcas);
    pairList.setBegin(m.getBegin());
    pairList.setEnd(m.getEnd());
    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){
        tail = head;
      }else{
        tail.setTail(new NonEmptyFSList(jcas));
        tail = (NonEmptyFSList) tail.getTail();
      }
      tail.setHead(labeledAntecedent);
//      if (isGoldPair(a, m)){
//        labeledAntecedent.setLabel(true);
//        // FIXME this cannot be done, it's implicitly looking at the label and changing the possible outcomes...
//        break; // stop if a gold pair is found
//      }else{
//        labeledAntecedent.setLabel(false);
//      }
    }
    if(tail == null) pairList.setAntecedentList(new EmptyFSList(jcas));
    else tail.setTail(new EmptyFSList(jcas));
    numVecs++;
    pairList.addToIndexes();   
  }
View Full Code Here

    pairList.addToIndexes();   
  }

  private void createDemPairs(LinkedList<Annotation> lm, int p, JCas jcas) {
    DemMarkable m = (DemMarkable) lm.get(p); // Current markable under consideration
    MarkablePairSet pairList = new MarkablePairSet(jcas);
    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
      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);
      if(tail == null){
        tail = head;
      }else{
        tail.setTail(new NonEmptyFSList(jcas));
        tail = (NonEmptyFSList) tail.getTail();
      }
      tail.setHead(labeledAntecedent);
//      if (isGoldPair(a, m)){
//        // FIXME
//        labeledAntecedent.setLabel(true);
//        break; // stop if a gold pair is found
//      }else{
//        labeledAntecedent.setLabel(false);
//      }
    }
    if(tail == null) pairList.setAntecedentList(new EmptyFSList(jcas));
    else tail.setTail(new EmptyFSList(jcas));
    numVecs++;
    pairList.addToIndexes();
  }
View Full Code Here

    pairList.addToIndexes();
  }

  private void createPronPairs(LinkedList<Annotation> lm, int p, JCas jcas) {
    PronounMarkable m = (PronounMarkable) lm.get(p); // Current markable under consideration
    MarkablePairSet pairList = new MarkablePairSet(jcas);
    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
      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);
      if(tail == null){
        tail = head;
      }else{
        tail.setTail(new NonEmptyFSList(jcas));
        tail = (NonEmptyFSList) tail.getTail();
      }
      tail.setHead(labeledAntecedent);
//      if (isGoldPair(a, m)){
//        // FIXME
//        labeledAntecedent.setLabel(true);
//        break; // stop if a gold pair is found
//      }else{
//        labeledAntecedent.setLabel(false);
//      }
    }
    if(tail == null) pairList.setAntecedentList(new EmptyFSList(jcas));
    else tail.setTail(new EmptyFSList(jcas));
    numVecs++;
    pairList.addToIndexes();
  }
View Full Code Here

TOP

Related Classes of org.apache.ctakes.coreference.type.MarkablePairSet

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.