uima-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Eckart de Castilho <eckar...@tk.informatik.tu-darmstadt.de>
Subject Re: How to deal with types which define allowed values?
Date Mon, 06 Jun 2011 10:24:53 GMT
Hi Jörn,

> Is it possible to determine if a Type restricts the values via allowed 
> values, and if so get a list of all allowed values? I would need both to create 
> a combo box where a user can select a value out of the allowed values.


there is a piece of code in TypeSystem2Xml.class which seems to extract AllowedValues from
TypeSystem instance. I'd guess that's what you need.

UIMA 2.3.1 - TypeSystem2Xml.java:159ff

      // check for string subtypes
      if (type instanceof StringTypeImpl) {
	LowLevelTypeSystem lts = aTypeSystem.getLowLevelTypeSystem();
	final int typeCode = lts.ll_getCodeForType(type);
        String[] strings = lts.ll_getStringSet(typeCode);
        AllowedValue[] allowedVals = new AllowedValue[strings.length];
        for (int i = 0; i < strings.length; i++) {
          allowedVals[i] = factory.createAllowedValue();
          allowedVals[i].setString(strings[i]);
        }
        typeDesc.setAllowedValues(allowedVals);
      }

Cheers,

Richard

-- 
------------------------------------------------------------------- 
Richard Eckart de Castilho
Technical Lead
Ubiquitous Knowledge Processing Lab 
FB 20 Computer Science Department      
Technische Universität Darmstadt 
Hochschulstr. 10, D-64289 Darmstadt, Germany 
phone [+49] (0)6151 16-7477, fax -5455, room S2/02/B117
eckartde@tk.informatik.tu-darmstadt.de 
www.ukp.tu-darmstadt.de 
Web Research at TU Darmstadt (WeRC) www.werc.tu-darmstadt.de
------------------------------------------------------------------- 





Mime
View raw message