Examples of FeatureStructure


Examples of opennlp.ccg.unify.FeatureStructure

       
        //Pass up unbalanced punctuation indicator
       
        //Result cat of current has unbal feature
        Category target = sign.getCategory().getTarget();
        FeatureStructure fs = target.getFeatureStructure();
        String punctFeatVal=null;
        if ( (fs != null && fs.hasAttribute("unbal"))) {
          Object val = fs.getValue("unbal");
          punctFeatVal = (val instanceof SimpleType) ? ((SimpleType)val).getName() : null;
        }
       
        //Right child (binary case) or only child (unary case) has unbalanced punct feature
        SignProps childProps=(SignProps)inputs[inputs.length-1].getData(SignProps.class);
View Full Code Here

Examples of org.apache.stanbol.commons.caslight.FeatureStructure

        if (!localName.equals("result")) {
            elementCounter++;
            String type = localName;

            FeatureStructure fs = new FeatureStructure(sourceName + "." + localName + "#" + elementCounter, type);
            for (int i = 0; i < attrs.getLength(); i++) {
                String name = attrs.getQName(i);
                String value = attrs.getValue(i);
                if (checkIfInteger(value)) {
                    Feature<Integer> f = new Feature(name, value);
                    fs.addFeature(f);
                } else {
                    Feature<String> f = new Feature(name, value);
                    fs.addFeature(f);
                }
            }
            fsList.add(fs);

        }
View Full Code Here

Examples of org.apache.uima.cas.FeatureStructure

    Type entityType = cas.getTypeSystem().getType("org.apache.uima.testTypeSystem.Entity");
    Feature classesFeat = entityType.getFeatureByBaseName("classes");
    Iterator iter = cas.getIndexRepository().getIndex("testEntityIndex").iterator();
    assertTrue(iter.hasNext());
    while (iter.hasNext()) {
      FeatureStructure fs = (FeatureStructure) iter.next();
      StringArrayFS arrayFS = (StringArrayFS) fs.getFeatureValue(classesFeat);
      assertNotNull(arrayFS);
      for (int i = 0; i < arrayFS.size(); i++) {
        assertNotNull(arrayFS.get(i));
      }
    }
View Full Code Here

Examples of org.apache.uima.cas.FeatureStructure

    Type entityType = cas2.getTypeSystem().getType("org.apache.uima.testTypeSystem.Entity");
    Feature classesFeat = entityType.getFeatureByBaseName("classes");
    Iterator iter = cas2.getIndexRepository().getIndex("testEntityIndex").iterator();
    assertTrue(iter.hasNext());
    while (iter.hasNext()) {
      FeatureStructure fs = (FeatureStructure) iter.next();
      StringArrayFS arrayFS = (StringArrayFS) fs.getFeatureValue(classesFeat);
      assertNotNull(arrayFS);
      for (int i = 0; i < arrayFS.size(); i++) {
        assertNotNull(arrayFS.get(i));
      }
    }
View Full Code Here

Examples of org.apache.uima.cas.FeatureStructure

      array.get(0);
    } catch (ArrayIndexOutOfBoundsException e) {
      exceptionCaught = true;
    }
    assertTrue(exceptionCaught);
    FeatureStructure fs1 = this.cas.createFS(this.ts.getType(CAS.TYPE_NAME_ANNOTATION));
    FeatureStructure fs2 = this.cas.createFS(this.ts.getType(CAS.TYPE_NAME_TOP));
    FeatureStructure fs3 = this.cas.createFS(this.ts.getType(CASTestSetup.TOKEN_TYPE));
    array = this.cas.createArrayFS(3);
    try {
      array.set(0, fs1);
      array.set(1, fs2);
      array.set(2, fs3);
View Full Code Here

Examples of org.apache.uima.cas.FeatureStructure

    assertTrue(exceptionCaught);
  }

  public void testToArray() {
    // From CAS array to Java array.
    FeatureStructure fs1 = this.cas.createFS(this.ts.getType(CAS.TYPE_NAME_ANNOTATION));
    FeatureStructure fs2 = this.cas.createFS(this.ts.getType(CAS.TYPE_NAME_TOP));
    FeatureStructure fs3 = this.cas.createFS(this.ts.getType(CASTestSetup.TOKEN_TYPE));
    ArrayFS array = this.cas.createArrayFS(3);
    FeatureStructure[] fsArray = array.toArray();
    for (int i = 0; i < 3; i++) {
      assertTrue(fsArray[i] == null);
    }
View Full Code Here

Examples of org.apache.uima.cas.FeatureStructure

    final Feature lemmaList = this.ts.getFeatureByFullName(lemmaListName);
    assertTrue(lemmaList != null);
    String[] javaArray = { "1", "2", "3" };
    StringArrayFS casArray = this.cas.createStringArrayFS(3);
    casArray.copyFromArray(javaArray, 0, 0, 3);
    FeatureStructure token = this.cas.createFS(this.ts.getType(CASTestSetup.TOKEN_TYPE));
    assertTrue(token.getFeatureValue(lemmaList) == null);
    token.setFeatureValue(lemmaList, casArray);
    assertTrue(((StringArrayFS) token.getFeatureValue(lemmaList)).get(0) == "1");
    String hello = "Hello.";
    casArray.set(0, hello);
    assertTrue(((StringArrayFS) token.getFeatureValue(lemmaList)).get(0) == hello);
  }
View Full Code Here

