1 |
commit: 9f412ecfb867c63bf2b22c5649173226278a2ded |
2 |
Author: Pavel Denisov <pavel.a.denisov <AT> gmail <DOT> com> |
3 |
AuthorDate: Sat Feb 28 19:26:08 2015 +0000 |
4 |
Commit: Justin Lecher <jlec <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Feb 28 19:26:08 2015 +0000 |
6 |
URL: http://sources.gentoo.org/gitweb/?p=proj/sci.git;a=commit;h=9f412ecf |
7 |
|
8 |
sci-misc/openfst: version bump |
9 |
|
10 |
Package-Manager: portage-2.2.17 |
11 |
|
12 |
--- |
13 |
sci-misc/openfst/ChangeLog | 8 +- |
14 |
sci-misc/openfst/files/kaldi-openfst-1.4.1.patch | 269 +++++++++++++++++++++++ |
15 |
sci-misc/openfst/openfst-1.4.1.ebuild | 19 ++ |
16 |
3 files changed, 295 insertions(+), 1 deletion(-) |
17 |
|
18 |
diff --git a/sci-misc/openfst/ChangeLog b/sci-misc/openfst/ChangeLog |
19 |
index 47bb94e..4278e32 100644 |
20 |
--- a/sci-misc/openfst/ChangeLog |
21 |
+++ b/sci-misc/openfst/ChangeLog |
22 |
@@ -1,7 +1,13 @@ |
23 |
# ChangeLog for sci-misc/openfst |
24 |
-# Copyright 1999-2014 Gentoo Foundation; Distributed under the GPL v2 |
25 |
+# Copyright 1999-2015 Gentoo Foundation; Distributed under the GPL v2 |
26 |
# $Header: $ |
27 |
|
28 |
+*openfst-1.4.1 (28 Feb 2015) |
29 |
+ |
30 |
+ 28 Feb 2015; Pavel Denisov <pavel.a.denisov@×××××.com> +openfst-1.4.1.ebuild, |
31 |
+ +files/kaldi-openfst-1.4.1.patch: |
32 |
+ Version bump. |
33 |
+ |
34 |
12 Nov 2014; Justin Lecher <jlec@g.o> -openfst-1.2.7.ebuild: |
35 |
Drop old |
36 |
|
37 |
|
38 |
diff --git a/sci-misc/openfst/files/kaldi-openfst-1.4.1.patch b/sci-misc/openfst/files/kaldi-openfst-1.4.1.patch |
39 |
new file mode 100644 |
40 |
index 0000000..140ea4e |
41 |
--- /dev/null |
42 |
+++ b/sci-misc/openfst/files/kaldi-openfst-1.4.1.patch |
43 |
@@ -0,0 +1,269 @@ |
44 |
+diff -crB openfst-1.4.1.orig/src/include/fst/lock.h openfst-1.4.1/src/include/fst/lock.h |
45 |
+*** openfst-1.4.1.orig/src/include/fst/lock.h 2012-04-25 19:43:47.000000000 -0400 |
46 |
+--- openfst-1.4.1/src/include/fst/lock.h 2015-02-28 14:12:29.009385600 -0400 |
47 |
+*************** |
48 |
+*** 78,85 **** |
49 |
+ RefCounter() : count_(1) {} |
50 |
+ |
51 |
+ int count() const { return count_; } |
52 |
+! int Incr() const { return ++count_; } |
53 |
+! int Decr() const { return --count_; } |
54 |
+ |
55 |
+ private: |
56 |
+ mutable int count_; |
57 |
+--- 78,93 ---- |
58 |
+ RefCounter() : count_(1) {} |
59 |
+ |
60 |
+ int count() const { return count_; } |
61 |
+! |
62 |
+! // below lines are modifications of openfst for multi-thrads support, |
63 |
+! // from tools/extras/openfst_gcc41up.patch, applied by tools/Makefile, |
64 |
+! // applicable to gcc 4.1 or above |
65 |
+! // int Incr() const { return ++count_; } |
66 |
+! // int Decr() const { return --count_; } |
67 |
+! |
68 |
+! int Incr() const { return __sync_add_and_fetch(&count_, 1); } |
69 |
+! int Decr() const { return __sync_sub_and_fetch(&count_, 1); } |
70 |
+! // end modifications |
71 |
+ |
72 |
+ private: |
73 |
+ mutable int count_; |
74 |
+diff -crB openfst-1.4.1.orig/src/include/fst/minimize.h openfst-1.4.1/src/include/fst/minimize.h |
75 |
+*** openfst-1.4.1.orig/src/include/fst/minimize.h 2014-04-29 18:15:17.000000000 -0400 |
76 |
+--- openfst-1.4.1/src/include/fst/minimize.h 2015-02-28 14:11:39.270566070 -0400 |
77 |
+*************** |
78 |
+*** 134,140 **** |
79 |
+ typedef typename A::Weight Weight; |
80 |
+ typedef ReverseArc<A> RevA; |
81 |
+ |
82 |
+! CyclicMinimizer(const ExpandedFst<A>& fst) { |
83 |
+ Initialize(fst); |
84 |
+ Compute(fst); |
85 |
+ } |
86 |
+--- 134,147 ---- |
87 |
+ typedef typename A::Weight Weight; |
88 |
+ typedef ReverseArc<A> RevA; |
89 |
+ |
90 |
+! CyclicMinimizer(const ExpandedFst<A>& fst): |
91 |
+! // tell the Partition data-member to expect multiple repeated |
92 |
+! // calls to SplitOn with the same element if we are non-deterministic. |
93 |
+! P_(fst.Properties(kIDeterministic, true) == 0) { |
94 |
+! if(fst.Properties(kIDeterministic, true) == 0) |
95 |
+! CHECK(Weight::Properties() & kIdempotent); // this minimization |
96 |
+! // algorithm for non-deterministic FSTs can only work with idempotent |
97 |
+! // semirings. |
98 |
+ Initialize(fst); |
99 |
+ Compute(fst); |
100 |
+ } |
101 |
+*************** |
102 |
+*** 315,321 **** |
103 |
+ typedef typename A::StateId ClassId; |
104 |
+ typedef typename A::Weight Weight; |
105 |
+ |
106 |
+! AcyclicMinimizer(const ExpandedFst<A>& fst) { |
107 |
+ Initialize(fst); |
108 |
+ Refine(fst); |
109 |
+ } |
110 |
+--- 322,334 ---- |
111 |
+ typedef typename A::StateId ClassId; |
112 |
+ typedef typename A::Weight Weight; |
113 |
+ |
114 |
+! AcyclicMinimizer(const ExpandedFst<A>& fst): |
115 |
+! // tell the Partition data-member to expect multiple repeated |
116 |
+! // calls to SplitOn with the same element if we are non-deterministic. |
117 |
+! partition_(fst.Properties(kIDeterministic, true) == 0) { |
118 |
+! if(fst.Properties(kIDeterministic, true) == 0) |
119 |
+! CHECK(Weight::Properties() & kIdempotent); // minimization for |
120 |
+! // non-deterministic FSTs can only work with idempotent semirings. |
121 |
+ Initialize(fst); |
122 |
+ Refine(fst); |
123 |
+ } |
124 |
+*************** |
125 |
+*** 531,543 **** |
126 |
+ void Minimize(MutableFst<A>* fst, |
127 |
+ MutableFst<A>* sfst = 0, |
128 |
+ float delta = kDelta) { |
129 |
+! uint64 props = fst->Properties(kAcceptor | kIDeterministic| |
130 |
+! kWeighted | kUnweighted, true); |
131 |
+! if (!(props & kIDeterministic)) { |
132 |
+! FSTERROR() << "FST is not deterministic"; |
133 |
+! fst->SetProperties(kError, kError); |
134 |
+! return; |
135 |
+! } |
136 |
+ |
137 |
+ if (!(props & kAcceptor)) { // weighted transducer |
138 |
+ VectorFst< GallicArc<A, GALLIC_LEFT> > gfst; |
139 |
+--- 544,550 ---- |
140 |
+ void Minimize(MutableFst<A>* fst, |
141 |
+ MutableFst<A>* sfst = 0, |
142 |
+ float delta = kDelta) { |
143 |
+! uint64 props = fst->Properties(kAcceptor | kWeighted | kUnweighted, true); |
144 |
+ |
145 |
+ if (!(props & kAcceptor)) { // weighted transducer |
146 |
+ VectorFst< GallicArc<A, GALLIC_LEFT> > gfst; |
147 |
+diff -crB openfst-1.4.1.orig/src/include/fst/partition.h openfst-1.4.1/src/include/fst/partition.h |
148 |
+*** openfst-1.4.1.orig/src/include/fst/partition.h 2014-04-29 18:15:17.000000000 -0400 |
149 |
+--- openfst-1.4.1/src/include/fst/partition.h 2015-02-28 14:11:39.271566087 -0400 |
150 |
+*************** |
151 |
+*** 43,50 **** |
152 |
+ friend class PartitionIterator<T>; |
153 |
+ |
154 |
+ struct Element { |
155 |
+! Element() : value(0), next(0), prev(0) {} |
156 |
+! Element(T v) : value(v), next(0), prev(0) {} |
157 |
+ |
158 |
+ T value; |
159 |
+ Element* next; |
160 |
+--- 43,50 ---- |
161 |
+ friend class PartitionIterator<T>; |
162 |
+ |
163 |
+ struct Element { |
164 |
+! Element() : value(0), next(0), prev(0) {} |
165 |
+! Element(T v) : value(v), next(0), prev(0) {} |
166 |
+ |
167 |
+ T value; |
168 |
+ Element* next; |
169 |
+*************** |
170 |
+*** 52,60 **** |
171 |
+ }; |
172 |
+ |
173 |
+ public: |
174 |
+! Partition() {} |
175 |
+ |
176 |
+! Partition(T num_states) { |
177 |
+ Initialize(num_states); |
178 |
+ } |
179 |
+ |
180 |
+--- 52,62 ---- |
181 |
+ }; |
182 |
+ |
183 |
+ public: |
184 |
+! Partition(bool allow_repeated_split): |
185 |
+! allow_repeated_split_(allow_repeated_split) {} |
186 |
+ |
187 |
+! Partition(bool allow_repeated_split, T num_states): |
188 |
+! allow_repeated_split_(allow_repeated_split) { |
189 |
+ Initialize(num_states); |
190 |
+ } |
191 |
+ |
192 |
+*************** |
193 |
+*** 137,152 **** |
194 |
+ if (class_size_[class_id] == 1) return; |
195 |
+ |
196 |
+ // first time class is split |
197 |
+! if (split_size_[class_id] == 0) |
198 |
+ visited_classes_.push_back(class_id); |
199 |
+! |
200 |
+ // increment size of split (set of element at head of chain) |
201 |
+ split_size_[class_id]++; |
202 |
+! |
203 |
+ // update split point |
204 |
+! if (class_split_[class_id] == 0) |
205 |
+! class_split_[class_id] = classes_[class_id]; |
206 |
+! if (class_split_[class_id] == elements_[element_id]) |
207 |
+ class_split_[class_id] = elements_[element_id]->next; |
208 |
+ |
209 |
+ // move to head of chain in same class |
210 |
+--- 139,154 ---- |
211 |
+ if (class_size_[class_id] == 1) return; |
212 |
+ |
213 |
+ // first time class is split |
214 |
+! if (split_size_[class_id] == 0) { |
215 |
+ visited_classes_.push_back(class_id); |
216 |
+! class_split_[class_id] = classes_[class_id]; |
217 |
+! } |
218 |
+ // increment size of split (set of element at head of chain) |
219 |
+ split_size_[class_id]++; |
220 |
+! |
221 |
+ // update split point |
222 |
+! if (class_split_[class_id] != 0 |
223 |
+! && class_split_[class_id] == elements_[element_id]) |
224 |
+ class_split_[class_id] = elements_[element_id]->next; |
225 |
+ |
226 |
+ // move to head of chain in same class |
227 |
+*************** |
228 |
+*** 157,165 **** |
229 |
+ // class indices of the newly created class. Returns the new_class id |
230 |
+ // or -1 if no new class was created. |
231 |
+ T SplitRefine(T class_id) { |
232 |
+ // only split if necessary |
233 |
+! if (class_size_[class_id] == split_size_[class_id]) { |
234 |
+! class_split_[class_id] = 0; |
235 |
+ split_size_[class_id] = 0; |
236 |
+ return -1; |
237 |
+ } else { |
238 |
+--- 159,169 ---- |
239 |
+ // class indices of the newly created class. Returns the new_class id |
240 |
+ // or -1 if no new class was created. |
241 |
+ T SplitRefine(T class_id) { |
242 |
++ |
243 |
++ Element* split_el = class_split_[class_id]; |
244 |
+ // only split if necessary |
245 |
+! //if (class_size_[class_id] == split_size_[class_id]) { |
246 |
+! if(split_el == NULL) { // we split on everything... |
247 |
+ split_size_[class_id] = 0; |
248 |
+ return -1; |
249 |
+ } else { |
250 |
+*************** |
251 |
+*** 163,180 **** |
252 |
+ split_size_[class_id] = 0; |
253 |
+ return -1; |
254 |
+ } else { |
255 |
+- |
256 |
+ T new_class = AddClass(); |
257 |
+ size_t remainder = class_size_[class_id] - split_size_[class_id]; |
258 |
+ if (remainder < split_size_[class_id]) { // add smaller |
259 |
+- Element* split_el = class_split_[class_id]; |
260 |
+ classes_[new_class] = split_el; |
261 |
+- class_size_[class_id] = split_size_[class_id]; |
262 |
+- class_size_[new_class] = remainder; |
263 |
+ split_el->prev->next = 0; |
264 |
+ split_el->prev = 0; |
265 |
+ } else { |
266 |
+- Element* split_el = class_split_[class_id]; |
267 |
+ classes_[new_class] = classes_[class_id]; |
268 |
+ class_size_[class_id] = remainder; |
269 |
+ class_size_[new_class] = split_size_[class_id]; |
270 |
+--- 167,189 ---- |
271 |
+ split_size_[class_id] = 0; |
272 |
+ return -1; |
273 |
+ } else { |
274 |
+ T new_class = AddClass(); |
275 |
++ |
276 |
++ if(allow_repeated_split_) { // split_size_ is possibly |
277 |
++ // inaccurate, so work it out exactly. |
278 |
++ size_t split_count; Element *e; |
279 |
++ for(split_count=0,e=classes_[class_id]; |
280 |
++ e != split_el; split_count++, e=e->next); |
281 |
++ split_size_[class_id] = split_count; |
282 |
++ } |
283 |
+ size_t remainder = class_size_[class_id] - split_size_[class_id]; |
284 |
+ if (remainder < split_size_[class_id]) { // add smaller |
285 |
+ classes_[new_class] = split_el; |
286 |
+ split_el->prev->next = 0; |
287 |
+ split_el->prev = 0; |
288 |
++ class_size_[class_id] = split_size_[class_id]; |
289 |
++ class_size_[new_class] = remainder; |
290 |
+ } else { |
291 |
+ classes_[new_class] = classes_[class_id]; |
292 |
+ class_size_[class_id] = remainder; |
293 |
+ class_size_[new_class] = split_size_[class_id]; |
294 |
+*************** |
295 |
+*** 245,254 **** |
296 |
+--- 254,269 ---- |
297 |
+ vector<T> class_size_; |
298 |
+ |
299 |
+ // size of split for each class |
300 |
++ // in the nondeterministic case, split_size_ is actually an upper |
301 |
++ // bound on the size of split for each class. |
302 |
+ vector<T> split_size_; |
303 |
+ |
304 |
+ // set of visited classes to be used in split refine |
305 |
+ vector<T> visited_classes_; |
306 |
++ |
307 |
++ // true if input fst was deterministic: we can make |
308 |
++ // certain assumptions in this case that speed up the algorithm. |
309 |
++ bool allow_repeated_split_; |
310 |
+ }; |
311 |
+ |
312 |
+ |
313 |
|
314 |
diff --git a/sci-misc/openfst/openfst-1.4.1.ebuild b/sci-misc/openfst/openfst-1.4.1.ebuild |
315 |
new file mode 100644 |
316 |
index 0000000..a3eb530 |
317 |
--- /dev/null |
318 |
+++ b/sci-misc/openfst/openfst-1.4.1.ebuild |
319 |
@@ -0,0 +1,19 @@ |
320 |
+# Copyright 1999-2015 Gentoo Foundation |
321 |
+# Distributed under the terms of the GNU General Public License v2 |
322 |
+# $Header: $ |
323 |
+ |
324 |
+EAPI="5" |
325 |
+ |
326 |
+inherit eutils |
327 |
+ |
328 |
+DESCRIPTION="Finite State Transducer tools by Google et al." |
329 |
+HOMEPAGE="http://www.openfst.org" |
330 |
+SRC_URI="http://www.openfst.org/twiki/pub/FST/FstDownload/${P}.tar.gz" |
331 |
+ |
332 |
+LICENSE="Apache-2.0" |
333 |
+SLOT="0" |
334 |
+KEYWORDS="~amd64 ~x86" |
335 |
+ |
336 |
+src_prepare() { |
337 |
+ epatch "${FILESDIR}/kaldi-${P}.patch" |
338 |
+} |