00001 #include "TokenizedRuleHalf.h" 00002 00003 namespace MosesTraining 00004 { 00005 namespace Syntax 00006 { 00007 namespace ScoreStsg 00008 { 00009 00010 bool TokenizedRuleHalf::IsFullyLexical() const 00011 { 00012 for (std::vector<RuleSymbol>::const_iterator p = frontierSymbols.begin(); 00013 p != frontierSymbols.end(); ++p) { 00014 if (p->isNonTerminal) { 00015 return false; 00016 } 00017 } 00018 return true; 00019 } 00020 00021 bool TokenizedRuleHalf::IsString() const 00022 { 00023 // A rule half is either a string (like "[X] and [X]") or a tree (like 00024 // "[NP [NP] [CC and] [NP]]"). 00025 // 00026 // A string must start with a terminal or a non-terminal (in square brackets). 00027 // A tree must start with '[' followed by a word then either another word or 00028 // another '['. 00029 return (tokens[0].type == TreeFragmentToken_WORD || 00030 tokens[2].type == TreeFragmentToken_RSB); 00031 } 00032 00033 bool TokenizedRuleHalf::IsTree() const 00034 { 00035 return !IsString(); 00036 } 00037 00038 } // namespace ScoreStsg 00039 } // namespace Syntax 00040 } // namespace MosesTraining