tokenalignment.h
3.52 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
/*
* ASCLITE
* Author: Jerome Ajot, Jon Fiscus, Nicolas Radde, Chris Laprun
*
* This software was developed at the National Institute of Standards and Technology by
* employees of the Federal Government in the course of their official duties. Pursuant
* to title 17 Section 105 of the United States Code this software is not subject to
* copyright protection and is in the public domain. ASCLITE is an experimental system.
* NIST assumes no responsibility whatsoever for its use by other parties, and makes no
* guarantees, expressed or implied, about its quality, reliability, or any other
* characteristic. We would appreciate acknowledgement if the software is used.
*
* THIS SOFTWARE IS PROVIDED "AS IS." With regard to this software, NIST MAKES NO EXPRESS
* OR IMPLIED WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING MERCHANTABILITY,
* OR FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef TOKENALIGNMENT_H
#define TOKENALIGNMENT_H
#include "stdinc.h"
#include "token.h"
class TokenAlignment
{
public:
class AlignmentResult
{
public:
AlignmentResult(const string & _shortName = string("UNSET"), const string & _description = string("Unset description"));
string GetDescription() { return m_description; }
string GetShortName() { return m_shortName; }
inline bool operator==(const AlignmentResult & rh) const { return m_shortName == rh.m_shortName; }
private:
string m_shortName;
string m_description;
};
class AlignmentEvaluation
{
public:
AlignmentEvaluation(Token* token, const TokenAlignment::AlignmentResult & result = TokenAlignment::UNAVAILABLE);
~AlignmentEvaluation() {}
Token* GetToken() { return m_token; }
TokenAlignment::AlignmentResult GetResult() { return m_result; }
void SetResult(const TokenAlignment::AlignmentResult & result) { m_result = result; }
string ToString();
bool Equals(AlignmentEvaluation* other);
private:
TokenAlignment::AlignmentResult m_result;
Token* m_token;
};
TokenAlignment(Token* refToken);
~TokenAlignment();
int AddAlignmentFor(const string & hypothesisKey, Token* hypothesisToken);
AlignmentEvaluation* GetAlignmentFor(const string & system) { return m_alignmentEvaluations[system]; }
AlignmentResult GetResultFor(const string & system);
Token* GetTokenFor(const string & system);
Token* GetReferenceToken();
string ToString();
bool Equals(TokenAlignment* other) { return (this == other); }
inline bool operator==(const TokenAlignment &rh) { return (this->m_alignmentEvaluations == rh.m_alignmentEvaluations); }
static const AlignmentResult CORRECT;
static const AlignmentResult SUBSTITUTION;
static const AlignmentResult SPEAKERSUB;
static const AlignmentResult DELETION;
static const AlignmentResult INSERTION;
static const AlignmentResult REFERENCE;
static const AlignmentResult INVALID_SYSTEM;
static const AlignmentResult UNAVAILABLE;
static const string REFERENCE_KEY;
private:
map< string, AlignmentEvaluation* > m_alignmentEvaluations;
};
typedef map< string, TokenAlignment::AlignmentEvaluation* > t_alignmentMap;
#endif