Package org.apache.uima.cas.impl

Examples of org.apache.uima.cas.impl.LowLevelCAS


      casEx.initCause(e);
      throw casEx;     
    }

    private int getSofaNbr(int addr, CASImpl casView) {
      final LowLevelCAS llCas = casView.getLowLevelCAS();
      final int sofa = llCas.ll_getIntValue(addr, annotSofaFeatCode, false);
      return (sofa == 0) ? 0 : llCas.ll_getIntValue(sofa, sofaNbrFeatCode);
    }
View Full Code Here


  // }

  /** return the indexed value from the corresponding Cas FSArray as a Java Model object. */
  public FeatureStructure get(int i) {
    jcasType.casImpl.checkArrayBounds(addr, i);
    final LowLevelCAS ll_cas = jcasType.ll_cas;
    return ll_cas.ll_getFSForRef(ll_cas.ll_getRefArrayValue(addr, i));
  }
View Full Code Here

      casEx.initCause(e);
      throw casEx;
    }

    private int getSofaNbr(int addr, CASImpl casView) {
      final LowLevelCAS llCas = casView.getLowLevelCAS();
      final int sofa = llCas.ll_getIntValue(addr, annotSofaFeatCode, false);
      return (sofa == 0) ? 0 : llCas.ll_getIntValue(sofa, sofaNbrFeatCode);
    }
View Full Code Here

        System.out.println(e2);
      }

      CAS localCas = jcas.getCas();
      assertTrue(localCas == this.cas);
      LowLevelCAS ll_cas = jcas.getLowLevelCas();
      assertTrue(ll_cas == this.cas);
      CASImpl casImpl = jcas.getCasImpl();
      assertTrue(casImpl == this.cas);
      TOP_Type type = jcas.getType(org.apache.uima.jcas.tcas.Annotation.type);
      assertTrue(type instanceof org.apache.uima.jcas.tcas.Annotation_Type);
View Full Code Here

  public void testAnnotationWithNullSofaRef() throws Exception {
    CAS srcCas = CasCreationUtils.createCas(typeSystem, new TypePriorities_impl(), indexes);
    CAS srcCasView = srcCas.createView("TestView");
    srcCasView.setDocumentText("This is a test");
    CAS destCas = CasCreationUtils.createCas(typeSystem, new TypePriorities_impl(), indexes);
    LowLevelCAS lowLevelSrcCasView = srcCasView.getLowLevelCAS();
    int typeCode = lowLevelSrcCasView.ll_getTypeSystem().ll_getCodeForType(
            srcCas.getAnnotationType());
    int destFsAddr = lowLevelSrcCasView.ll_createFS(typeCode);
    AnnotationFS fs = (AnnotationFS) lowLevelSrcCasView.ll_getFSForRef(destFsAddr);
    fs.setIntValue(srcCas.getBeginFeature(), 0);
    fs.setIntValue(srcCas.getEndFeature(), 4);
    assertEquals("This", fs.getCoveredText());
    srcCasView.addFsToIndexes(fs);
    CasCopier.copyCas(srcCas, destCas, true);
View Full Code Here

  // }

  /** return the indexed value from the corresponding Cas FSArray as a Java Model object. */
  public FeatureStructure get(int i) {
    jcasType.casImpl.checkArrayBounds(addr, i);
    final LowLevelCAS ll_cas = jcasType.ll_cas;
    return ll_cas.ll_getFSForRef(ll_cas.ll_getRefArrayValue(addr, i));
  }
View Full Code Here

    // Regression: toString() used to fail because string subtypes were
    // incorrectly classified as ref types.
    lp.toString();

    LowLevelCAS llc = this.cas.getLowLevelCAS();
    LowLevelTypeSystem llts = llc.ll_getTypeSystem();
    final int tokenTypeCode = llts.ll_getCodeForType(this.tokenType);
    final int addr = llc.ll_createFS(tokenTypeCode);
    final int lemmaFeatCode = llts.ll_getCodeForFeature(this.lemmaFeat);
    llc.ll_setStringValue(addr, lemmaFeatCode, "test", true);
    assertTrue(llc.ll_getCharBufferValueSize(addr, lemmaFeatCode) == 4);

  }
