Blame view

morfeusz/IdResolverImpl.hpp 1.65 KB
Michał Lenart authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* 
 * File:   tagset.hpp
 * Author: mlenart
 *
 * Created on 12 listopad 2013, 14:09
 */

#ifndef DEFAULTTAGSET_HPP
#define	DEFAULTTAGSET_HPP

#include <string>
#include <vector>
#include <map>
#include "morfeusz2.h"
#include "charset/CharsetConverter.hpp"

namespace morfeusz {

    class IdResolverImpl : public IdResolver {
    public:

        IdResolverImpl(const unsigned char* ptr, const CharsetConverter* charsetConverter);

        void setCharsetConverter(const CharsetConverter* charsetConverter);

        const std::string& getTag(const int tagId) const;
        int getTagId(const std::string& tag) const;

        const std::string& getName(const int nameId) const;
        int getNameId(const std::string& name) const;

        const std::string& getLabelsAsString(int labelsId) const;
        const std::set<std::string>& getLabels(int labelsId) const;
        int getLabelsId(const std::string& labelsStr) const;

        size_t getTagsCount() const;
        size_t getNamesCount() const;
        size_t getLabelsCount() const;

        virtual ~IdResolverImpl() {
        }

        struct IdStringMapping {
            std::vector<std::string> id2String;
            std::map<std::string, int> string2Id;
        };
Michał Lenart authored
47
48
49

        bool isCompatibleWith(const IdResolverImpl& other) const;
Michał Lenart authored
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
    private:

        IdStringMapping tags;
        IdStringMapping names;
        IdStringMapping labels;
        std::vector< std::set<std::string> > labelsAsSets;
//
//        std::vector<std::string> tags;
//        std::vector<std::string> names;
        const CharsetConverter* charsetConverter;
    };

}

#endif	/* DEFAULTTAGSET_HPP */