<commit_before>package it.unitn.disi.smatch.data.ling;

import it.unitn.disi.smatch.data.matrices.IndexedObject;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

/**
 * This class represents atomic concept of label (ACoL) as a
 * concept label and list of associated senses in WordNet.
 *
 * @author <NAME> <EMAIL>
 * @author <NAME> <EMAIL>
 */
public class AtomicConceptOfLabel extends IndexedObject implements IAtomicConceptOfLabel {

    private int id;
    private String token;
    private String lemma;

    private ArrayList<ISense> senses;
    private static final Iterator<ISense> EMPTY_SENSE_ITERATOR = Collections.<ISense>emptyList().iterator();

    public AtomicConceptOfLabel() {
    }

    /**
     * Constructor class which sets the id, token and lemma.
     *
     * @param id    id of token
     * @param token token
     * @param lemma lemma
     */
    public AtomicConceptOfLabel(int id, String token, String lemma) {
        this.id = id;
        this.token = token;
        this.lemma = lemma;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getLemma() {
        return lemma;
    }

    public void setLemma(String lemma) {
        this.lemma = lemma;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public ISense getSenseAt(int index) {
        if (senses == null) {
            throw new ArrayIndexOutOfBoundsException("acol has no senses");
        }
        return senses.get(index);
    }

    public int getSenseCount() {
        if (senses == null) {
            return 0;
        } else {
            return senses.size();
        }
    }

    public int getSenseIndex(ISense sense) {
        if (null == sense) {
            throw new IllegalArgumentException("argument is null");
        }

        if (null == senses) {
            return -1;
        }

        return senses.indexOf(sense);
    }

    public Iterator<ISense> getSenses() {
        if (null == senses) {
            return EMPTY_SENSE_ITERATOR;
        } else {
            return senses.iterator();
        }
    }

    public List<ISense> getSenseList() {
        return Collections.unmodifiableList(senses);
    }

    public ISense createSense(char pos, long id) {
        ISense sense = new Sense(pos, id);
        addSense(sense);
        return sense;
    }

    public void addSense(ISense sense) {
        addSense(getSenseCount(), sense);
    }

    public void addSense(int index, ISense sense) {
        if (null == sense) {
            throw new IllegalArgumentException("new sense is null");
        }

        if (null == senses) {
            senses = new ArrayList<ISense>();
        }

        if (-1 == senses.indexOf(sense)) {
            senses.add(index, sense);
        }
    }<commit_msg>null pointer is no senses fixed<commit_after>package it.unitn.disi.smatch.data.ling;

import it.unitn.disi.smatch.data.matrices.IndexedObject;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

/**
 * This class represents atomic concept of label (ACoL) as a
 * concept label and list of associated senses in WordNet.
 *
 * @author <NAME> <EMAIL>
 * @author <NAME> <EMAIL>
 */
public class AtomicConceptOfLabel extends IndexedObject implements IAtomicConceptOfLabel {

    private int id;
    private String token;
    private String lemma;

    private ArrayList<ISense> senses;
    private static final Iterator<ISense> EMPTY_SENSE_ITERATOR = Collections.<ISense>emptyList().iterator();

    public AtomicConceptOfLabel() {
    }

    /**
     * Constructor class which sets the id, token and lemma.
     *
     * @param id    id of token
     * @param token token
     * @param lemma lemma
     */
    public AtomicConceptOfLabel(int id, String token, String lemma) {
        this.id = id;
        this.token = token;
        this.lemma = lemma;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getLemma() {
        return lemma;
    }

    public void setLemma(String lemma) {
        this.lemma = lemma;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public ISense getSenseAt(int index) {
        if (senses == null) {
            throw new ArrayIndexOutOfBoundsException("acol has no senses");
        }
        return senses.get(index);
    }

    public int getSenseCount() {
        if (senses == null) {
            return 0;
        } else {
            return senses.size();
        }
    }

    public int getSenseIndex(ISense sense) {
        if (null == sense) {
            throw new IllegalArgumentException("argument is null");
        }

        if (null == senses) {
            return -1;
        }

        return senses.indexOf(sense);
    }

    public Iterator<ISense> getSenses() {
        if (null == senses) {
            return EMPTY_SENSE_ITERATOR;
        } else {
            return senses.iterator();
        }
    }

    public List<ISense> getSenseList() {
        if (null != senses) {
            return Collections.unmodifiableList(senses);
        } else {
            return Collections.emptyList();
        }
    }

    public ISense createSense(char pos, long id) {
        ISense sense = new Sense(pos, id);
        addSense(sense);
        return sense;
    }

    public void addSense(ISense sense) {
        addSense(getSenseCount(), sense);
    }

    public void addSense(int index, ISense sense) {
        if (null == sense) {
            throw new IllegalArgumentException("new sense is null");
        }

        if (null == senses) {
            senses = new ArrayList<ISense>();
        }

        if (-1 == senses.indexOf(sense)) {
            senses.add(index, sense);
        }
    }
{'fraction_non_alphanumeric': 0.10084311456439081, 'fraction_numerical': 0.000991899487518598, 'mean_word_length': 2.028028028028028, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '7588151', 'n_tokens_mistral': 1825, 'n_tokens_neox': 1739, 'n_words': 485}