package org.algorithm.core.cnn.entity;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName org.algorithm.core.cnn.entity.Lemma
 * @Description 词元信息
 * @Author fyeman
 * @Date 2019/1/17/017 19:15
 * @Version 1.0
 **/
public class Lemma implements Comparable<Lemma> {
    private String text;
    private String position;
    private int len;
    private String property;

    private Lemma parent;

    private boolean haveChildren = false;

    public boolean isHaveChildren() {
        return haveChildren;
    }

    public void setHaveChildren(boolean haveChildren) {
        this.haveChildren = haveChildren;
    }

    public Lemma getParent() {
        return parent;
    }

    public void setParent(Lemma parent) {
        this.parent = parent;
    }

    public int getStartPosition() {
        String[] pos = this.position.split(",");
        return Integer.parseInt(pos[0]);
    }


    private List<Lemma> relationLemmas = new ArrayList<>();

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    public int getLen() {
        return len;
    }

    public void setLen(int len) {
        this.len = len;
    }

    public String getProperty() {
        return property;
    }

    public void setProperty(String property) {
        this.property = property;
    }

    public List<Lemma> getRelationLemmas() {
        return relationLemmas;
    }

    public void setRelationLemmas(List<Lemma> relationLemmas) {
        this.relationLemmas = relationLemmas;
    }

    public void add(Lemma l) {
        if (relationLemmas == null) {
            relationLemmas = new ArrayList<>();
        }
        relationLemmas.add(l);
    }

    @Override
    public int compareTo(Lemma o) {
        return this.getStartPosition() - o.getStartPosition();
    }
}
