<commit_before>package com.brajagopal.rmend.data.beans;

import java.util.Map;

/**
 * @author <bxr4261>
 */
public abstract class BaseContent {
    public static final String KEY_TYPEGROUP = "_typeGroup";

    public static Class<? extends BaseContent> find(Map<String, ? extends Object> _value) {
        if (_value.containsKey(KEY_TYPEGROUP)) {
            ContentType contentType = ContentType.getInstance((String) _value.get(KEY_TYPEGROUP));
            if (contentType != null) {
                return contentType.getClassInstance();
            }
        }
        return null;
    }

    public abstract void process(Map<String, ? extends Object> _value);
    public abstract BaseContent getInstance();

    public static enum ContentType {
        TOPICS("topics", null),
        SOCIAL_TAGS("socialTag", SocialTag.class),
        ENTITIES("entities", null),
        DISCARDED("", null);

        private String name;
        private Class<? extends BaseContent> classInstance;

        private ContentType(String _typeGroup, Class<? extends BaseContent> _classInstance) {
            this.name = _typeGroup;
            this.classInstance = _classInstance;

        }

        public static ContentType getInstance(String _typeGroup) {
            for (ContentType value : values()) {
                if (value.getTypeGroup().equals(_typeGroup)) {
                    return value;
                }<commit_msg>Refactored the BaseContent class to introduce additional ContentTypes and also handle the document info block.<commit_after>package com.brajagopal.rmend.data.beans;

import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.Map;

/**
 * @author <bxr4261>
 */
public abstract class BaseContent {
    public static final String KEY_TYPEGROUP = "_typeGroup";

    public static Class<? extends BaseContent> find(Map<String, ? extends Object> _value) {
        if (_value.containsKey(KEY_TYPEGROUP)) {
            ContentType contentType = ContentType.getInstance((String) _value.get(KEY_TYPEGROUP));
            if (contentType != null) {
                return contentType.getClassInstance();
            }
        }
        else if (_value.keySet().containsAll(Arrays.asList("info", "meta"))) { // document information
            return ContentType.DOCUMENT_INFO.getClassInstance();
        }
        return null;
    }

    public abstract void process(Map<String, ? extends Object> _value);
    public abstract BaseContent getInstance();

    public static enum ContentType {
        TOPICS("topics", TopicBean.class),
        SOCIAL_TAGS("socialTag", SocialTagBean.class),
        ENTITIES("entities", EntitiesBean.class),
        RELATIONS("relations", RelationsBean.class),
        DOCUMENT_INFO("document", DocumentBean.class),
        DISCARDED(StringUtils.EMPTY, null);

        private String name;
        private Class<? extends BaseContent> classInstance;

        private ContentType(String _typeGroup, Class<? extends BaseContent> _classInstance) {
            this.name = _typeGroup;
            this.classInstance = _classInstance;

        }

        public static ContentType getInstance(String _typeGroup) {
            for (ContentType value : values()) {
                if (value.getTypeGroup().equals(_typeGroup)) {
                    return value;
                }
{'fraction_non_alphanumeric': 0.09784560143626571, 'fraction_numerical': 0.0026929982046678637, 'mean_word_length': 2.6817180616740086, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '2403143', 'n_tokens_mistral': 884, 'n_tokens_neox': 852, 'n_words': 216}