Cambridge SMT System
|
Structure for sentence-specific grammar Rules will be queried by cyk per position and number of elements in the right-hand-side (source) of the rule Therefore indices are stored in this fashion so queries can be done directly. Note: a more efficient implementation could be to store these rule indices in a structure much closer even to the cyk grid. For instance, if an instanced pattern has never been seen below span 5, there is no need for the cyk to query and reject it. More...
#include <data.ssgrammar.hpp>
Public Member Functions | |
SentenceSpecificGrammarData () | |
void | reset () |
const std::string | getRule (std::size_t idx) |
Returns rule corresponding to index idx. More... | |
const std::string | getLHS (std::size_t idx) |
Returns Left-hand-side of a rule corresponding to index idx. More... | |
const std::string | getRHSSource (std::size_t idx) |
Returns Right-hand-side (source) of the rule with index=idx. More... | |
const std::string | getRHSSource (std::size_t idx, uint rulepos) |
Returns element at position rulepos of right-hand-side (source) More... | |
const std::vector< std::string > | getRHSSplitSource (std::size_t idx) |
Returns vector of elements of the RHS source. More... | |
const uint | getRHSSourceSize (std::size_t idx) |
Returns size of RHS source of a rule. More... | |
const std::string | getRHSTranslation (std::size_t idx) |
Returns RHS translation of a rule with index idx. More... | |
const std::vector< std::string > | getRHSSplitTranslation (std::size_t idx) |
Returns translation as a vector of elements. More... | |
const uint | getRHSTranslationSize (std::size_t idx) |
Returns size of RHS (translation) of a rule. More... | |
const float | getWeight (std::size_t idx) |
Returns the weight of a rule. This weight is the dot product of all the features with its scales. More... | |
void | getLinks (std::size_t idx, std::vector< unsigned > &links) const |
const bool | isPhrase (std::size_t idx) |
const std::size_t | getIdx (std::size_t idx) |
Returns the true idx of a rule (i.e. line in the grammar file). If it is sentence specific, then return the idx itself. More... | |
const bool | isAcceptedByVocabulary (const std::size_t idx, const unordered_set< std::string > &vcb) |
void | getMappings (std::size_t idx, unordered_map< uint, uint > *mappings) |
Returns the non-terminal mappings for a rule. For more details see getRuleMappings function. More... | |
Public Attributes | |
const GrammarData * | grammar |
Pointer to the original grammar data (no ownership) More... | |
ssgrammar_rulesmap_t | rulesWithRhsSpan1 |
ssgrammar_rulesmap_t | rulesWithRhsSpan2OrMore |
cells containing potentially applicable rules with two or more elements More... | |
unordered_map< std::size_t, std::string > | extrarules |
Structure for sentence-specific grammar Rules will be queried by cyk per position and number of elements in the right-hand-side (source) of the rule Therefore indices are stored in this fashion so queries can be done directly. Note: a more efficient implementation could be to store these rule indices in a structure much closer even to the cyk grid. For instance, if an instanced pattern has never been seen below span 5, there is no need for the cyk to query and reject it.
Definition at line 38 of file data.ssgrammar.hpp.
|
inline |
Definition at line 40 of file data.ssgrammar.hpp.
|
inline |
Returns the true idx of a rule (i.e. line in the grammar file). If it is sentence specific, then return the idx itself.
Definition at line 200 of file data.ssgrammar.hpp.
|
inline |
Returns Left-hand-side of a rule corresponding to index idx.
Definition at line 74 of file data.ssgrammar.hpp.
|
inline |
Definition at line 167 of file data.ssgrammar.hpp.
|
inline |
Returns the non-terminal mappings for a rule. For more details see getRuleMappings function.
idx | rule (sorted) identifier. |
mappings | Source to target non-terminal mapping information |
Definition at line 220 of file data.ssgrammar.hpp.
|
inline |
Returns Right-hand-side (source) of the rule with index=idx.
Definition at line 82 of file data.ssgrammar.hpp.
|
inline |
Returns element at position rulepos of right-hand-side (source)
Definition at line 91 of file data.ssgrammar.hpp.
|
inline |
Returns size of RHS source of a rule.
Definition at line 116 of file data.ssgrammar.hpp.
|
inline |
Returns vector of elements of the RHS source.
Definition at line 106 of file data.ssgrammar.hpp.
|
inline |
Returns translation as a vector of elements.
Definition at line 135 of file data.ssgrammar.hpp.
|
inline |
Returns RHS translation of a rule with index idx.
Definition at line 125 of file data.ssgrammar.hpp.
|
inline |
Returns size of RHS (translation) of a rule.
Definition at line 146 of file data.ssgrammar.hpp.
|
inline |
Returns rule corresponding to index idx.
Definition at line 66 of file data.ssgrammar.hpp.
|
inline |
Returns the weight of a rule. This weight is the dot product of all the features with its scales.
Definition at line 156 of file data.ssgrammar.hpp.
|
inline |
Determines whether a rule is allowed within the vocabulary. If the rule is sentence-specific (i.e. created due to oov or feedback,etc) this method will always return true.
Definition at line 208 of file data.ssgrammar.hpp.
|
inline |
Definition at line 189 of file data.ssgrammar.hpp.
|
inline |
unordered_map<std::size_t, std::string> ucam::hifst::SentenceSpecificGrammarData::extrarules |
Extra rules, e.g. due to oovs, feedback, etc. Indexed by a rule id that must be bigger than the number of rules of the whole grammar Note that this hash is not expected to contain many rules. If so, access speed will degrade.
Definition at line 55 of file data.ssgrammar.hpp.
const GrammarData* ucam::hifst::SentenceSpecificGrammarData::grammar |
Pointer to the original grammar data (no ownership)
Definition at line 45 of file data.ssgrammar.hpp.
ssgrammar_rulesmap_t ucam::hifst::SentenceSpecificGrammarData::rulesWithRhsSpan1 |
Sentence-specific data. cells containing potentially applicable rules with one element
Definition at line 49 of file data.ssgrammar.hpp.
ssgrammar_rulesmap_t ucam::hifst::SentenceSpecificGrammarData::rulesWithRhsSpan2OrMore |
cells containing potentially applicable rules with two or more elements
Definition at line 51 of file data.ssgrammar.hpp.