-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalign.h
More file actions
91 lines (76 loc) · 2.43 KB
/
align.h
File metadata and controls
91 lines (76 loc) · 2.43 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Copyright 2012 Florian Petran
#ifndef ALIGN_H_
#define ALIGN_H_
#include<cstdlib>
#include<list>
#include<utility>
#include<map>
#include"params.h"
#include"text.h"
#include"dictionary.h"
#include"containers.h"
#include"scorers.h"
namespace Align {
class Candidates {
friend class AlignMake;
public:
explicit Candidates(const Dictionary&);
~Candidates();
Candidates() = delete;
Candidates(const Candidates&) = delete;
const Candidates& operator=(const Candidates&) = delete;
/// collect all translation candidates
void collect();
typedef std::map<WordToken, std::list<WordToken>*>::iterator
iterator;
inline Candidates::iterator begin() {
return _translations.begin();
};
inline Candidates::iterator end() {
return _translations.end();
};
inline std::list<WordToken>* at(const WordToken& pos) const {
return _translations.at(pos);
}
inline std::list<WordToken>* operator[](const WordToken& pos) {
return _translations[pos];
}
protected:
std::map<WordToken, std::list<WordToken>*> _translations;
const Dictionary* _dict;
};
class AlignMake {
public:
explicit AlignMake(Candidates* cand);
~AlignMake();
AlignMake() = delete;
AlignMake(const AlignMake&) = delete;
const AlignMake&
operator=(const AlignMake&) = delete;
/// construct initial Sequence objects (bigrams of pairs)
AlignMake& initial_sequences();
/// expand the Sequence at tail end
AlignMake& expand_sequences();
/// merge Sequence that are close
AlignMake& merge_sequences();
/// collect confidence scores for all Sequence
AlignMake& collect_scores();
/// remove all but topranking Sequence
AlignMake& get_topranking();
inline Hypothesis* get_result() {
return hypothesis;
}
/// return the address of Scorer container, so that users
/// can push_back() custom Scorer methods.
inline ScoringMethods* scorers() {
return &scoring_methods;
}
private:
Hypothesis* hypothesis;
Candidates* _candidates;
const Dictionary* _dict;
/// contains all scoring methods as functors
ScoringMethods scoring_methods;
};
} // namespace Align
#endif // ALIGN_H_