1 $NetBSD
: patch
-src_include_fst_replace
.h
,v
1.1 2012/07/03 17:42:05 joerg Exp $
3 --- src
/include
/fst
/replace
.h
.orig
2009-03-21 03:35:34.000000000 +0000
4 +++ src
/include
/fst
/replace
.h
6 #ifndef FST_LIB_REPLACE_H__
7 #define FST_LIB_REPLACE_H__
11 +#if defined(_LIBCPP_VERSION) || __cplusplus >= 201103L
12 +#include <unordered_map>
13 +using std::unordered_map
;
15 #include <tr1/unordered_map>
16 using std::tr1::unordered_map
;
21 @@
-424,16 +431,16 @@
class ReplaceFstImpl
: public CacheImpl
<
23 // return final weight of state (kInfWeight means state is not final)
24 Weight
Final(StateId s
) {
26 + if (!this->HasFinal(s
)) {
27 const StateTuple
& tuple
= state_table_
->Tuple(s
);
28 const StackPrefix
& stack
= stackprefix_array_
[tuple
.prefix_id
];
29 const Fst
<A
>* fst
= fst_array_
[tuple
.fst_id
];
30 StateId fst_state
= tuple
.fst_state
;
32 if (fst
->Final(fst_state
) != Weight::Zero() && stack
.Depth() == 0)
33 - SetFinal(s
, fst
->Final(fst_state
));
34 + this->SetFinal(s
, fst
->Final(fst_state
));
36 - SetFinal(s
, Weight::Zero());
37 + this->SetFinal(s
, Weight::Zero());
39 return CacheImpl
<A
>::Final(s
);
41 @@
-471,7 +478,7 @@
class ReplaceFstImpl
: public CacheImpl
<
42 const Fst
<A
>* fst
= fst_array_
[tuple
.fst_id
];
43 StateId fst_state
= tuple
.fst_state
;
44 if (fst_state
== kNoStateId
) {
50 @@
-483,7 +490,7 @@
class ReplaceFstImpl
: public CacheImpl
<
52 StateId nextstate
= state_table_
->FindState(
53 StateTuple(prefix_id
, top
.fst_id
, top
.nextstate
));
54 - AddArc(s
, A(0, 0, fst
->Final(fst_state
), nextstate
));
55 + this->AddArc(s
, A(0, 0, fst
->Final(fst_state
), nextstate
));
58 // extend arcs leaving the state
59 @@
-493,7 +500,7 @@
class ReplaceFstImpl
: public CacheImpl
<
60 if (arc
.olabel
== 0) { // expand local fst
61 StateId nextstate
= state_table_
->FindState(
62 StateTuple(tuple
.prefix_id
, tuple
.fst_id
, arc
.nextstate
));
63 - AddArc(s
, A(arc
.ilabel
, arc
.olabel
, arc
.weight
, nextstate
));
64 + this->AddArc(s
, A(arc
.ilabel
, arc
.olabel
, arc
.weight
, nextstate
));
66 // check for non terminal
67 typename
NonTerminalHash::const_iterator it
=
68 @@
-511,17 +518,17 @@
class ReplaceFstImpl
: public CacheImpl
<
69 StateId nt_nextstate
= state_table_
->FindState(
70 StateTuple(nt_prefix
, nonterminal
, nt_start
));
71 Label ilabel
= (epsilon_on_replace_
) ? 0 : arc
.ilabel
;
72 - AddArc(s
, A(ilabel
, 0, arc
.weight
, nt_nextstate
));
73 + this->AddArc(s
, A(ilabel
, 0, arc
.weight
, nt_nextstate
));
76 StateId nextstate
= state_table_
->FindState(
77 StateTuple(tuple
.prefix_id
, tuple
.fst_id
, arc
.nextstate
));
78 - AddArc(s
, A(arc
.ilabel
, arc
.olabel
, arc
.weight
, nextstate
));
79 + this->AddArc(s
, A(arc
.ilabel
, arc
.olabel
, arc
.weight
, nextstate
));