Package org.apache.ctakes.ytex.uima.types

Examples of org.apache.ctakes.ytex.uima.types.DocKey


    AnalysisEngine engine = TestUtils.createTokenizerAE(null);
    JCas jCas = engine.newJCas();
    jCas.setDocumentText(text);
    // create a docKey so we can find the doc
    long key = System.currentTimeMillis();
    DocKey docKey = new DocKey(jCas);
    KeyValuePair kvp = new KeyValuePair(jCas);
    kvp.setKey("instance_id");
    kvp.setValueLong(key);
    FSArray fsa = new FSArray(jCas, 1);
    fsa.set(0, kvp);
    docKey.setKeyValuePairs(fsa);
    docKey.addToIndexes();
    // run the analysis engine
    engine.process(jCas);
    DataSource ds = ctx.getBean(DataSource.class);
    Properties ytexProperties = (Properties) ctx.getBean("ytexProperties");
    String schema = ytexProperties.getProperty("db.schema");
View Full Code Here


    }
  }

  private void addDocKey(JCas aCAS, Map<String, Object> id)
      throws CollectionException {
    DocKey docKey = new DocKey(aCAS);
    FSArray keyValuePairs = new FSArray(aCAS, id.size());
    int i = 0;
    for (Map.Entry<String, Object> idVal : id.entrySet()) {
      String key = idVal.getKey();
      Object val = idVal.getValue();
      KeyValuePair p = new KeyValuePair(aCAS);
      p.setKey(key);
      if (val instanceof Number) {
        p.setValueLong(((Number) val).longValue());
      } else if (val instanceof String) {
        p.setValueString((String) val);
      } else {
        log.warn("Don't know how to handle key attribute, converting to string, key="
            + key + ", value=" + val);
        p.setValueString(val.toString());
      }
      keyValuePairs.set(i, p);
      i++;
    }
    docKey.setKeyValuePairs(keyValuePairs);
    docKey.addToIndexes();

  }
View Full Code Here

TOP

Related Classes of org.apache.ctakes.ytex.uima.types.DocKey

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.