package com.apobates.forum.core.nlp.tag;

import java.util.Objects;

/**
 * 标签源数据
 *
 * @author xiaofanku
 * @since 20200111
 */
public final class RelateWordStats {
    private final long topic;
    //词
    private final String word;
    //词频
    private final int frequency;
    
    public RelateWordStats(long topic, String word, int frequency) {
        super();
        this.topic = topic;
        this.word = word;
        this.frequency = frequency;
    }
    
    /**
     * 话题ID
     *
     * @return
     */
    public long getTopic() {
        return topic;
    }
    
    /**
     * 标签名/词语
     *
     * @return
     */
    public String getWord() {
        return word;
    }
    
    /**
     * 词频
     *
     * @return
     */
    public int getFrequency() {
        return frequency;
    }
    
    @Override
    public int hashCode() {
        int hash = 7;
        hash = 13 * hash + (int) (this.topic ^ (this.topic >>> 32));
        hash = 13 * hash + Objects.hashCode(this.word);
        return hash;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final RelateWordStats other = (RelateWordStats) obj;
        if (this.topic != other.topic) {
            return false;
        }
        if (!this.word.equalsIgnoreCase(other.word)) {
            return false;
        }
        return true;
    }
}