Example #1
0
 /**
  * Calculates the document frequency of annotations of the given annotation type in the corpus.
  * Annotations are transformed into strings using the given toString function.
  *
  * @param type the annotation type to count.
  * @param toString the function to convert Annotations into strings
  * @return A counter containing document frequencies of the given annotation type
  */
 default Counter<String> documentFrequencies(
     @NonNull AnnotationType type, @NonNull Function<? super Annotation, String> toString) {
   return new HashMapCounter<>(
       Cast.cast(
           stream()
               .flatMap(
                   document ->
                       document
                           .get(type)
                           .stream()
                           .map(toString)
                           .distinct()
                           .collect(Collectors.toList()))
               .countByValue()));
 }
 @Override
 public Resource createResource(String specification, Map<String, String> properties) {
   BeanMap beanMap = new BeanMap(new FileResource(specification));
   beanMap.putAll(properties);
   return Cast.as(beanMap.getBean());
 }