Home | History | Annotate | Download | only in fst

Lines Matching defs:StringWeight

51 class StringWeight;
60 bool operator==(const StringWeight<L, S> &, const StringWeight<L, S> &);
65 class StringWeight {
68 typedef StringWeight<L, REVERSE_STRING_TYPE(S)> ReverseWeight;
72 friend bool operator==<>(const StringWeight<L, S> &,
73 const StringWeight<L, S> &);
75 StringWeight() { Init(); }
78 StringWeight(const Iter &begin, const Iter &end) {
84 explicit StringWeight(L l) { Init(); PushBack(l); }
86 static const StringWeight<L, S> &Zero() {
87 static const StringWeight<L, S> zero(kStringInfinity);
91 static const StringWeight<L, S> &One() {
92 static const StringWeight<L, S> one;
96 static const StringWeight<L, S> &NoWeight() {
97 static const StringWeight<L, S> no_weight(kStringBad);
118 StringWeight<L, S> Quantize(float delta = kDelta) const {
130 // StringWeight<L, S> &operator=(const StringWeight<L, S> &w);
139 // Clear existing StringWeight.
167 explicit StringWeightIterator(const StringWeight<L, S>& w)
202 explicit StringWeightReverseIterator(const StringWeight<L, S>& w)
230 // StringWeight member functions follow that require
234 inline istream &StringWeight<L, S>::Read(istream &strm) {
247 inline ostream &StringWeight<L, S>::Write(ostream &strm) const {
258 inline bool StringWeight<L, S>::Member() const {
266 inline typename StringWeight<L, S>::ReverseWeight
267 StringWeight<L, S>::Reverse() const {
275 inline size_t StringWeight<L, S>::Hash() const {
285 // inline StringWeight<L, S>
286 // &StringWeight<L, S>::operator=(const StringWeight<L, S> &w) {
296 inline bool operator==(const StringWeight<L, S> &w1,
297 const StringWeight<L, S> &w2) {
312 inline bool operator!=(const StringWeight<L, S> &w1,
313 const StringWeight<L, S> &w2) {
318 inline bool ApproxEqual(const StringWeight<L, S> &w1,
319 const StringWeight<L, S> &w2,
325 inline ostream &operator<<(ostream &strm, const StringWeight<L, S> &w) {
343 inline istream &operator>>(istream &strm, StringWeight<L, S> &w) {
347 w = StringWeight<L, S>::Zero();
349 w = StringWeight<L, S>::One();
369 template <typename L, StringType S> inline StringWeight<L, S>
370 Plus(const StringWeight<L, S> &w1,
371 const StringWeight<L, S> &w2) {
373 return StringWeight<L, S>::NoWeight();
374 if (w1 == StringWeight<L, S>::Zero())
376 if (w2 == StringWeight<L, S>::Zero())
380 FSTERROR() << "StringWeight::Plus: unequal arguments "
384 return StringWeight<L, S>::NoWeight();
392 template <typename L> inline StringWeight<L, STRING_LEFT>
393 Plus(const StringWeight<L, STRING_LEFT> &w1,
394 const StringWeight<L, STRING_LEFT> &w2) {
396 return StringWeight<L, STRING_LEFT>::NoWeight();
397 if (w1 == StringWeight<L, STRING_LEFT>::Zero())
399 if (w2 == StringWeight<L, STRING_LEFT>::Zero())
402 StringWeight<L, STRING_LEFT> sum;
413 template <typename L> inline StringWeight<L, STRING_RIGHT>
414 Plus(const StringWeight<L, STRING_RIGHT> &w1,
415 const StringWeight<L, STRING_RIGHT> &w2) {
417 return StringWeight<L, STRING_RIGHT>::NoWeight();
418 if (w1 == StringWeight<L, STRING_RIGHT>::Zero())
420 if (w2 == StringWeight<L, STRING_RIGHT>::Zero())
423 StringWeight<L, STRING_RIGHT> sum;
434 inline StringWeight<L, S> Times(const StringWeight<L, S> &w1,
435 const StringWeight<L, S> &w2) {
437 return StringWeight<L, S>::NoWeight();
438 if (w1 == StringWeight<L, S>::Zero() || w2 == StringWeight<L, S>::Zero())
439 return StringWeight<L, S>::Zero();
441 StringWeight<L, S> prod(w1);
451 template <typename L, StringType S> inline StringWeight<L, S>
452 Divide(const StringWeight<L, S> &w1,
453 const StringWeight<L, S> &w2,
457 FSTERROR() << "StringWeight::Divide: only left division is defined "
458 << "for the " << StringWeight<L, S>::Type() << " semiring";
459 return StringWeight<L, S>::NoWeight();
463 return StringWeight<L, S>::NoWeight();
465 if (w2 == StringWeight<L, S>::Zero())
466 return StringWeight<L, S>(kStringBad);
467 else if (w1 == StringWeight<L, S>::Zero())
468 return StringWeight<L, S>::Zero();
470 StringWeight<L, S> div;
481 template <typename L> inline StringWeight<L, STRING_RIGHT>
482 Divide(const StringWeight<L, STRING_RIGHT> &w1,
483 const StringWeight<L, STRING_RIGHT> &w2,
487 FSTERROR() << "StringWeight::Divide: only right division is defined "
489 return StringWeight<L, STRING_RIGHT>::NoWeight();
493 return StringWeight<L, STRING_RIGHT>::NoWeight();
495 if (w2 == StringWeight<L, STRING_RIGHT>::Zero())
496 return StringWeight<L, STRING_RIGHT>(kStringBad);
497 else if (w1 == StringWeight<L, STRING_RIGHT>::Zero())
498 return StringWeight<L, STRING_RIGHT>::Zero();
500 StringWeight<L, STRING_RIGHT> div;
511 template <typename L> inline StringWeight<L, STRING_RIGHT_RESTRICT>
512 Divide(const StringWeight<L, STRING_RIGHT_RESTRICT> &w1,
513 const StringWeight<L, STRING_RIGHT_RESTRICT> &w2,
517 FSTERROR() << "StringWeight::Divide: only right division is defined "
519 return StringWeight<L, STRING_RIGHT_RESTRICT>::NoWeight();
523 return StringWeight<L, STRING_RIGHT_RESTRICT>::NoWeight();
525 if (w2 == StringWeight<L, STRING_RIGHT_RESTRICT>::Zero())
526 return StringWeight<L, STRING_RIGHT_RESTRICT>(kStringBad);
527 else if (w1 == StringWeight<L, STRING_RIGHT_RESTRICT>::Zero())
528 return StringWeight<L, STRING_RIGHT_RESTRICT>::Zero();
530 StringWeight<L, STRING_RIGHT_RESTRICT> div;
542 struct GallicWeight : public ProductWeight<StringWeight<L, S>, W> {
548 GallicWeight(StringWeight<L, S> w1, W w2)
549 : ProductWeight<StringWeight<L, S>, W>(w1, w2) {}
552 : ProductWeight<StringWeight<L, S>, W>(s, nread) {}
554 GallicWeight(const ProductWeight<StringWeight<L, S>, W> &w)
555 : ProductWeight<StringWeight<L, S>, W>(w) {}