|
1
2
3
4
5
6
7
8
9
10
11
|
/*
* File: FlexionGraph.hpp
* Author: mlenart
*
* Created on 18 listopad 2013, 15:03
*/
#ifndef FLEXIONGRAPH_HPP
#define FLEXIONGRAPH_HPP
#include <vector>
|
|
12
13
|
#include <set>
#include <utility>
|
|
14
15
|
#include "InterpretedChunk.hpp"
|
|
16
|
class InflexionGraph {
|
|
17
|
public:
|
|
18
|
|
|
19
|
InflexionGraph(): graph(), node2ChunkStartPtr(), onlyWeakPaths(true) {
|
|
20
21
|
}
|
|
22
23
24
|
struct Edge {
InterpretedChunk chunk;
|
|
25
|
unsigned int nextNode;
|
|
26
27
|
};
|
|
28
|
void addPath(const std::vector<InterpretedChunk>& path, bool weak);
|
|
29
30
31
|
// void getResults(const Tagset& tagset, const CharsetConverter& charsetConverter, std::vector<MorphInterpretation>& results);
|
|
32
|
std::vector< std::vector<InflexionGraph::Edge> >& getTheGraph() {
|
|
33
|
minimizeGraph();
|
|
34
|
repairLastNodeNumbers();
|
|
35
36
37
|
return this->graph;
}
|
|
38
|
bool empty() const;
|
|
39
40
41
|
// virtual ~FlexionGraph();
|
|
42
|
private:
|
|
43
44
45
46
|
typedef std::pair<const char*, int> PathElement;
typedef std::set<PathElement> Path;
|
|
47
|
void addStartEdge(const Edge& e);
|
|
48
|
|
|
49
|
void addMiddleEdge(unsigned int startNode, const Edge& e);
|
|
50
|
|
|
51
|
void minimizeGraph();
|
|
52
53
54
55
56
57
58
59
60
61
62
63
|
bool canMergeNodes(unsigned int node1, unsigned int node2);
void doMergeNodes(unsigned int node1, unsigned int node2);
bool tryToMergeTwoNodes();
std::set<Path> getPossiblePaths(unsigned int node);
void redirectEdges(unsigned int fromNode, unsigned int toNode);
void doRemoveNode(unsigned int node);
|
|
64
|
|
|
65
|
void repairLastNodeNumbers();
|
|
66
67
|
void repairOrthShifts();
|
|
68
|
|
|
69
|
std::vector< std::vector<Edge> > graph;
|
|
70
|
std::vector< const char* > node2ChunkStartPtr;
|
|
71
|
bool onlyWeakPaths;
|
|
72
73
74
75
|
};
#endif /* FLEXIONGRAPH_HPP */
|