An error occurred while loading the file. Please try again.
-
Adam Wardynski authored631c5f87
tset.cpp 1.09 KiB
#include <libwccl/values/tset.h>
#include <libpwrutils/foreach.h>
#include <libpwrutils/bitset.h>
#include <sstream>
namespace Wccl {
const char* TSet::type_name = "TSet";
std::string TSet::to_raw_string() const
{
return tag_.raw_dump();
}
std::string TSet::to_string(const Corpus2::Tagset& tagset) const
{
return "{" + tagset.tag_to_symbol_string(tag_) + "}";
}
std::string TSet::var_repr(const std::string &var_name)
{
std::ostringstream ss;
ss << "$t:" << var_name;
return ss.str();
}
int TSet::categories_count(const Corpus2::Tagset& tagset) const
{
int cats = (tag_.get_pos().any()) ? 1 : 0;
foreach (const Corpus2::mask_t& mask, tagset.all_attribute_masks()) {
if (tag_.get_values_for(mask).any()) {
++cats;
}
}
return cats;
}
int TSet::matching_categories(const Corpus2::Tag& tag) const
{
const Corpus2::Tag& masked = tag_.get_masked(tag);
return PwrNlp::count_bits_set(masked.get_pos()) + PwrNlp::count_bits_set(masked.get_values());
}
void TSet::insert_symbol(const Corpus2::Tagset& tagset, const std::string& s)
{
tag_.combine_with(tagset.parse_symbol(s));
}
} /* end ns Wccl */