View Full Code Here

  public void testAnnotationWithNullSofaRef() throws Exception {
    CAS srcCas = CasCreationUtils.createCas(typeSystem, new TypePriorities_impl(), indexes);
    CAS srcCasView = srcCas.createView("TestView");
    srcCasView.setDocumentText("This is a test");
    CAS destCas = CasCreationUtils.createCas(typeSystem, new TypePriorities_impl(), indexes);
    LowLevelCAS lowLevelSrcCasView = srcCasView.getLowLevelCAS();
    int typeCode = lowLevelSrcCasView.ll_getTypeSystem().ll_getCodeForType(
            srcCas.getAnnotationType());
    int destFsAddr = lowLevelSrcCasView.ll_createFS(typeCode);
    AnnotationFS fs = (AnnotationFS) lowLevelSrcCasView.ll_getFSForRef(destFsAddr);
    fs.setIntValue(srcCas.getBeginFeature(), 0);
    fs.setIntValue(srcCas.getEndFeature(), 4);
    assertEquals("This", fs.getCoveredText());
    srcCasView.addFsToIndexes(fs);
    CasCopier.copyCas(srcCas, destCas, true);
View Full Code Here

    }
    assertTrue(exCaught);
  }

  public void testLowLevelCas() {
    LowLevelCAS cas = this.jcas.getLowLevelCas();
    LowLevelTypeSystem ts = cas.ll_getTypeSystem();
    final int annotType = ts.ll_getCodeForTypeName(annotationTypeName);
    final int addr = cas.ll_createFS(annotType);
    final int stringSetFeat = ts.ll_getCodeForFeatureName(annotationTypeName
  + TypeSystem.FEATURE_SEPARATOR + stringSetFeatureName);
    cas.ll_setStringValue(addr, stringSetFeat, definedValue1);
    cas.ll_setStringValue(addr, stringSetFeat, definedValue2);
    cas.ll_setStringValue(addr, stringSetFeat, definedValue3);
    boolean exCaught = false;
    try {
      cas.ll_setStringValue(addr, stringSetFeat, undefinedValue);
    } catch (CASRuntimeException e) {
      exCaught = true;
    }
    assertTrue(exCaught);
  }
View Full Code Here

        ResourceInitializationException.CONFIG_SETTING_ABSENT,
        new Object[] { "outputFile" });
    }

    //get low level CAS
    LowLevelCAS ll_cas = aCAS.getLowLevelCAS();

    //get low level TypeSystem
    LowLevelTypeSystem ll_typeSystem = ll_cas.ll_getTypeSystem();

    //get types and feature interessted in
    HashMap types = processTofs(aCAS, this.tofs);

    try
    {
      //iterate and print annotations
      FSIterator typeIterator = aCAS.getAnnotationIndex().iterator();

      for (typeIterator.moveToFirst(); typeIterator.isValid(); typeIterator.moveToNext())
      {
        Iterator it = types.keySet().iterator();

        while (it.hasNext())
        {
          //get current type and features
          Type currentType = (Type) it.next();
          boolean isFeatureOnly = false;
         
          ArrayList featureList = (ArrayList) types.get(currentType);
          if(featureList.size() >0 && featureList.get(0).equals(featureOnlyKey)){
            featureList.remove(0);
            isFeatureOnly = true;
          }
          Feature[] features = (Feature[]) featureList.toArray(new Feature[] {
          });
         
          AnnotationFS annot = (AnnotationFS) typeIterator.get();

          if (annot.getType().getName() == currentType.getName())
          {
            //only for formatting necessary
            boolean firstFeature = true;

            String span = annot.getCoveredText();
            if(!isFeatureOnly){
              this.fileWriter.write(
                annot.getType().getShortName()
                  + "(" + annot.getBegin() + "," + annot.getEnd()  + "): "  + span);
            }else{
              this.fileWriter.write(
                annot.getType().getShortName()
                  + ": ");
            }

            for (int f = 0; f < features.length; f++)
            {
              if (firstFeature)
              {
                this.fileWriter.write("  { ");
                firstFeature = false;
              }
              else
              {
                this.fileWriter.write(", ");
              }

              Feature fs = features[f];
              int typeClass = ll_cas.ll_getTypeClass(ll_typeSystem.ll_getCodeForType(fs.getRange()));
              this.fileWriter.write(fs.getShortName() + "=");
             
              switch (typeClass)
              {
                case LowLevelCAS.TYPE_CLASS_FLOAT :
View Full Code Here

TOP

Related Classes of org.apache.uima.cas.impl.LowLevelCAS

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.