<commit_before>package org.wyona.yanel.core.attributes.annotatable;

import org.apache.log4j.Logger;

/**
 * Utility class to read, write annotations, etc.
 */
public class Util {

    private static Logger log = Logger.getLogger(Util.class);

    private static final String ANNOTATIONS_PROP_NAME = "annotations";

    /**
     * Read annotations
     */
    public static java.util.Set<String> readAnnotations(org.wyona.yarep.core.Repository repo, String path) throws Exception {
        java.util.Set<String> annotations  = new java.util.HashSet<String>();
            if (repo.existsNode(path) && repo.getNode(path).hasProperty(ANNOTATIONS_PROP_NAME)) {
                String aString = repo.getNode(path).getProperty(ANNOTATIONS_PROP_NAME).getString();
                String[] aArray = aString.split(", ");
                for(int i = 0; i < aArray.length; i++) {
                    annotations.add(aArray[i]);
                }
                return annotations;
            } else {
                log.warn("No annotations yet: " + path);
                return null;
            }
    }

    /**
     * Save annotations
     * @param annotations TODO
     * @param repo Repository
     * @param path TODO
     */
    public static void saveAnnotations(java.util.Set<String> annotations, org.wyona.yarep.core.Repository repo, String path) throws Exception {
        String[] aArray = annotations.toArray(new String[0]);
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < aArray.length; i++) {<commit_msg>do not never return null, but rather empty set if there are no annotations<commit_after>package org.wyona.yanel.core.attributes.annotatable;

import org.apache.log4j.Logger;

/**
 * Utility class to read, write annotations, etc.
 */
public class Util {

    private static Logger log = Logger.getLogger(Util.class);

    private static final String ANNOTATIONS_PROP_NAME = "annotations";

    /**
     * Read annotations
     * @return annotations, whereas return empty list if there are no annotations yet
     */
    public static java.util.Set<String> readAnnotations(org.wyona.yarep.core.Repository repo, String path) throws Exception {
        java.util.Set<String> annotations  = new java.util.HashSet<String>();
        if (repo.existsNode(path) && repo.getNode(path).hasProperty(ANNOTATIONS_PROP_NAME)) {
            String aString = repo.getNode(path).getProperty(ANNOTATIONS_PROP_NAME).getString();
            String[] aArray = aString.split(", ");
            for(int i = 0; i < aArray.length; i++) {
                annotations.add(aArray[i]);
            }
        } else {
           log.warn("No annotations yet: " + path);
        }
        return annotations;
    }

    /**
     * Save annotations
     * @param annotations TODO
     * @param repo Repository
     * @param path TODO
     */
    public static void saveAnnotations(java.util.Set<String> annotations, org.wyona.yarep.core.Repository repo, String path) throws Exception {
        String[] aArray = annotations.toArray(new String[0]);
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < aArray.length; i++) {
{'fraction_non_alphanumeric': 0.11329736591558236, 'fraction_numerical': 0.0025388765471278957, 'mean_word_length': 2.5858930602957906, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1565474', 'n_tokens_mistral': 905, 'n_tokens_neox': 862, 'n_words': 225}