Blame view

morfeusz/test/consoleUtils.hpp 1.08 KB
Michał Lenart authored
1
2
3
4
5
6
7
8
9
10
11
12
/* 
 * File:   consoleUtils.hpp
 * Author: lennyn
 *
 * Created on April 4, 2014, 7:36 PM
 */

#ifndef CONSOLEUTILS_HPP
#define	CONSOLEUTILS_HPP

#include <vector>
#include <string>
Michał Lenart authored
13
#include "morfeusz2.h"
Michał Lenart authored
14
Michał Lenart authored
15
16
namespace morfeusz {
Michał Lenart authored
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
template <class OutputStream>
void appendMorfeuszResults(const std::vector<MorphInterpretation>& res, OutputStream& out) {
    int prevStart = -1;
    int prevEnd = -1;
    out << "[";
    for (unsigned int i = 0; i < res.size(); i++) {
        const MorphInterpretation& mi = res[i];
        if (prevStart != -1
                && (prevStart != mi.getStartNode() || prevEnd != mi.getEndNode())) {
            out << "]\n[";
        }
        else if (prevStart != -1) {
            out << "; ";
        }
        out << mi.getStartNode() << ","
                << mi.getEndNode() << ","
                << mi.getOrth() << ","
                << mi.getLemma() << ","
                << mi.getTag() << ","
                << mi.getName();
        prevStart = mi.getStartNode();
        prevEnd = mi.getEndNode();
    }
    out << "]\n";
}
Michał Lenart authored
43
44
}
Michał Lenart authored
45
46
#endif	/* CONSOLEUTILS_HPP */