Examples of org.apache.uima.cas.FeatureStructure

    Type entityType = cas2.getTypeSystem().getType("org.apache.uima.testTypeSystem.Entity");
    Feature classesFeat = entityType.getFeatureByBaseName("classes");
    Iterator iter = cas2.getIndexRepository().getIndex("testEntityIndex").iterator();
    assertTrue(iter.hasNext());
    while (iter.hasNext()) {
      FeatureStructure fs = (FeatureStructure) iter.next();
      StringArrayFS arrayFS = (StringArrayFS) fs.getFeatureValue(classesFeat);
      assertNotNull(arrayFS);
      for (int i = 0; i < arrayFS.size(); i++) {
        assertNotNull(arrayFS.get(i));
      }
    }
    Type annotArrayTestType = cas2.getTypeSystem().getType("org.apache.uima.testTypeSystem.AnnotationArrayTest");
    Feature annotArrayFeat = annotArrayTestType.getFeatureByBaseName("arrayOfAnnotations");
    Iterator iter2 = cas2.getAnnotationIndex(annotArrayTestType).iterator();
    assertTrue(iter2.hasNext());
    while (iter2.hasNext()) {
      FeatureStructure fs = (FeatureStructure) iter2.next();
      ArrayFS arrayFS = (ArrayFS) fs.getFeatureValue(annotArrayFeat);
      assertNotNull(arrayFS);
      for (int i = 0; i < arrayFS.size(); i++) {
        assertNotNull(arrayFS.get(i));
      }
    }
View Full Code Here

Examples of org.apache.uima.cas.FeatureStructure

      Type personType = cas2.getTypeSystem().getType("org.apache.uima.testTypeSystem.Person");
      FSIndex personIndex = cas2.getAnnotationIndex(personType);
      assertTrue(personIndex.size() > 0);

      // check that mentionType has been filtered out (set to null)
      FeatureStructure somePlace = personIndex.iterator().get();
      Feature mentionTypeFeat = personType.getFeatureByBaseName("mentionType");
      assertNotNull(mentionTypeFeat);
      assertNull(somePlace.getStringValue(mentionTypeFeat));
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
  }
View Full Code Here

Examples of org.apache.uima.cas.FeatureStructure

    Type relArgsType = newCas2.getTypeSystem().getType(
            "org.apache.uima.testTypeSystem.BinaryRelationArgs");
    Feature domainFeat = relArgsType.getFeatureByBaseName("domainValue");
    Feature rangeFeat = relArgsType.getFeatureByBaseName("rangeValue");
    AnnotationFS ownerAnnot = newCas2.createAnnotation(ownerType, 0, 70);
    FeatureStructure relArgs = newCas2.createFS(relArgsType);
    relArgs.setFeatureValue(domainFeat, person);
    relArgs.setFeatureValue(rangeFeat, org);
    ownerAnnot.setFeatureValue(argsFeat, relArgs);
    ownerAnnot.setStringValue(componentIdFeat, "XCasDeserializerTest");
    newCas2.addFsToIndexes(ownerAnnot);
    int orgBegin = org.getBegin();
    int orgEnd = org.getEnd();
   
    //add Sofas
    CAS newView1 = newCas1.createView("newSofa1");
    final String sofaText1 = "This is a new Sofa, created in CAS 1.";
    newView1.setDocumentText(sofaText1);
    final String annotText = "Sofa";
    int annotStart1 = sofaText1.indexOf(annotText);
    AnnotationFS annot1 = newView1.createAnnotation(orgType, annotStart1, annotStart1 + annotText.length());
    newView1.addFsToIndexes(annot1);
    CAS newView2 = newCas1.createView("newSofa2");
    final String sofaText2 = "This is another new Sofa, created in CAS 2.";
    newView2.setDocumentText(sofaText2);
    int annotStart2 = sofaText2.indexOf(annotText);
    AnnotationFS annot2 = newView2.createAnnotation(orgType, annotStart2, annotStart2 + annotText.length());
    newView2.addFsToIndexes(annot2);

    //re-serialize each new CAS back to XMI, keeping consistent ids
    String newSerCas1 = serialize(newCas1, deserSharedData1);
    String newSerCas2 = serialize(newCas2, deserSharedData2);
   
    //merge the two XMI CASes back into the original CAS
    XmiSerializationSharedData deserSharedData3 = new XmiSerializationSharedData();
    deserialize(newSerCas1, cas, deserSharedData3, false, -1);
   
    assertEquals(numAnnotations +2, cas.getAnnotationIndex().size());
   
    deserialize(newSerCas2, cas, deserSharedData3, false, maxOutgoingXmiId);
   
    assertEquals(numAnnotations + 5, cas.getAnnotationIndex().size());
   
    assertEquals(docText, cas.getDocumentText());
   
    //check covered text of annotations
    FSIterator iter = cas.getAnnotationIndex().iterator();
    while (iter.hasNext()) {
      AnnotationFS annot = (AnnotationFS)iter.next();
      assertEquals(cas.getDocumentText().substring(
              annot.getBegin(), annot.getEnd()), annot.getCoveredText());
    }
    //check Owner annotation we created to test link across merge boundary
    iter = cas.getAnnotationIndex(ownerType).iterator();
    while (iter.hasNext()) {
      AnnotationFS annot = (AnnotationFS)iter.next();
      String componentId = annot.getStringValue(componentIdFeat);
      if ("XCasDeserializerTest".equals(componentId)) {
        FeatureStructure targetRelArgs = annot.getFeatureValue(argsFeat);
        AnnotationFS targetDomain = (AnnotationFS)targetRelArgs.getFeatureValue(domainFeat);
        assertEquals(60, targetDomain.getBegin());
        assertEquals(70, targetDomain.getEnd());
        AnnotationFS targetRange = (AnnotationFS)targetRelArgs.getFeatureValue(rangeFeat);
        assertEquals(orgBegin, targetRange.getBegin());
        assertEquals(orgEnd, targetRange.getEnd());
      }    
    }
    //check Sofas
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.