<commit_before>package org.intermine.webservice.server.widget;

import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.json.JSONObject;

public class EnrichmentJSONProcessor implements WidgetResultProcessor {

    private static final WidgetResultProcessor instance = new EnrichmentJSONProcessor();

    private EnrichmentJSONProcessor() {
        // Not to be instantiated.
    }

    public static WidgetResultProcessor instance() {
        return instance;
    }

    @Override
    public List<String> formatRow(List<Object> row) {
        Map<String, Object> backingMap = new HashMap<String, Object>();
        backingMap.put("item", row.get(0));
        backingMap.put("description", row.get(1));
        backingMap.put("p-value", row.get(2));
        // Counts (index 3) are not necessary here, as it it trivial to
        // fetch from the matches array (as result.matches.length)
        List<Map<String, Object>> matchesDetail = (List<Map<String, Object>>) row.get(4);
        backingMap.put("matches", matchesDetail);
        JSONObject jo = new JSONObject(backingMap);
        return new LinkedList<String>(Arrays.asList(jo.toString()));
    }

}<commit_msg>Replaced item with identifier<commit_after>package org.intermine.webservice.server.widget;

import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.json.JSONObject;

public class EnrichmentJSONProcessor implements WidgetResultProcessor {

    private static final WidgetResultProcessor instance = new EnrichmentJSONProcessor();

    private EnrichmentJSONProcessor() {
        // Not to be instantiated.
    }

    public static WidgetResultProcessor instance() {
        return instance;
    }

    @Override
    public List<String> formatRow(List<Object> row) {
        Map<String, Object> backingMap = new HashMap<String, Object>();
        backingMap.put("identifier", row.get(0));
        backingMap.put("description", row.get(1));
        backingMap.put("p-value", row.get(2));
        // Counts (index 3) are not necessary here, as it it trivial to
        // fetch from the matches array (as result.matches.length)
        List<Map<String, Object>> matchesDetail = (List<Map<String, Object>>) row.get(4);
        backingMap.put("matches", matchesDetail);
        JSONObject jo = new JSONObject(backingMap);
        return new LinkedList<String>(Arrays.asList(jo.toString()));
    }

}
{'fraction_non_alphanumeric': 0.11410459587955626, 'fraction_numerical': 0.003961965134706815, 'mean_word_length': 3.5577617328519855, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '2409650', 'n_tokens_mistral': 706, 'n_tokens_neox': 709, 'n_words': 181}