diff options
author | Slávek Banko <[email protected]> | 2021-11-05 13:28:23 +0100 |
---|---|---|
committer | Slávek Banko <[email protected]> | 2021-11-05 13:28:23 +0100 |
commit | 8c787c3591c1c885b91a54128835b400858c5cca (patch) | |
tree | eca1b776912a305c4d45b3964038278a2fae1ead /debian/htdig/htdig-3.2.0b6/htsearch/OrFuzzyExpander.cc | |
parent | fe188b907cdf30dfdfe0eba9412e7f8749fec158 (diff) | |
download | extra-dependencies-8c787c3591c1c885b91a54128835b400858c5cca.tar.gz extra-dependencies-8c787c3591c1c885b91a54128835b400858c5cca.zip |
DEB htdig: Added to repository.
Signed-off-by: Slávek Banko <[email protected]>
Diffstat (limited to 'debian/htdig/htdig-3.2.0b6/htsearch/OrFuzzyExpander.cc')
-rw-r--r-- | debian/htdig/htdig-3.2.0b6/htsearch/OrFuzzyExpander.cc | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/debian/htdig/htdig-3.2.0b6/htsearch/OrFuzzyExpander.cc b/debian/htdig/htdig-3.2.0b6/htsearch/OrFuzzyExpander.cc new file mode 100644 index 00000000..d288496d --- /dev/null +++ b/debian/htdig/htdig-3.2.0b6/htsearch/OrFuzzyExpander.cc @@ -0,0 +1,94 @@ +// +// OrFuzzyExpander.cc +// +// OrFuzzyExpander: a concrete Fuzzy expander that makes a OR with +// all the results returned by the applicable Fuzzies. +// +// Part of the ht://Dig package <http://www.htdig.org/> +// Copyright (c) 1995-2004 The ht://Dig Group +// For copyright details, see the file COPYING in your distribution +// or the GNU Library General Public License (LGPL) version 2 or later +// <http://www.gnu.org/copyleft/lgpl.html> +// +// $Id: OrFuzzyExpander.cc,v 1.4 2004/05/28 13:15:24 lha Exp $ +// + +#include "OrFuzzyExpander.h" +#include "Dictionary.h" +#include "ExactWordQuery.h" +#include "OrQuery.h" + +extern int debug; + +// +// creates a query with a OrQuery with all the +// distinct fuzzy results +// +// additionally, sets fuzzy scores for used words +// +Query * +OrFuzzyExpander::MakeQuery(const String &word) +{ + Query *result = 0; + Dictionary exacts; + + // for each configured fuzzy + filters.Start_Get(); + Fuzzy *fuzzy = (Fuzzy *)filters.Get_Next(); + while(fuzzy) + { + // for each word expanded by fuzzy + List words; + String nonconst = word; + fuzzy->getWords(nonconst, words); + words.Start_Get(); + String *w = (String *)words.Get_Next(); + while(w) + { + // if not yet expanded by another fuzzy + // add it to the big Or + if(debug) cerr << "fuzzy " << word << "=" << *w << endl; + ExactWordQuery *exact = (ExactWordQuery *)exacts[*w]; + if(!exact) + { + exact = new ExactWordQuery(*w); + exact->SetWeight(fuzzy->getWeight()); + exacts.Add(*w, exact); + } + // otherwise, just adjust the weight + else + { + exact->SetWeight( + exact->GetWeight() + + fuzzy->getWeight()); + } + w = (String *)words.Get_Next(); + } + fuzzy = (Fuzzy *)filters.Get_Next(); + } + + // return the expanded query + // a single word or + // a Or with all the expanded words + exacts.Start_Get(); + Query *exact = (Query *)exacts.Get_NextElement(); + if(exact) + { + result = exact; + exact = (Query *)exacts.Get_NextElement(); + } + if(exact) + { + Query *tmp = result; + result = new OrQuery; + result->Add(tmp); + while(exact) + { + result->Add(exact); + exact = (Query *)exacts.Get_NextElement(); + } + } + exacts.Release(); + + return result; +} |