Exemple #1
0
    def test_FeatureValsetNget(self):
        typeSystemFilePath = 'typesystem.xml'
        typesystem = TypeSystemFactory.readTypeSystem(self, typeSystemFilePath)
        tokenType = 'de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token'
        fsTokenType = typesystem.getType(tokenType)
        posType = 'de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS'
        fsPosType = typesystem.getType(posType)

        fsToken = TOP(fsTokenType, 1, typesystem)

        aFeature = Feature(fsToken.FStype, 'pos')
        aFeature.description = ''
        aFeature.rangeType = typesystem.getType(
            'de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS')

        fsPOS = Annotation(fsPosType, 1, typesystem)
        fsPOS.PosValue = "DT"

        fsToken.setFeatureValue(aFeature, fsPOS)
        self.assertEqual(fsToken.getFeatureValue(aFeature), fsPOS)
Exemple #2
0
    def test_setFeatureVal_Fail(self):
        typeSystemFilePath = 'typesystem.xml'
        typesystem = TypeSystemFactory.readTypeSystem(self, typeSystemFilePath)
        fstype4 = typesystem.getType(
            'de.tudarmstadt.ukp.dkpro.core.api.metadata.type.TagDescription')
        fsTagDesc1 = TOP(fstype4, 1, typesystem)
        aFeature = Feature(fsTagDesc1.FStype, 'name')
        aFeature.description = ''
        aFeature.elementType = typesystem.getType(
            'de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS')

        self.assertEqual('', '')
        with self.assertRaises(TypeError):
            fsTagDesc1.setFeatureValue(aFeature, 10.1)
        with self.assertRaises(TypeError):
            nonfeature = 1
            fsTagDesc1.setComplexValue(nonfeature, 878)
        with self.assertRaises(TypeError):
            aFeature.elementType = None
            fsTagDesc1.setComplexValue(aFeature, 878)
        with self.assertRaises(TypeError):
            aFeature.elementType = 'uima.cas.Integer'
            fsTagDesc1.setComplexValue(aFeature, 878)