Reimplement Language Modelling weights
[xapian.git] / xapian-core / weight / coordweight.cc
blobf0d1abec4c0b9f950b28622f2974fe1496505fcd
1 /** @file
2 * @brief Xapian::CoordWeight class - coordinate matching
3 */
4 /* Copyright (C) 2004,2009,2011,2016 Olly Betts
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <config.h>
23 #include "xapian/weight.h"
25 #include "xapian/error.h"
27 using namespace std;
29 namespace Xapian {
31 CoordWeight *
32 CoordWeight::clone() const
34 return new CoordWeight;
37 void
38 CoordWeight::init(double factor_)
40 factor = factor_;
43 string
44 CoordWeight::name() const
46 return "Xapian::CoordWeight";
49 string
50 CoordWeight::short_name() const
52 return "coord";
55 string
56 CoordWeight::serialise() const
58 // No parameters to serialise.
59 return string();
62 CoordWeight *
63 CoordWeight::unserialise(const string& s) const
65 if (rare(!s.empty()))
66 throw Xapian::SerialisationError("Extra data in CoordWeight::unserialise()");
67 return new CoordWeight;
70 double
71 CoordWeight::get_sumpart(Xapian::termcount, Xapian::termcount,
72 Xapian::termcount, Xapian::termcount) const
74 return factor;
77 double
78 CoordWeight::get_maxpart() const
80 return factor;
83 CoordWeight *
84 CoordWeight::create_from_parameters(const char * p) const
86 if (*p != '\0')
87 throw InvalidArgumentError("No parameters are required for CoordWeight");
88 return new Xapian::CoordWeight();