Package org.apache.uima.cas.impl

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


 
  public static boolean isRestrictedByAllowedValues(TypeSystem ts, Type type) {
   
    if (ts.getType(CAS.TYPE_NAME_STRING).equals(type) ||
            ts.subsumes(ts.getType(CAS.TYPE_NAME_STRING), type)) {
      LowLevelTypeSystem lts = ts.getLowLevelTypeSystem();
      final int typeCode = lts.ll_getCodeForType(type);
      String[] strings = lts.ll_getStringSet(typeCode);
     
      return strings.length > 0;
    }
    else {
      return false;
View Full Code Here


  public static String[] getRestrictedValues(TypeSystem ts, Type type) {
    if (isRestrictedByAllowedValues(ts, type)) {
      throw new IllegalArgumentException("Type " + type.getName() + " does not defines allowed values!");
    }
   
    LowLevelTypeSystem lts = ts.getLowLevelTypeSystem();
    final int typeCode = lts.ll_getCodeForType(type);
   
    return lts.ll_getStringSet(typeCode);
  }
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

    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;
View Full Code Here

    //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

 
  public static boolean isRestrictedByAllowedValues(TypeSystem ts, Type type) {
   
    if (ts.getType(CAS.TYPE_NAME_STRING).equals(type) ||
            ts.subsumes(ts.getType(CAS.TYPE_NAME_STRING), type)) {
      LowLevelTypeSystem lts = ts.getLowLevelTypeSystem();
      final int typeCode = lts.ll_getCodeForType(type);
      String[] strings = lts.ll_getStringSet(typeCode);
     
      return strings.length > 0;
    }
    else {
      return false;
View Full Code Here

  public static String[] getRestrictedValues(TypeSystem ts, Type type) {
    if (isRestrictedByAllowedValues(ts, type)) {
      throw new IllegalArgumentException("Type " + type.getName() + " does not defines allowed values!");
    }
   
    LowLevelTypeSystem lts = ts.getLowLevelTypeSystem();
    final int typeCode = lts.ll_getCodeForType(type);
   
    return lts.ll_getStringSet(typeCode);
  }
View Full Code Here

   * @param aTypeSystem the type system to use
   * @return array of allowed values for <code>aType</code> TODO - this should be a method on
   *         Type.
   */
  public static String[] getAllowedValuesForType(Type aType, TypeSystem aTypeSystem) {
    LowLevelTypeSystem lts = aTypeSystem.getLowLevelTypeSystem();
    return lts.ll_getStringSet(lts.ll_getCodeForType(aType));
  }
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

   *          the type, which must be a subtype of uima.cas.String
   * @return array of allowed values for <code>aType</code> TODO - this should be a method on
   *         Type.
   */
  public static String[] getAllowedValuesForType(Type aType, TypeSystem aTypeSystem) {
    LowLevelTypeSystem lts = aTypeSystem.getLowLevelTypeSystem();
    return lts.ll_getStringSet(lts.ll_getCodeForType(aType));
  }
View Full Code Here

TOP

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

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.