Skip to content
Snippets Groups Projects
Commit e7250075 authored by ilor's avatar ilor
Browse files

add Tagset get_pos_index(mask_t) and get_pos_name(mask_t pos)

parent 69dda1b7
No related merge requests found
......@@ -420,6 +420,11 @@ const std::string& Tagset::get_pos_name(idx_t pos) const
return pos_dict_.get_string(pos);
}
const std::string& Tagset::get_pos_name(mask_t pos) const
{
return pos_dict_.get_string(get_pos_index(pos));
}
mask_t Tagset::get_pos_mask(const string_range& pos) const
{
return get_pos_mask(get_pos_index(pos));
......@@ -434,6 +439,15 @@ mask_t Tagset::get_pos_mask(idx_t pos) const
}
}
idx_t Tagset::get_pos_index(mask_t pos) const
{
if (pos.none()) {
return -1;
} else {
return PwrNlp::lowest_bit(pos);
}
}
idx_t Tagset::get_attribute_index(const string_range& a) const
{
return attribute_dict_.get_id(a);
......
......@@ -266,7 +266,6 @@ public:
return attribute_dict_;
}
/// POS name -> index mapping
/// @returns -1 on invalid name
idx_t get_pos_index(const string_range& pos) const;
......@@ -275,6 +274,10 @@ public:
/// @returns empty string on invalid index
const std::string& get_pos_name(idx_t pos) const;
/// POS mask -> name
/// @returns empty string on invalid index
const std::string& get_pos_name(mask_t pos) const;
/// POS name -> mask mapping
/// @return null mask on invalid name
mask_t get_pos_mask(const string_range& pos) const;
......@@ -283,6 +286,10 @@ public:
/// @return null mask on invalid index
mask_t get_pos_mask(idx_t pos) const;
/// POS mask -> index mapping
/// @return -1 on empty mask, unspecified in more tha one POS set
idx_t get_pos_index(mask_t pos) const;
/// Attribute name -> index mapping
/// @returns -1 on invalid name
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment