00001 // -*- mode: c++; indent-tabs-mode: nil; tab-width:2 -*- 00002 // (c) 2007-2012 Ulrich Germann 00003 // Token class for dependency trees, where the linear order 00004 // of tokens is defined as going up a dependency chain 00005 #pragma once 00006 00007 #include "ug_typedefs.h" 00008 namespace sapt 00009 { 00010 00011 template<typename T> 00012 class ConllBottomUpToken : public T 00013 { 00014 public: 00015 typedef T Token; 00016 ConllBottomUpToken() : T() {}; 00017 ConllBottomUpToken(id_type id) : T(id) {}; 00018 00019 ConllBottomUpToken const* next(int length=1) const; 00020 00021 template<typename TTRACK_TYPE> 00022 ConllBottomUpToken const* stop(TTRACK_TYPE const& C, id_type sid) const 00023 { 00024 return NULL; 00025 }; 00026 00027 ConllBottomUpToken const* 00028 stop(ConllBottomUpToken const* seqStart, 00029 ConllBottomUpToken const* seqEnd) const 00030 { 00031 return NULL; 00032 }; 00033 00034 bool operator<(T const& other) const { return this->cmp(other) < 0; } 00035 bool operator>(T const& other) const { return this->cmp(other) > 0; } 00036 bool operator==(T const& other) const { return this->cmp(other) == 0; } 00037 bool operator!=(T const& other) const { return this->cmp(other) != 0; } 00038 00039 bool reachable(T const* o) 00040 { 00041 for (T const* x = this; x; x = reinterpret_cast<T const*>(x->up())) 00042 if (x == o) return true; 00043 return false; 00044 } 00045 }; 00046 00047 template<typename T> 00048 ConllBottomUpToken<T> const* 00049 ConllBottomUpToken<T>:: 00050 next(int length) const 00051 { 00052 return reinterpret_cast<ConllBottomUpToken<T> const*>(this->up(length)); 00053 } 00054 00055 } // end of namespace ugdiss 00056