MorphInterpretation.cpp 2.61 KB
/* 
 * File:   MorphInterpretation.cpp
 * Author: mlenart
 * 
 * Created on November 14, 2013, 11:47 AM
 */

#include <string>
#include <sstream>
#include "MorphInterpretation.hpp"
#include "EncodedInterpretation.hpp"

using namespace std;

MorphInterpretation::MorphInterpretation(
        int startNode,
        int endNode,
        const string& orth,
        const string& lemma,
        const string& homonymId,
        int tagnum,
        int namenum,
        const Tagset& tagset,
        const CharsetConverter& charsetConverter)
: startNode(startNode), 
        endNode(endNode), 
        orth(orth),
        lemma(lemma),
        homonymId(homonymId),
        tagnum(tagnum),
        namenum(namenum),
        tag(tagset.getTag(tagnum, charsetConverter)),
        name(tagset.getName(namenum, charsetConverter)) {

}

MorphInterpretation::MorphInterpretation(
        int startNode,
        const std::string& orth,
        const Tagset& tagset,
        const CharsetConverter& charsetConverter)
: startNode(startNode), 
        endNode(startNode + 1), 
        orth(orth),
        lemma(orth),
        homonymId(""),
        tagnum(0),
        namenum(0),
        tag(tagset.getTag(0, charsetConverter)),
        name(tagset.getName(0, charsetConverter)) {

}

MorphInterpretation MorphInterpretation::createIgn(int startNode, const std::string& orth, const Tagset& tagset, const CharsetConverter& charsetConverter) {
    return MorphInterpretation(startNode, orth, tagset, charsetConverter);
}

int MorphInterpretation::getStartNode() const {
    return this->startNode;
}

int MorphInterpretation::getEndNode() const {
    return this->endNode;
}

const std::string& MorphInterpretation::getOrth() const {
    return this->orth;
}

const std::string& MorphInterpretation::getLemma() const {
    return this->lemma;
}

const std::string& MorphInterpretation::getHomonymId() const {
    return this->homonymId;
}

int MorphInterpretation::getTagnum() const {
    return this->tagnum;
}

int MorphInterpretation::getNamenum() const {
    return this->namenum;
}

const std::string& MorphInterpretation::getTag() const {
    return this->tag;
}

const std::string& MorphInterpretation::getName() const {
    return this->name;
}

std::string MorphInterpretation::toString(bool includeNodeNumbers) const {
    std::stringstream res;
    if (includeNodeNumbers) {
        res << startNode << "," << endNode << ",";
    }
    res << orth << ",";
    
    res << lemma;
    if (!this->homonymId.empty()) {
        res << ":" << homonymId;
    }
    res << ",";
    
    res << tag;
    if (!name.empty()) {
        res << "," << name;
    }
    return res.str();
}