<commit_before>package org.protempa;

import java.util.regex.Pattern;

/**
 * Represents a term pulled from a terminology in PROTEMPA.
 * 
 * @author <NAME>
 */

public final class Term {

    /*
     * the unique ID of this term: <terminology id>:<term id> (<SAB>:<term
     * code>)
     */
    private final String id;

    /*
     * the code for this term in its terminology
     */
    private final String code;

    /*
     * the terminology this term comes from
     */
    private final Terminology terminology;

    /*
     * the display name of this term
     */
    private String displayName;

    /*
     * the description of this term
     */
    private String description;

    /*
     * the semantic type of this term
     */
    private String semanticType;

    /*
     * the short name of this term
     */
    private String abbrevDisplayName;

    /*
     * term IDs related to this one
     */
    private String[] inverseIsA;

    /*
     * direct children of this term, stored as terms
     */
    private Term[] directChildren;

    /*
     * TermID pattern
     */
    private static Pattern idPattern;

    static {
        idPattern = Pattern.compile("\\w:\\w");
    }

    private static boolean checkId(String id) {
        return idPattern.matcher(id).matches();
    }

    private Term(String id, String terminology, String code) {
        this(id, Terminology.withName(terminology), code);
    }
    
    private Term(String id, Terminology terminology, String code) {
        this.id = id;
        this.terminology = terminology;
        this.code = code;    
    }
    
    private Term(Terminology terminology, String code) {
        this(makeId(terminology, code), terminology, code);
    }

    /**
     * Creates and returns a new <code>Term</code> with the given identifier
     * 
     * @param id
     *            the term's unique identifier
     * @return a new <code>Term</code> with the given identifier
     */
    public static Term withId(String id) throws MalformedTermIdException {
        if (checkId(id)) {
            String[] parts = parseId(id);
            Term term = new Term(id, parts[0], parts[1]);
            return term;
        } else {
            throw new MalformedTermIdException(
                    "Term IDs must be of the form: <SAB>:<terminology code>");
        }
    }
    
    public static Term fromTerminologyAndCode(Terminology terminology, String code) {
        return new Term(terminology, code);
    }
    
    /**
     * Defines how term IDs are constructed
     * 
     */
    private static String makeId(Terminology terminology, String code) {
        return terminology.getName() + ":" + code;
    }

    private static String[] parseId(String id) {
        return id.split(":");
    }
<commit_msg>fixed the regex used to match term IDs to anything split by a colon<commit_after>package org.protempa;

import java.util.regex.Pattern;

/**
 * Represents a term pulled from a terminology in PROTEMPA.
 * 
 * @author <NAME>
 */

public final class Term {

    /*
     * the unique ID of this term: <terminology id>:<term id> (<SAB>:<term
     * code>)
     */
    private final String id;

    /*
     * the code for this term in its terminology
     */
    private final String code;

    /*
     * the terminology this term comes from
     */
    private final Terminology terminology;

    /*
     * the display name of this term
     */
    private String displayName;

    /*
     * the description of this term
     */
    private String description;

    /*
     * the semantic type of this term
     */
    private String semanticType;

    /*
     * the short name of this term
     */
    private String abbrevDisplayName;

    /*
     * term IDs related to this one
     */
    private String[] inverseIsA;

    /*
     * direct children of this term, stored as terms
     */
    private Term[] directChildren;

    /*
     * TermID pattern
     */
    private static Pattern idPattern;

    static {
        idPattern = Pattern.compile(".+:.+");
    }

    private static boolean checkId(String id) {
        return idPattern.matcher(id).matches();
    }

    private Term(String id, String terminology, String code) {
        this(id, Terminology.withName(terminology), code);
    }

    private Term(String id, Terminology terminology, String code) {
        this.id = id;
        this.terminology = terminology;
        this.code = code;
    }

    private Term(String terminology, String code) {
        this(makeId(Terminology.withName(terminology), code), terminology, code);
    }

    /**
     * Creates and returns a new <code>Term</code> with the given identifier
     * 
     * @param id
     *            the term's unique identifier
     * @return a new <code>Term</code> with the given identifier
     */
    public static Term withId(String id) throws MalformedTermIdException {
        if (checkId(id)) {
            String[] parts = parseId(id);
            Term term = new Term(id, parts[0], parts[1]);
            return term;
        } else {
            throw new MalformedTermIdException(
                    "Bad term ID: "
                            + id
                            + "\nTerm IDs must be of the form: <terminology name>:<terminology code>");
        }
    }

    public static Term fromTerminologyAndCode(String terminology, String code) {
        return new Term(terminology, code);
    }

    /**
     * Defines how term IDs are constructed
     * 
     */
    private static String makeId(Terminology terminology, String code) {
        return terminology.getName() + ":" + code;
    }

    private static String[] parseId(String id) {
        return id.split(":");
    }

{'fraction_non_alphanumeric': 0.09741168240643581, 'fraction_numerical': 0.0006995452955578874, 'mean_word_length': 2.022727272727273, 'pattern_counts': {'":': 4, '<': 25, '<?xml version=': 0, '>': 25, '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': '7656384', 'n_tokens_mistral': 1631, 'n_tokens_neox': 1546, 'n_words': 518}