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
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,7 @@ bool Lexeme::operator<(const Lexeme& other) const ...@@ -28,7 +28,7 @@ bool Lexeme::operator<(const Lexeme& other) const
|| (lemma_ == other.lemma_ || (lemma_ == other.lemma_
&& (tag_ < other.tag_ && (tag_ < other.tag_
|| (tag_ == other.tag_ || (tag_ == other.tag_
&& disamb_ < other.disamb_))); && disamb_ && !other.disamb_)));
} }
bool Lexeme::operator==(const Lexeme& other) const bool Lexeme::operator==(const Lexeme& other) const
...@@ -37,4 +37,9 @@ bool Lexeme::operator==(const Lexeme& other) const ...@@ -37,4 +37,9 @@ bool Lexeme::operator==(const Lexeme& other) const
disamb_ == other.disamb_; 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 */ } /* end ns Corpus2 */
...@@ -88,6 +88,14 @@ public: ...@@ -88,6 +88,14 @@ public:
*/ */
bool operator==(const Lexeme& other) const; bool operator==(const Lexeme& other) const;
/**
* Disamb-ignoring lexeme comparison
*/
struct DisamblessComparator
{
bool operator()(const Lexeme& l1, const Lexeme& l2) const;
};
private: private:
/// The lemma -- basic form /// The lemma -- basic form
//boost::flyweight<UnicodeString> lemma_; //boost::flyweight<UnicodeString> lemma_;
......
...@@ -84,7 +84,7 @@ bool Token::remove_duplicate_lexemes() ...@@ -84,7 +84,7 @@ bool Token::remove_duplicate_lexemes()
{ {
size_t old_size = lexemes_.size(); size_t old_size = lexemes_.size();
std::sort(lexemes_.begin(), lexemes_.end()); 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()); lexemes_.end());
return old_size != lexemes_.size(); return old_size != lexemes_.size();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment