1 |
commit: f7284d4b0a2dd6b4414b1812531f7b237c752e95 |
2 |
Author: Pavel Denisov <pavel.a.denisov <AT> gmail <DOT> com> |
3 |
AuthorDate: Thu Nov 21 12:33:27 2013 +0000 |
4 |
Commit: Justin Lecher <jlec <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Nov 21 13:28:13 2013 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/sci.git;a=commit;h=f7284d4b |
7 |
|
8 |
sci-misc/openfst: version bump, patch from Kaldi |
9 |
|
10 |
Package-Manager: portage-2.2.7 |
11 |
|
12 |
--- |
13 |
sci-misc/openfst/ChangeLog | 6 + |
14 |
sci-misc/openfst/files/kaldi.patch | 599 +++++++++++++++++++++ |
15 |
.../{openfst-1.3.2.ebuild => openfst-1.3.4.ebuild} | 6 + |
16 |
3 files changed, 611 insertions(+) |
17 |
|
18 |
diff --git a/sci-misc/openfst/ChangeLog b/sci-misc/openfst/ChangeLog |
19 |
index b84b7db..3d9cf2c 100644 |
20 |
--- a/sci-misc/openfst/ChangeLog |
21 |
+++ b/sci-misc/openfst/ChangeLog |
22 |
@@ -2,6 +2,12 @@ |
23 |
# Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2 |
24 |
# $Header: $ |
25 |
|
26 |
+*openfst-1.3.4 (21 Nov 2013) |
27 |
+ |
28 |
+ 21 Nov 2013; Pavel Denisov <pavel.a.denisov@×××××.com> +files/kaldi.patch, |
29 |
+ +openfst-1.3.4.ebuild, -openfst-1.3.2.ebuild: |
30 |
+ sci-misc/openfst: version bump, patch from Kaldi |
31 |
+ |
32 |
03 Mar 2013; Justin Lecher <jlec@g.o> openfst-1.2.7.ebuild, |
33 |
openfst-1.3.2.ebuild, metadata.xml: |
34 |
Add ~amd64 or ~x86 keywords for revdeps |
35 |
|
36 |
diff --git a/sci-misc/openfst/files/kaldi.patch b/sci-misc/openfst/files/kaldi.patch |
37 |
new file mode 100644 |
38 |
index 0000000..3a3854e |
39 |
--- /dev/null |
40 |
+++ b/sci-misc/openfst/files/kaldi.patch |
41 |
@@ -0,0 +1,599 @@ |
42 |
+diff -crB openfst-1.3.4.orig/src/include/fst/interval-set.h openfst-1.3.4/src/include/fst/interval-set.h |
43 |
+*** openfst-1.3.4.orig/src/include/fst/interval-set.h 2013-01-24 06:36:23.000000000 +0400 |
44 |
+--- openfst-1.3.4/src/include/fst/interval-set.h 2013-11-21 15:59:08.541136087 +0400 |
45 |
+*************** |
46 |
+*** 37,74 **** |
47 |
+ class IntervalSet { |
48 |
+ public: |
49 |
+ struct Interval { |
50 |
+! T begin; |
51 |
+! T end; |
52 |
+ |
53 |
+! Interval() : begin(-1), end(-1) {} |
54 |
+ |
55 |
+! Interval(T b, T e) : begin(b), end(e) {} |
56 |
+ |
57 |
+ bool operator<(const Interval &i) const { |
58 |
+! return begin < i.begin || (begin == i.begin && end > i.end); |
59 |
+ } |
60 |
+ |
61 |
+ bool operator==(const Interval &i) const { |
62 |
+! return begin == i.begin && end == i.end; |
63 |
+ } |
64 |
+ |
65 |
+ bool operator!=(const Interval &i) const { |
66 |
+! return begin != i.begin || end != i.end; |
67 |
+ } |
68 |
+ |
69 |
+ istream &Read(istream &strm) { |
70 |
+ T n; |
71 |
+ ReadType(strm, &n); |
72 |
+! begin = n; |
73 |
+ ReadType(strm, &n); |
74 |
+! end = n; |
75 |
+ return strm; |
76 |
+ } |
77 |
+ |
78 |
+ ostream &Write(ostream &strm) const { |
79 |
+! T n = begin; |
80 |
+ WriteType(strm, n); |
81 |
+! n = end; |
82 |
+ WriteType(strm, n); |
83 |
+ return strm; |
84 |
+ } |
85 |
+--- 37,74 ---- |
86 |
+ class IntervalSet { |
87 |
+ public: |
88 |
+ struct Interval { |
89 |
+! T begin_; |
90 |
+! T end_; |
91 |
+ |
92 |
+! Interval() : begin_(-1), end_(-1) {} |
93 |
+ |
94 |
+! Interval(T b, T e) : begin_(b), end_(e) {} |
95 |
+ |
96 |
+ bool operator<(const Interval &i) const { |
97 |
+! return begin_ < i.begin_ || (begin_ == i.begin_ && end_ > i.end_); |
98 |
+ } |
99 |
+ |
100 |
+ bool operator==(const Interval &i) const { |
101 |
+! return begin_ == i.begin_ && end_ == i.end_; |
102 |
+ } |
103 |
+ |
104 |
+ bool operator!=(const Interval &i) const { |
105 |
+! return begin_ != i.begin_ || end_ != i.end_; |
106 |
+ } |
107 |
+ |
108 |
+ istream &Read(istream &strm) { |
109 |
+ T n; |
110 |
+ ReadType(strm, &n); |
111 |
+! begin_ = n; |
112 |
+ ReadType(strm, &n); |
113 |
+! end_ = n; |
114 |
+ return strm; |
115 |
+ } |
116 |
+ |
117 |
+ ostream &Write(ostream &strm) const { |
118 |
+! T n = begin_; |
119 |
+ WriteType(strm, n); |
120 |
+! n = end_; |
121 |
+ WriteType(strm, n); |
122 |
+ return strm; |
123 |
+ } |
124 |
+*************** |
125 |
+*** 108,114 **** |
126 |
+ lower_bound(intervals_.begin(), intervals_.end(), interval); |
127 |
+ if (lb == intervals_.begin()) |
128 |
+ return false; |
129 |
+! return (--lb)->end > value; |
130 |
+ } |
131 |
+ |
132 |
+ // Requires intervals be normalized. |
133 |
+--- 108,114 ---- |
134 |
+ lower_bound(intervals_.begin(), intervals_.end(), interval); |
135 |
+ if (lb == intervals_.begin()) |
136 |
+ return false; |
137 |
+! return (--lb)->end_ > value; |
138 |
+ } |
139 |
+ |
140 |
+ // Requires intervals be normalized. |
141 |
+*************** |
142 |
+*** 123,129 **** |
143 |
+ |
144 |
+ bool Singleton() const { |
145 |
+ return intervals_.size() == 1 && |
146 |
+! intervals_[0].begin + 1 == intervals_[0].end; |
147 |
+ } |
148 |
+ |
149 |
+ |
150 |
+--- 123,129 ---- |
151 |
+ |
152 |
+ bool Singleton() const { |
153 |
+ return intervals_.size() == 1 && |
154 |
+! intervals_[0].begin_ + 1 == intervals_[0].end_; |
155 |
+ } |
156 |
+ |
157 |
+ |
158 |
+*************** |
159 |
+*** 178,194 **** |
160 |
+ T size = 0; |
161 |
+ for (T i = 0; i < intervals_.size(); ++i) { |
162 |
+ Interval &inti = intervals_[i]; |
163 |
+! if (inti.begin == inti.end) |
164 |
+ continue; |
165 |
+ for (T j = i + 1; j < intervals_.size(); ++j) { |
166 |
+ Interval &intj = intervals_[j]; |
167 |
+! if (intj.begin > inti.end) |
168 |
+ break; |
169 |
+! if (intj.end > inti.end) |
170 |
+! inti.end = intj.end; |
171 |
+ ++i; |
172 |
+ } |
173 |
+! count_ += inti.end - inti.begin; |
174 |
+ intervals_[size++] = inti; |
175 |
+ } |
176 |
+ intervals_.resize(size); |
177 |
+--- 178,194 ---- |
178 |
+ T size = 0; |
179 |
+ for (T i = 0; i < intervals_.size(); ++i) { |
180 |
+ Interval &inti = intervals_[i]; |
181 |
+! if (inti.begin_ == inti.end_) |
182 |
+ continue; |
183 |
+ for (T j = i + 1; j < intervals_.size(); ++j) { |
184 |
+ Interval &intj = intervals_[j]; |
185 |
+! if (intj.begin_ > inti.end_) |
186 |
+ break; |
187 |
+! if (intj.end_ > inti.end_) |
188 |
+! inti.end_ = intj.end_; |
189 |
+ ++i; |
190 |
+ } |
191 |
+! count_ += inti.end_ - inti.begin_; |
192 |
+ intervals_[size++] = inti; |
193 |
+ } |
194 |
+ intervals_.resize(size); |
195 |
+*************** |
196 |
+*** 208,224 **** |
197 |
+ oset->count_ = 0; |
198 |
+ |
199 |
+ while (it1 != intervals_.end() && it2 != iintervals->end()) { |
200 |
+! if (it1->end <= it2->begin) { |
201 |
+ ++it1; |
202 |
+! } else if (it2->end <= it1->begin) { |
203 |
+ ++it2; |
204 |
+ } else { |
205 |
+ Interval interval; |
206 |
+! interval.begin = max(it1->begin, it2->begin); |
207 |
+! interval.end = min(it1->end, it2->end); |
208 |
+ ointervals->push_back(interval); |
209 |
+! oset->count_ += interval.end - interval.begin; |
210 |
+! if (it1->end < it2->end) |
211 |
+ ++it1; |
212 |
+ else |
213 |
+ ++it2; |
214 |
+--- 208,224 ---- |
215 |
+ oset->count_ = 0; |
216 |
+ |
217 |
+ while (it1 != intervals_.end() && it2 != iintervals->end()) { |
218 |
+! if (it1->end_ <= it2->begin_) { |
219 |
+ ++it1; |
220 |
+! } else if (it2->end_ <= it1->begin_) { |
221 |
+ ++it2; |
222 |
+ } else { |
223 |
+ Interval interval; |
224 |
+! interval.begin_ = max(it1->begin_, it2->begin_); |
225 |
+! interval.end_ = min(it1->end_, it2->end_); |
226 |
+ ointervals->push_back(interval); |
227 |
+! oset->count_ += interval.end_ - interval.begin_; |
228 |
+! if (it1->end_ < it2->end_) |
229 |
+ ++it1; |
230 |
+ else |
231 |
+ ++it2; |
232 |
+*************** |
233 |
+*** 235,255 **** |
234 |
+ oset->count_ = 0; |
235 |
+ |
236 |
+ Interval interval; |
237 |
+! interval.begin = 0; |
238 |
+ for (typename vector<Interval>::const_iterator it = intervals_.begin(); |
239 |
+ it != intervals_.end(); |
240 |
+ ++it) { |
241 |
+! interval.end = min(it->begin, maxval); |
242 |
+! if (interval.begin < interval.end) { |
243 |
+ ointervals->push_back(interval); |
244 |
+! oset->count_ += interval.end - interval.begin; |
245 |
+ } |
246 |
+! interval.begin = it->end; |
247 |
+ } |
248 |
+! interval.end = maxval; |
249 |
+! if (interval.begin < interval.end) { |
250 |
+ ointervals->push_back(interval); |
251 |
+! oset->count_ += interval.end - interval.begin; |
252 |
+ } |
253 |
+ } |
254 |
+ |
255 |
+--- 235,255 ---- |
256 |
+ oset->count_ = 0; |
257 |
+ |
258 |
+ Interval interval; |
259 |
+! interval.begin_ = 0; |
260 |
+ for (typename vector<Interval>::const_iterator it = intervals_.begin(); |
261 |
+ it != intervals_.end(); |
262 |
+ ++it) { |
263 |
+! interval.end_ = min(it->begin_, maxval); |
264 |
+! if (interval.begin_ < interval.end_) { |
265 |
+ ointervals->push_back(interval); |
266 |
+! oset->count_ += interval.end_ - interval.begin_; |
267 |
+ } |
268 |
+! interval.begin_ = it->end_; |
269 |
+ } |
270 |
+! interval.end_ = maxval; |
271 |
+! if (interval.begin_ < interval.end_) { |
272 |
+ ointervals->push_back(interval); |
273 |
+! oset->count_ += interval.end_ - interval.begin_; |
274 |
+ } |
275 |
+ } |
276 |
+ |
277 |
+*************** |
278 |
+*** 263,269 **** |
279 |
+ oset->count_ = 0; |
280 |
+ } else { |
281 |
+ IntervalSet<T> cset; |
282 |
+! iset.Complement(intervals_.back().end, &cset); |
283 |
+ Intersect(cset, oset); |
284 |
+ } |
285 |
+ } |
286 |
+--- 263,269 ---- |
287 |
+ oset->count_ = 0; |
288 |
+ } else { |
289 |
+ IntervalSet<T> cset; |
290 |
+! iset.Complement(intervals_.back().end_, &cset); |
291 |
+ Intersect(cset, oset); |
292 |
+ } |
293 |
+ } |
294 |
+*************** |
295 |
+*** 277,285 **** |
296 |
+ typename vector<Interval>::const_iterator it2 = intervals->begin(); |
297 |
+ |
298 |
+ while (it1 != intervals_.end() && it2 != intervals->end()) { |
299 |
+! if (it1->end <= it2->begin) { |
300 |
+ ++it1; |
301 |
+! } else if (it2->end <= it1->begin) { |
302 |
+ ++it2; |
303 |
+ } else { |
304 |
+ return true; |
305 |
+--- 277,285 ---- |
306 |
+ typename vector<Interval>::const_iterator it2 = intervals->begin(); |
307 |
+ |
308 |
+ while (it1 != intervals_.end() && it2 != intervals->end()) { |
309 |
+! if (it1->end_ <= it2->begin_) { |
310 |
+ ++it1; |
311 |
+! } else if (it2->end_ <= it1->begin_) { |
312 |
+ ++it2; |
313 |
+ } else { |
314 |
+ return true; |
315 |
+*************** |
316 |
+*** 300,320 **** |
317 |
+ bool overlap = false; // point in both intervals_ and intervals |
318 |
+ |
319 |
+ while (it1 != intervals_.end() && it2 != intervals->end()) { |
320 |
+! if (it1->end <= it2->begin) { // no overlap - it1 first |
321 |
+ only1 = true; |
322 |
+ ++it1; |
323 |
+! } else if (it2->end <= it1->begin) { // no overlap - it2 first |
324 |
+ only2 = true; |
325 |
+ ++it2; |
326 |
+! } else if (it2->begin == it1->begin && it2->end == it1->end) { // equals |
327 |
+ overlap = true; |
328 |
+ ++it1; |
329 |
+ ++it2; |
330 |
+! } else if (it2->begin <= it1->begin && it2->end >= it1->end) { // 1 c 2 |
331 |
+ only2 = true; |
332 |
+ overlap = true; |
333 |
+ ++it1; |
334 |
+! } else if (it1->begin <= it2->begin && it1->end >= it2->end) { // 2 c 1 |
335 |
+ only1 = true; |
336 |
+ overlap = true; |
337 |
+ ++it2; |
338 |
+--- 300,320 ---- |
339 |
+ bool overlap = false; // point in both intervals_ and intervals |
340 |
+ |
341 |
+ while (it1 != intervals_.end() && it2 != intervals->end()) { |
342 |
+! if (it1->end_ <= it2->begin_) { // no overlap - it1 first |
343 |
+ only1 = true; |
344 |
+ ++it1; |
345 |
+! } else if (it2->end_ <= it1->begin_) { // no overlap - it2 first |
346 |
+ only2 = true; |
347 |
+ ++it2; |
348 |
+! } else if (it2->begin_ == it1->begin_ && it2->end_ == it1->end_) { // equals |
349 |
+ overlap = true; |
350 |
+ ++it1; |
351 |
+ ++it2; |
352 |
+! } else if (it2->begin_ <= it1->begin_ && it2->end_ >= it1->end_) { // 1 c 2 |
353 |
+ only2 = true; |
354 |
+ overlap = true; |
355 |
+ ++it1; |
356 |
+! } else if (it1->begin_ <= it2->begin_ && it1->end_ >= it2->end_) { // 2 c 1 |
357 |
+ only1 = true; |
358 |
+ overlap = true; |
359 |
+ ++it2; |
360 |
+*************** |
361 |
+*** 346,356 **** |
362 |
+ typename vector<Interval>::const_iterator it2 = intervals->begin(); |
363 |
+ |
364 |
+ while (it1 != intervals_.end() && it2 != intervals->end()) { |
365 |
+! if (it1->end <= it2->begin) { // no overlap - it1 first |
366 |
+ ++it1; |
367 |
+! } else if (it2->begin < it1->begin || it2->end > it1->end) { // no C |
368 |
+ return false; |
369 |
+! } else if (it2->end == it1->end) { |
370 |
+ ++it1; |
371 |
+ ++it2; |
372 |
+ } else { |
373 |
+--- 346,356 ---- |
374 |
+ typename vector<Interval>::const_iterator it2 = intervals->begin(); |
375 |
+ |
376 |
+ while (it1 != intervals_.end() && it2 != intervals->end()) { |
377 |
+! if (it1->end_ <= it2->begin_) { // no overlap - it1 first |
378 |
+ ++it1; |
379 |
+! } else if (it2->begin_ < it1->begin_ || it2->end_ > it1->end_) { // no C |
380 |
+ return false; |
381 |
+! } else if (it2->end_ == it1->end_) { |
382 |
+ ++it1; |
383 |
+ ++it2; |
384 |
+ } else { |
385 |
+*************** |
386 |
+*** 370,376 **** |
387 |
+ ++it) { |
388 |
+ if (it != intervals->begin()) |
389 |
+ strm << ","; |
390 |
+! strm << "[" << it->begin << "," << it->end << ")"; |
391 |
+ } |
392 |
+ strm << "}"; |
393 |
+ return strm; |
394 |
+--- 370,376 ---- |
395 |
+ ++it) { |
396 |
+ if (it != intervals->begin()) |
397 |
+ strm << ","; |
398 |
+! strm << "[" << it->begin_ << "," << it->end_ << ")"; |
399 |
+ } |
400 |
+ strm << "}"; |
401 |
+ return strm; |
402 |
+diff -crB openfst-1.3.4.orig/src/include/fst/minimize.h openfst-1.3.4/src/include/fst/minimize.h |
403 |
+*** openfst-1.3.4.orig/src/include/fst/minimize.h 2013-01-24 06:36:23.000000000 +0400 |
404 |
+--- openfst-1.3.4/src/include/fst/minimize.h 2013-11-21 15:59:08.539136087 +0400 |
405 |
+*************** |
406 |
+*** 134,140 **** |
407 |
+ typedef typename A::Weight Weight; |
408 |
+ typedef ReverseArc<A> RevA; |
409 |
+ |
410 |
+! CyclicMinimizer(const ExpandedFst<A>& fst) { |
411 |
+ Initialize(fst); |
412 |
+ Compute(fst); |
413 |
+ } |
414 |
+--- 134,147 ---- |
415 |
+ typedef typename A::Weight Weight; |
416 |
+ typedef ReverseArc<A> RevA; |
417 |
+ |
418 |
+! CyclicMinimizer(const ExpandedFst<A>& fst): |
419 |
+! // tell the Partition data-member to expect multiple repeated |
420 |
+! // calls to SplitOn with the same element if we are non-deterministic. |
421 |
+! P_(fst.Properties(kIDeterministic, true) == 0) { |
422 |
+! if(fst.Properties(kIDeterministic, true) == 0) |
423 |
+! CHECK(Weight::Properties() & kIdempotent); // this minimization |
424 |
+! // algorithm for non-deterministic FSTs can only work with idempotent |
425 |
+! // semirings. |
426 |
+ Initialize(fst); |
427 |
+ Compute(fst); |
428 |
+ } |
429 |
+*************** |
430 |
+*** 315,321 **** |
431 |
+ typedef typename A::StateId ClassId; |
432 |
+ typedef typename A::Weight Weight; |
433 |
+ |
434 |
+! AcyclicMinimizer(const ExpandedFst<A>& fst) { |
435 |
+ Initialize(fst); |
436 |
+ Refine(fst); |
437 |
+ } |
438 |
+--- 322,334 ---- |
439 |
+ typedef typename A::StateId ClassId; |
440 |
+ typedef typename A::Weight Weight; |
441 |
+ |
442 |
+! AcyclicMinimizer(const ExpandedFst<A>& fst): |
443 |
+! // tell the Partition data-member to expect multiple repeated |
444 |
+! // calls to SplitOn with the same element if we are non-deterministic. |
445 |
+! partition_(fst.Properties(kIDeterministic, true) == 0) { |
446 |
+! if(fst.Properties(kIDeterministic, true) == 0) |
447 |
+! CHECK(Weight::Properties() & kIdempotent); // minimization for |
448 |
+! // non-deterministic FSTs can only work with idempotent semirings. |
449 |
+ Initialize(fst); |
450 |
+ Refine(fst); |
451 |
+ } |
452 |
+*************** |
453 |
+*** 531,543 **** |
454 |
+ void Minimize(MutableFst<A>* fst, |
455 |
+ MutableFst<A>* sfst = 0, |
456 |
+ float delta = kDelta) { |
457 |
+! uint64 props = fst->Properties(kAcceptor | kIDeterministic| |
458 |
+! kWeighted | kUnweighted, true); |
459 |
+! if (!(props & kIDeterministic)) { |
460 |
+! FSTERROR() << "FST is not deterministic"; |
461 |
+! fst->SetProperties(kError, kError); |
462 |
+! return; |
463 |
+! } |
464 |
+ |
465 |
+ if (!(props & kAcceptor)) { // weighted transducer |
466 |
+ VectorFst< GallicArc<A, STRING_LEFT> > gfst; |
467 |
+--- 544,550 ---- |
468 |
+ void Minimize(MutableFst<A>* fst, |
469 |
+ MutableFst<A>* sfst = 0, |
470 |
+ float delta = kDelta) { |
471 |
+! uint64 props = fst->Properties(kAcceptor | kWeighted | kUnweighted, true); |
472 |
+ |
473 |
+ if (!(props & kAcceptor)) { // weighted transducer |
474 |
+ VectorFst< GallicArc<A, STRING_LEFT> > gfst; |
475 |
+diff -crB openfst-1.3.4.orig/src/include/fst/partition.h openfst-1.3.4/src/include/fst/partition.h |
476 |
+*** openfst-1.3.4.orig/src/include/fst/partition.h 2013-01-24 06:36:23.000000000 +0400 |
477 |
+--- openfst-1.3.4/src/include/fst/partition.h 2013-11-21 15:59:08.539136087 +0400 |
478 |
+*************** |
479 |
+*** 43,50 **** |
480 |
+ friend class PartitionIterator<T>; |
481 |
+ |
482 |
+ struct Element { |
483 |
+! Element() : value(0), next(0), prev(0) {} |
484 |
+! Element(T v) : value(v), next(0), prev(0) {} |
485 |
+ |
486 |
+ T value; |
487 |
+ Element* next; |
488 |
+--- 43,50 ---- |
489 |
+ friend class PartitionIterator<T>; |
490 |
+ |
491 |
+ struct Element { |
492 |
+! Element() : value(0), next(0), prev(0) {} |
493 |
+! Element(T v) : value(v), next(0), prev(0) {} |
494 |
+ |
495 |
+ T value; |
496 |
+ Element* next; |
497 |
+*************** |
498 |
+*** 52,60 **** |
499 |
+ }; |
500 |
+ |
501 |
+ public: |
502 |
+! Partition() {} |
503 |
+ |
504 |
+! Partition(T num_states) { |
505 |
+ Initialize(num_states); |
506 |
+ } |
507 |
+ |
508 |
+--- 52,62 ---- |
509 |
+ }; |
510 |
+ |
511 |
+ public: |
512 |
+! Partition(bool allow_repeated_split): |
513 |
+! allow_repeated_split_(allow_repeated_split) {} |
514 |
+ |
515 |
+! Partition(bool allow_repeated_split, T num_states): |
516 |
+! allow_repeated_split_(allow_repeated_split) { |
517 |
+ Initialize(num_states); |
518 |
+ } |
519 |
+ |
520 |
+*************** |
521 |
+*** 137,152 **** |
522 |
+ if (class_size_[class_id] == 1) return; |
523 |
+ |
524 |
+ // first time class is split |
525 |
+! if (split_size_[class_id] == 0) |
526 |
+ visited_classes_.push_back(class_id); |
527 |
+! |
528 |
+ // increment size of split (set of element at head of chain) |
529 |
+ split_size_[class_id]++; |
530 |
+! |
531 |
+ // update split point |
532 |
+! if (class_split_[class_id] == 0) |
533 |
+! class_split_[class_id] = classes_[class_id]; |
534 |
+! if (class_split_[class_id] == elements_[element_id]) |
535 |
+ class_split_[class_id] = elements_[element_id]->next; |
536 |
+ |
537 |
+ // move to head of chain in same class |
538 |
+--- 139,154 ---- |
539 |
+ if (class_size_[class_id] == 1) return; |
540 |
+ |
541 |
+ // first time class is split |
542 |
+! if (split_size_[class_id] == 0) { |
543 |
+ visited_classes_.push_back(class_id); |
544 |
+! class_split_[class_id] = classes_[class_id]; |
545 |
+! } |
546 |
+ // increment size of split (set of element at head of chain) |
547 |
+ split_size_[class_id]++; |
548 |
+! |
549 |
+ // update split point |
550 |
+! if (class_split_[class_id] != 0 |
551 |
+! && class_split_[class_id] == elements_[element_id]) |
552 |
+ class_split_[class_id] = elements_[element_id]->next; |
553 |
+ |
554 |
+ // move to head of chain in same class |
555 |
+*************** |
556 |
+*** 157,165 **** |
557 |
+ // class indices of the newly created class. Returns the new_class id |
558 |
+ // or -1 if no new class was created. |
559 |
+ T SplitRefine(T class_id) { |
560 |
+ // only split if necessary |
561 |
+! if (class_size_[class_id] == split_size_[class_id]) { |
562 |
+! class_split_[class_id] = 0; |
563 |
+ split_size_[class_id] = 0; |
564 |
+ return -1; |
565 |
+ } else { |
566 |
+--- 159,169 ---- |
567 |
+ // class indices of the newly created class. Returns the new_class id |
568 |
+ // or -1 if no new class was created. |
569 |
+ T SplitRefine(T class_id) { |
570 |
++ |
571 |
++ Element* split_el = class_split_[class_id]; |
572 |
+ // only split if necessary |
573 |
+! //if (class_size_[class_id] == split_size_[class_id]) { |
574 |
+! if(split_el == NULL) { // we split on everything... |
575 |
+ split_size_[class_id] = 0; |
576 |
+ return -1; |
577 |
+ } else { |
578 |
+*************** |
579 |
+*** 163,180 **** |
580 |
+ split_size_[class_id] = 0; |
581 |
+ return -1; |
582 |
+ } else { |
583 |
+- |
584 |
+ T new_class = AddClass(); |
585 |
+ size_t remainder = class_size_[class_id] - split_size_[class_id]; |
586 |
+ if (remainder < split_size_[class_id]) { // add smaller |
587 |
+- Element* split_el = class_split_[class_id]; |
588 |
+ classes_[new_class] = split_el; |
589 |
+- class_size_[class_id] = split_size_[class_id]; |
590 |
+- class_size_[new_class] = remainder; |
591 |
+ split_el->prev->next = 0; |
592 |
+ split_el->prev = 0; |
593 |
+ } else { |
594 |
+- Element* split_el = class_split_[class_id]; |
595 |
+ classes_[new_class] = classes_[class_id]; |
596 |
+ class_size_[class_id] = remainder; |
597 |
+ class_size_[new_class] = split_size_[class_id]; |
598 |
+--- 167,189 ---- |
599 |
+ split_size_[class_id] = 0; |
600 |
+ return -1; |
601 |
+ } else { |
602 |
+ T new_class = AddClass(); |
603 |
++ |
604 |
++ if(allow_repeated_split_) { // split_size_ is possibly |
605 |
++ // inaccurate, so work it out exactly. |
606 |
++ size_t split_count; Element *e; |
607 |
++ for(split_count=0,e=classes_[class_id]; |
608 |
++ e != split_el; split_count++, e=e->next); |
609 |
++ split_size_[class_id] = split_count; |
610 |
++ } |
611 |
+ size_t remainder = class_size_[class_id] - split_size_[class_id]; |
612 |
+ if (remainder < split_size_[class_id]) { // add smaller |
613 |
+ classes_[new_class] = split_el; |
614 |
+ split_el->prev->next = 0; |
615 |
+ split_el->prev = 0; |
616 |
++ class_size_[class_id] = split_size_[class_id]; |
617 |
++ class_size_[new_class] = remainder; |
618 |
+ } else { |
619 |
+ classes_[new_class] = classes_[class_id]; |
620 |
+ class_size_[class_id] = remainder; |
621 |
+ class_size_[new_class] = split_size_[class_id]; |
622 |
+*************** |
623 |
+*** 245,254 **** |
624 |
+--- 254,269 ---- |
625 |
+ vector<T> class_size_; |
626 |
+ |
627 |
+ // size of split for each class |
628 |
++ // in the nondeterministic case, split_size_ is actually an upper |
629 |
++ // bound on the size of split for each class. |
630 |
+ vector<T> split_size_; |
631 |
+ |
632 |
+ // set of visited classes to be used in split refine |
633 |
+ vector<T> visited_classes_; |
634 |
++ |
635 |
++ // true if input fst was deterministic: we can make |
636 |
++ // certain assumptions in this case that speed up the algorithm. |
637 |
++ bool allow_repeated_split_; |
638 |
+ }; |
639 |
+ |
640 |
+ |
641 |
|
642 |
diff --git a/sci-misc/openfst/openfst-1.3.2.ebuild b/sci-misc/openfst/openfst-1.3.4.ebuild |
643 |
similarity index 88% |
644 |
rename from sci-misc/openfst/openfst-1.3.2.ebuild |
645 |
rename to sci-misc/openfst/openfst-1.3.4.ebuild |
646 |
index 7f92b1c..7a90629 100644 |
647 |
--- a/sci-misc/openfst/openfst-1.3.2.ebuild |
648 |
+++ b/sci-misc/openfst/openfst-1.3.4.ebuild |
649 |
@@ -2,6 +2,8 @@ |
650 |
# Distributed under the terms of the GNU General Public License v2 |
651 |
# $Header: $ |
652 |
|
653 |
+EAPI="5" |
654 |
+ |
655 |
inherit eutils flag-o-matic multilib |
656 |
|
657 |
DESCRIPTION="Finite State Transducer tools by Google et al." |
658 |
@@ -19,6 +21,10 @@ IUSE="" |
659 |
DEPEND="" |
660 |
RDEPEND="${DEPEND}" |
661 |
|
662 |
+src_prepare() { |
663 |
+ epatch "${FILESDIR}/kaldi.patch" || die "patch failed" |
664 |
+} |
665 |
+ |
666 |
src_install() { |
667 |
emake DESTDIR="${D}" install || die "install failed" |
668 |
dodoc AUTHORS NEWS README || die "docs missing" |