예제 #1
0
 def test_BoolValsetNget(self):
     typeSystemFilePath = 'tests/testing_data/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 = 'uima.cas.Boolean'
     fsTagDesc1.setBoolValue(aFeature, False)
     self.assertEqual(fsTagDesc1.getBoolValue(aFeature), False)
예제 #2
0
    def test_ComplexValsetNget(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 = 'uima.cas.String'

        fsTagDesc1.setComplexValue(aFeature, 1j)
        self.assertEqual(complex(fsTagDesc1.getComplexValue(aFeature)), 1j)
예제 #3
0
    def test_ListValsetNget(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.rangeType = 'uima.cas.String'
        listval = []
        listval.append('#')
        fsTagDesc1.setListValue(aFeature, aFeature.rangeType, listval)
        self.assertEqual(' '.join(fsTagDesc1.getListValue(aFeature)), '#')
예제 #4
0
    def createFS(self, typeName, featureDict=None, FSid=-1):
        fsTopType = self.typesystem.getType(typeName)
        if ((not featureDict == None) and ('id' in featureDict)):
            fsid = self.__getCounter(FSid, featureDict['id'])
        else:
            fsid = self.__getCounter(FSid, None)

        topFs = TOP(fsTopType, fsid, self.typesystem)
        topFs.CAS = self
        if not featureDict == None:
            for key in featureDict:
                if not (key == 'id'):
                    setattr(topFs, key, featureDict[key])
        return topFs
예제 #5
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)
예제 #6
0
 def test_setComplexVal_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 = 'uima.cas.String'
     self.assertEqual('', '')
     with self.assertRaises(TypeError):
         fsTagDesc1.setComplexValue(aFeature, 10.1)
     with self.assertRaises(TypeError):
         nonfeature = 1
         fsTagDesc1.setComplexValue(nonfeature, 1j)
     with self.assertRaises(TypeError):
         aFeature.elementType = None
         fsTagDesc1.setComplexValue(aFeature, 1j)
     with self.assertRaises(TypeError):
         aFeature.elementType = 'uima.cas.Integer'
         fsTagDesc1.setComplexValue(aFeature, 1j)
예제 #7
0
 def __init__(self, FStype, FSid, typeSystem):
     '''
     Constructor
     '''
     #set the FSid
     TOP.__init__(self, FStype, FSid, typeSystem)
예제 #8
0
 def __getattr__(self, attr):
     if attr in ('sofaNum', 'sofaID', 'mimeType', 'sofaString'):
         return object.__getattr__(self, attr)
     else:
         return TOP.__getattr__(self, attr)
예제 #9
0
 def __setattr__(self, attr, value):
     if attr in ('sofaNum', 'sofaID', 'mimeType', 'sofaString'):
         object.__setattr__(self, attr, value)
     else:
         TOP.__setattr__(self, attr, value)
예제 #10
0
    def test_setListVal_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.rangeType = 'uima.cas.String'
        listval = []
        listval.append('#')
        self.assertEqual('', '')
        with self.assertRaises(TypeError):
            nonlist = 1
            fsTagDesc1.setListValue(aFeature, aFeature.rangeType, nonlist)
        with self.assertRaises(TypeError):
            nonfeature = 1
            fsTagDesc1.setListValue(nonfeature, aFeature.rangeType, listval)
        with self.assertRaises(TypeError):
            aFeature.rangeType = 'uima.cas.Inetger'
            fsTagDesc1.setListValue(aFeature, aFeature.rangeType, listval)
        with self.assertRaises(TypeError):
            aFeature.rangeType = typesystem.getType(
                'de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS')

            fsTagDesc1.setListValue(aFeature, aFeature.rangeType, listval)
        with self.assertRaises(TypeError):
            aFeature.rangeType = 'uima.cas.Integer'
            aFeature.elementType = 'uima.cas.String'
            fsTagDesc1.setListValue(aFeature, aFeature.elementType, listval)