Home | History | Annotate | Download | only in lib

Lines Matching refs:StringWeight

48 class StringWeight;
57 bool operator==(const StringWeight<L, S> &, const StringWeight<L, S> &);
62 class StringWeight {
65 typedef StringWeight<L, REVERSE_STRING_TYPE(S)> ReverseWeight;
69 friend bool operator==<>(const StringWeight<L, S> &,
70 const StringWeight<L, S> &);
72 StringWeight() { Init(); }
75 StringWeight(const Iter &begin, const Iter &end) {
81 explicit StringWeight(L l) { Init(); PushBack(l); }
83 static const StringWeight<L, S> &Zero() {
84 static const StringWeight<L, S> zero(kStringInfinity);
88 static const StringWeight<L, S> &One() {
89 static const StringWeight<L, S> one;
110 StringWeight<L, S> Quantize(float delta = kDelta) const {
122 // StringWeight<L, S> &operator=(const StringWeight<L, S> &w);
131 // Clear existing StringWeight.
159 explicit StringWeightIterator(const StringWeight<L, S>& w)
194 explicit StringWeightReverseIterator(const StringWeight<L, S>& w)
222 // StringWeight member functions follow that require
226 inline istream &StringWeight<L, S>::Read(istream &strm) {
239 inline ostream &StringWeight<L, S>::Write(ostream &strm) const {
250 inline bool StringWeight<L, S>::Member() const {
258 inline typename StringWeight<L, S>::ReverseWeight
259 StringWeight<L, S>::Reverse() const {
267 inline ssize_t StringWeight<L, S>::Hash() const {
277 // inline StringWeight<L, S>
278 // &StringWeight<L, S>::operator=(const StringWeight<L, S> &w) {
288 inline bool operator==(const StringWeight<L, S> &w1,
289 const StringWeight<L, S> &w2) {
304 inline bool operator!=(const StringWeight<L, S> &w1,
305 const StringWeight<L, S> &w2) {
310 inline bool ApproxEqual(const StringWeight<L, S> &w1,
311 const StringWeight<L, S> &w2,
317 inline ostream &operator<<(ostream &strm, const StringWeight<L, S> &w) {
335 inline istream &operator>>(istream &strm, StringWeight<L, S> &w) {
339 w = StringWeight<L, S>::Zero();
341 w = StringWeight<L, S>::One();
361 template <typename L, StringType S> inline StringWeight<L, S>
362 Plus(const StringWeight<L, S> &w1,
363 const StringWeight<L, S> &w2) {
364 if (w1 == StringWeight<L, S>::Zero())
366 if (w2 == StringWeight<L, S>::Zero())
370 LOG(FATAL) << "StringWeight::Plus: unequal arguments "
378 template <typename L> inline StringWeight<L, STRING_LEFT>
379 Plus(const StringWeight<L, STRING_LEFT> &w1,
380 const StringWeight<L, STRING_LEFT> &w2) {
381 if (w1 == StringWeight<L, STRING_LEFT>::Zero())
383 if (w2 == StringWeight<L, STRING_LEFT>::Zero())
386 StringWeight<L, STRING_LEFT> sum;
397 template <typename L> inline StringWeight<L, STRING_RIGHT>
398 Plus(const StringWeight<L, STRING_RIGHT> &w1,
399 const StringWeight<L, STRING_RIGHT> &w2) {
400 if (w1 == StringWeight<L, STRING_RIGHT>::Zero())
402 if (w2 == StringWeight<L, STRING_RIGHT>::Zero())
405 StringWeight<L, STRING_RIGHT> sum;
416 inline StringWeight<L, S> Times(const StringWeight<L, S> &w1,
417 const StringWeight<L, S> &w2) {
418 if (w1 == StringWeight<L, S>::Zero() || w2 == StringWeight<L, S>::Zero())
419 return StringWeight<L, S>::Zero();
421 StringWeight<L, S> prod(w1);
431 template <typename L, StringType S> inline StringWeight<L, S>
432 Divide(const StringWeight<L, S> &w1,
433 const StringWeight<L, S> &w2,
437 LOG(FATAL) << "StringWeight::Divide: only left division is defined "
438 << "for the " << StringWeight<L, S>::Type() << " semiring";
440 if (w2 == StringWeight<L, S>::Zero())
441 return StringWeight<L, S>(kStringBad);
442 else if (w1 == StringWeight<L, S>::Zero())
443 return StringWeight<L, S>::Zero();
445 StringWeight<L, S> div;
456 template <typename L> inline StringWeight<L, STRING_RIGHT>
457 Divide(const StringWeight<L, STRING_RIGHT> &w1,
458 const StringWeight<L, STRING_RIGHT> &w2,
462 LOG(FATAL) << "StringWeight::Divide: only right division is defined "
465 if (w2 == StringWeight<L, STRING_RIGHT>::Zero())
466 return StringWeight<L, STRING_RIGHT>(kStringBad);
467 else if (w1 == StringWeight<L, STRING_RIGHT>::Zero())
468 return StringWeight<L, STRING_RIGHT>::Zero();
470 StringWeight<L, STRING_RIGHT> div;
481 template <typename L> inline StringWeight<L, STRING_RIGHT_RESTRICT>
482 Divide(const StringWeight<L, STRING_RIGHT_RESTRICT> &w1,
483 const StringWeight<L, STRING_RIGHT_RESTRICT> &w2,
487 LOG(FATAL) << "StringWeight::Divide: only right division is defined "
490 if (w2 == StringWeight<L, STRING_RIGHT_RESTRICT>::Zero())
491 return StringWeight<L, STRING_RIGHT_RESTRICT>(kStringBad);
492 else if (w1 == StringWeight<L, STRING_RIGHT_RESTRICT>::Zero())
493 return StringWeight<L, STRING_RIGHT_RESTRICT>::Zero();
495 StringWeight<L, STRING_RIGHT_RESTRICT> div;
507 struct GallicWeight : public ProductWeight<StringWeight<L, S>, W> {
513 GallicWeight(StringWeight<L, S> w1, W w2)
514 : ProductWeight<StringWeight<L, S>, W>(w1, w2) {}
517 : ProductWeight<StringWeight<L, S>, W>(s, nread) {}
519 GallicWeight(const ProductWeight<StringWeight<L, S>, W> &w)
520 : ProductWeight<StringWeight<L, S>, W>(w) {}