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

Fix disamb ordering in Lexeme op<

add disamb-ignoring equality
use both of these in Token's remove duplicate lexemes to mEdukacjaWeb/bilanse.do?event=switchBilanse&bilanse=prognozowaneake disamb take priority in case of a disamb/ndisamb dupe
parent 857b81fb
Branches
No related merge requests found
......@@ -28,7 +28,7 @@ bool Lexeme::operator<(const Lexeme& other) const
|| (lemma_ == other.lemma_
&& (tag_ < other.tag_
|| (tag_ == other.tag_
&& disamb_ < other.disamb_)));
&& disamb_ && !other.disamb_)));
}
bool Lexeme::operator==(const Lexeme& other) const
......@@ -37,4 +37,9 @@ bool Lexeme::operator==(const Lexeme& other) const
disamb_ == other.disamb_;
}
bool Lexeme::DisamblessComparator::operator()(const Lexeme& l, const Lexeme& other) const
{
return l.lemma_ == other.lemma_ && l.tag_ == other.tag_;
}
} /* end ns Corpus2 */
......@@ -88,6 +88,14 @@ public:
*/
bool operator==(const Lexeme& other) const;
/**
* Disamb-ignoring lexeme comparison
*/
struct DisamblessComparator
{
bool operator()(const Lexeme& l1, const Lexeme& l2) const;
};
private:
/// The lemma -- basic form
//boost::flyweight<UnicodeString> lemma_;
......
......@@ -84,7 +84,7 @@ bool Token::remove_duplicate_lexemes()
{
size_t old_size = lexemes_.size();
std::sort(lexemes_.begin(), lexemes_.end());
lexemes_.erase(std::unique(lexemes_.begin(), lexemes_.end()),
lexemes_.erase(std::unique(lexemes_.begin(), lexemes_.end(), Lexeme::DisamblessComparator()),
lexemes_.end());
return old_size != lexemes_.size();
}
......
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