Skip to content
Snippets Groups Projects
Commit fa524598 authored by Adam Wardyński's avatar Adam Wardyński
Browse files

Adding some methods to values for use by operators, e.g. equals and...

Adding some methods to values for use by operators, e.g. equals and is_subset_of/intersection. Some are just stubs.
parent f0a461c1
Branches
No related merge requests found
......@@ -23,6 +23,10 @@ public:
val_ = v;
}
bool equals(const Bool& other) {
return val_ == other.val_;
}
/// Value override
std::string to_raw_string() const {
return val_ ? "true" : "false";
......
......@@ -32,6 +32,10 @@ public:
/// Value override
std::string to_raw_string() const;
bool equals(const Position& other) {
return val_ == other.val_;
}
private:
int val_;
};
......
......@@ -37,6 +37,29 @@ public:
offset_ = offset;
}
/**
* Returns true if underlying Position is Nowhere,
* or underlying Position is Begin and offset is less than zero,
* or underlying Position is End and offset is greater than zero.
* False otherwise.
* This function does not take into account any actual sentence
* boundaries.
*/
bool points_nowhere() const {
//We probably could allow null dereference (shouldn't logically
//happen so if it does, it's bad) but let's be defensive
//and assume null base is like nowhere.
return (base_.get() == NULL) ||
(base_->get_value() == Position::Nowhere) ||
(base_->get_value() == Position::Begin && offset_ < 0) ||
(base_->get_value() == Position::End && offset_ > 0);
}
bool equals(const PositionRef& other) {
return points_nowhere() ? other.points_nowhere()
: offset_ == other.offset_ && base_->equals(*other.base_);
}
private:
boost::shared_ptr<Position> base_;
......
......@@ -52,6 +52,25 @@ public:
return set_.size();
}
bool empty() const {
return set_.empty();
}
bool is_subset_of(const StrSet& /*set*/) const {
//TODO: implement this
return false;
}
StrSet intersect(const StrSet& /*set*/) const {
//TODO: implement this
return StrSet(set_t());
}
bool equals(const StrSet& /*set*/) const {
//TODO: implement this
return false;
}
/// Value override
std::string to_raw_string() const;
......
......@@ -33,6 +33,25 @@ public:
return tag_;
}
bool empty() const {
return tag_.is_null();
}
bool is_subset_of(const TSet& /*tset*/) const {
//TODO: implement this
return false;
}
TSet intersect(const TSet& /*tset*/) const {
//TODO: implement this
return TSet();
}
bool equals(const TSet& /*tset*/) const {
//TODO: implement this
return false;
}
std::string to_string(const Corpus2::Tagset &) const;
std::string to_raw_string() const;
......
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