Package org.apache.uima.cas

Examples of org.apache.uima.cas.FSIterator


    return ret;
  }

  public static ArrayList<Sentence> selectSentence (JCas jcas) {
    ArrayList<Sentence> ret = new ArrayList<Sentence>();
    FSIterator iter = jcas.getJFSIndexRepository().getAnnotationIndex(Sentence.type).iterator();
    while (iter.hasNext())
      ret.add((Sentence)iter.next());
    java.util.Collections.sort(ret, new AnnotOffsetComparator());
    return ret;
  }
View Full Code Here


  public static ArrayList<WordToken> selectPronoun (JCas jcas,
      HashSet<String> modalAdj, HashSet<String> cogved, HashSet<String> othervb,
      Logger logger) {
    Hashtable<String, WordToken> offset2token = new Hashtable<String, WordToken>();
    ArrayList<WordToken> ret = new ArrayList<WordToken>();
    FSIterator iter = jcas.getJFSIndexRepository().getAnnotationIndex(WordToken.type).iterator();
    while (iter.hasNext()) {
      WordToken t = (WordToken)iter.next();
      String s = t.getCoveredText();
      if (//s.equalsIgnoreCase("it") ||
        s.equalsIgnoreCase("its") ||
        s.equalsIgnoreCase("they") ||
        s.equalsIgnoreCase("their") ||
        s.equalsIgnoreCase("them") ||
        s.equalsIgnoreCase("theirs"))
        ret.add(t);
      if (s.equalsIgnoreCase("it"))
        offset2token.put(t.getBegin()+"-"+t.getEnd(), t);
    }

    iter = jcas.getJFSIndexRepository().getAnnotationIndex(TerminalTreebankNode.type).iterator();
    while (iter.hasNext()) {
      TerminalTreebankNode ttn = (TerminalTreebankNode) iter.next();
      if (ttn.getCoveredText().equalsIgnoreCase("it"))
        if (isPleonastic(ttn, modalAdj, cogved, othervb))
          logger.info("Pleonastic \"it\" at position "+
              ttn.getIndex()+" of \""+
              MarkableTreeUtils.getRoot(ttn).getCoveredText()+"\"");
View Full Code Here

    else return false;
  }

  public static ArrayList<Chunk> selectDemonAndRelative (JCas jcas) {
    ArrayList<Chunk> ret = new ArrayList<Chunk>();
    FSIterator iter = jcas.getJFSIndexRepository().getAnnotationIndex(Chunk.type).iterator();
    while (iter.hasNext()) {
      Chunk c = (Chunk)iter.next();
      if (c.getChunkType().equals("NP")) {
        String s = c.getCoveredText().toLowerCase();
        if (s.startsWith("these") ||
          s.startsWith("those") ||
          s.startsWith("this") ||
View Full Code Here

  }

  public String calcNPHead () {
    Annotation a = m1.getContent();
//    return (a.getEnd()==m1.getEnd() && a.getBegin()>m1.getBegin()) ? "yes" : "no";
    FSIterator iter = jcas.getJFSIndexRepository().getAnnotationIndex(LookupWindowAnnotation.type).iterator();
    while (iter.hasNext()) {
      LookupWindowAnnotation lwa = (LookupWindowAnnotation) iter.next();
      if (lwa.getBegin()<=a.getBegin() && lwa.getEnd()==a.getEnd())
        return "yes";
    }
    return "no";
  }
View Full Code Here

      if (outputDir != null) {
        // try to retreive the filename of the input file from the CAS
        File outFile = null;
        Type srcDocInfoType = aCas.getTypeSystem().getType("org.apache.uima.examples.SourceDocumentInformation");
        if (srcDocInfoType != null) {
          FSIterator it = aCas.getIndexRepository().getAllIndexedFS(srcDocInfoType);
          if (it.hasNext()) {
            FeatureStructure srcDocInfoFs = it.get();
            Feature uriFeat = srcDocInfoType.getFeatureByBaseName("uri");
            Feature offsetInSourceFeat = srcDocInfoType.getFeatureByBaseName("offsetInSource");
            String uri = srcDocInfoFs.getStringValue(uriFeat);
            int offsetInSource = srcDocInfoFs.getIntValue(offsetInSourceFeat);
            File inFile;
View Full Code Here

        // try to retreive the filename of the input file from the CAS
        File outFile = null;
        Type srcDocInfoType = aCas.getTypeSystem().getType(
                "org.apache.uima.examples.SourceDocumentInformation");
        if (srcDocInfoType != null) {
          FSIterator it = aCas.getIndexRepository().getAllIndexedFS(srcDocInfoType);
          if (it.hasNext()) {
            FeatureStructure srcDocInfoFs = it.get();
            Feature uriFeat = srcDocInfoType.getFeatureByBaseName("uri");
            Feature offsetInSourceFeat = srcDocInfoType.getFeatureByBaseName("offsetInSource");
            String uri = srcDocInfoFs.getStringValue(uriFeat);
            int offsetInSource = srcDocInfoFs.getIntValue(offsetInSourceFeat);
            File inFile;
View Full Code Here

   *
   * @return - feature value as int
   */
  public static int getIntFeatValue(CAS aCasView, String aTypeS, String aFeatS) {
    int result = 0;
    FSIterator idIter = aCasView.getAnnotationIndex(aCasView.getTypeSystem().getType(aTypeS)).iterator();
    while (idIter != null && idIter.isValid()) {
      org.apache.uima.cas.FeatureStructure idFS = idIter.get();
      result = idFS.getIntValue(aCasView.getTypeSystem().getFeatureByFullName(aTypeS + ":" + aFeatS));
      idIter.moveToNext();
    }
    return result;
  }
View Full Code Here

   *
   * @return feature value as string
   */
  public static String getStringFeatValue(CAS aCasView, String aTypeS, String aFeatS) {
    String result = null;
    FSIterator idIter = aCasView.getAnnotationIndex(aCasView.getTypeSystem().getType(aTypeS))
            .iterator();
    while (idIter != null && idIter.isValid()) {
      org.apache.uima.cas.FeatureStructure idFS = idIter.get();
      result = idFS.getStringValue(aCasView.getTypeSystem().getFeatureByFullName(
              aTypeS + ":" + aFeatS));
      idIter.moveToNext();
    }
    return result;
  }
View Full Code Here

   *
   * @return the first Feature Structure of a given type
   */
  public static FeatureStructure getTcasFS(CAS aCasView, String aTypeS) {
    org.apache.uima.cas.FeatureStructure idFS = null;
    FSIterator idIter = aCasView.getAnnotationIndex(aCasView.getTypeSystem().getType(aTypeS)).iterator();
    while (idIter != null && idIter.isValid()) {
      idFS = idIter.get();
      idIter.moveToNext();
    }
    return idFS;
  }
View Full Code Here

      // Extract CAS
      // UIMAFramework.getLogger().log("CAS ACount::" +
      // cas.getAnnotationIndex().size());
      int totalAnnots = 0;
      SofaFS sofa;
      FSIterator sItr = cas.getSofaIterator();
      while (sItr.isValid()) {
        sofa = (SofaFS) sItr.get();
        totalAnnots += cas.getView(sofa).getAnnotationIndex().size();
        sItr.moveToNext();
      }
      UIMAFramework.getLogger().log(Level.FINEST, "CAS ACount::" + totalAnnots);
      ct.setCommand(null);
      return ct;
    } catch (Exception ex) {
View Full Code Here

TOP

Related Classes of org.apache.uima.cas.FSIterator

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.