Blame view

morfeusz/MorphDeserializer.cpp 1.04 KB
Michał Lenart authored
1
2
3
4
5
6
7
/* 
 * File:   MorphDeserializer.cpp
 * Author: mlenart
 * 
 * Created on 12 listopad 2013, 15:31
 */
Michał Lenart authored
8
#include <map>
Michał Lenart authored
9
#include <algorithm>
Michał Lenart authored
10
//#include <cstdint>
Michał Lenart authored
11
#include "MorphDeserializer.hpp"
Michał Lenart authored
12
13
#include "EncodedInterpretation.hpp"
#include "InterpsGroup.hpp"
Michał Lenart authored
14
#include "deserializationUtils.hpp"
Michał Lenart authored
15
Michał Lenart authored
16
17
18
19
//const uint8_t LEMMA_ONLY_LOWER = 0;
//const uint8_t LEMMA_UPPER_PREFIX = 1;
//const uint8_t LEMMA_MIXED_CASE = 2;
//const unsigned int MAX_WORD_SIZE = 256;
Michał Lenart authored
20
Michał Lenart authored
21
22
23
24
25
26
MorphDeserializer::MorphDeserializer() {
}

MorphDeserializer::~MorphDeserializer() {
}
Michał Lenart authored
27
long MorphDeserializer::deserialize(const unsigned char* ptr, vector<InterpsGroup>& interps) const {
Michał Lenart authored
28
    const unsigned char* currPtr = ptr;
Michał Lenart authored
29
    uint8_t interpTypesNum = readInt8(currPtr);
Michał Lenart authored
30
31
32
33
    interps.clear();
    interps.reserve(interpTypesNum);
    for (unsigned int i = 0; i < interpTypesNum; i++) {
        InterpsGroup ig;
Michał Lenart authored
34
35
        ig.type = readInt8(currPtr);
        ig.size = readInt16(currPtr);
Michał Lenart authored
36
37
38
        ig.ptr = currPtr;
        currPtr += ig.size;
        interps.push_back(ig);
Michał Lenart authored
39
40
41
    }
    return currPtr - ptr;
}