diff options
| author | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-06 22:06:22 +0000 | 
|---|---|---|
| committer | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-06 22:06:22 +0000 | 
| commit | 9f2f8c40c1e074ba08119dfb9ed55f278d6a51f2 (patch) | |
| tree | 915a3f12331278bb2393877895c8466ebd6d9c2a /decoder/inside_outside.h | |
| parent | 3467f7ba69aae03e6552862b3cb3676d5f1ef2fd (diff) | |
Boolean semiring
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@166 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/inside_outside.h')
| -rw-r--r-- | decoder/inside_outside.h | 17 | 
1 files changed, 17 insertions, 0 deletions
diff --git a/decoder/inside_outside.h b/decoder/inside_outside.h index 3c7518f2..9f7ce526 100644 --- a/decoder/inside_outside.h +++ b/decoder/inside_outside.h @@ -5,6 +5,23 @@  #include <algorithm>  #include "hg.h" +// semiring for Inside/Outside +struct Boolean { +  bool x; +  Boolean() : x() {  } +  Boolean(bool i) : x(i) {  } +  operator bool() const { return x; } +  // normally you'd use the logical (short circuit) || &&  operators, but bool really is guaranteed to be 0 or 1 numerically. +  void operator+=(Boolean o) { x|=o.x; } +  friend inline Boolean operator +(Boolean a,Boolean b) { +    return Boolean(a.x|b.x); +  } +  void operator*=(Boolean o) { x&=o.x; } +  friend inline Boolean operator *(Boolean a,Boolean b) { +    return Boolean(a.x&b.x); +  } +}; +  // run the inside algorithm and return the inside score  // if result is non-NULL, result will contain the inside  // score for each node  | 
