in uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/CasInitializationUtils.java [36:64]
public static void initRandomCas(CAS cas, int typeCount, int annotationCount,
int maxAnnotationLength, int approxDocLength, long seed) {
cas.reset();
Random rnd = new Random(seed);
List<Type> types = new ArrayList<Type>();
types.add(cas.getTypeSystem().getType(Token.class.getName()));
types.add(cas.getTypeSystem().getType(Sentence.class.getName()));
// Shuffle the types
for (int n = 0; n < typeCount; n++) {
Type t = types.remove(rnd.nextInt(types.size()));
types.add(t);
}
// Randomly generate annotations
for (int n = 0; n < annotationCount; n++) {
for (Type t : types) {
int begin = rnd.nextInt(approxDocLength);
int end = begin + rnd.nextInt(maxAnnotationLength);
cas.addFsToIndexes(cas.createAnnotation(t, begin, end));
}
}
try {
cas.getJCas();
} catch (CASException e) {
throw new RuntimeException(e);
}
}