00001 /* 00002 * Word.h 00003 * 00004 * Created on: 18 Feb 2014 00005 * Author: s0565741 00006 */ 00007 #pragma once 00008 00009 #include <string> 00010 #include <set> 00011 #include "RuleSymbol.h" 00012 00013 // a terminal 00014 class Word : public RuleSymbol 00015 { 00016 public: 00017 Word(const Word&); // do not implement 00018 Word(int pos, const std::string &str); 00019 virtual ~Word(); 00020 00021 virtual bool IsNonTerm() const { 00022 return false; 00023 } 00024 00025 std::string GetString() const { 00026 return m_str; 00027 } 00028 00029 std::string GetString(int factor) const; 00030 00031 int GetPos() const { 00032 return m_pos; 00033 } 00034 00035 void AddAlignment(const Word *other); 00036 00037 const std::set<const Word *> &GetAlignment() const { 00038 return m_alignment; 00039 } 00040 00041 std::set<int> GetAlignmentIndex() const; 00042 00043 void Output(std::ostream &out) const; 00044 std::string Debug() const; 00045 00046 int CompareString(const Word &other) const; 00047 00048 protected: 00049 int m_pos; // original position in sentence, NOT in lattice 00050 std::string m_str; 00051 std::set<const Word *> m_alignment; 00052 }; 00053