You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2010/06/19 02:22:04 UTC
svn commit: r956162 - in /lucene/lucy/trunk/core/Lucy: Index/Similarity.bp
Index/Similarity/LuceneSimilarity.bp Index/Similarity/LuceneSimilarity.c
Search/PolyMatcher.bp Search/PolyMatcher.c
Author: marvin
Date: Sat Jun 19 00:22:04 2010
New Revision: 956162
URL: http://svn.apache.org/viewvc?rev=956162&view=rev
Log:
LUCY-112:
Add PolyMatcher.
Added:
lucene/lucy/trunk/core/Lucy/Search/PolyMatcher.bp (with props)
lucene/lucy/trunk/core/Lucy/Search/PolyMatcher.c (with props)
Modified:
lucene/lucy/trunk/core/Lucy/Index/Similarity.bp
lucene/lucy/trunk/core/Lucy/Index/Similarity/LuceneSimilarity.bp
lucene/lucy/trunk/core/Lucy/Index/Similarity/LuceneSimilarity.c
Modified: lucene/lucy/trunk/core/Lucy/Index/Similarity.bp
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Index/Similarity.bp?rev=956162&r1=956161&r2=956162&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Index/Similarity.bp (original)
+++ lucene/lucy/trunk/core/Lucy/Index/Similarity.bp Sat Jun 19 00:22:04 2010
@@ -22,6 +22,11 @@ abstract class Lucy::Index::Similarity c
public inert Similarity*
init(Similarity *self);
+ /** Calculate a score factor based on the number of terms which match.
+ */
+ public abstract float
+ Coord(Similarity *self, uint32_t overlap, uint32_t max_overlap);
+
public incremented Obj*
Dump(Similarity *self);
Modified: lucene/lucy/trunk/core/Lucy/Index/Similarity/LuceneSimilarity.bp
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Index/Similarity/LuceneSimilarity.bp?rev=956162&r1=956161&r2=956162&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Index/Similarity/LuceneSimilarity.bp (original)
+++ lucene/lucy/trunk/core/Lucy/Index/Similarity/LuceneSimilarity.bp Sat Jun 19 00:22:04 2010
@@ -11,6 +11,9 @@ class Lucy::Index::Similarity::LuceneSim
public inert LuceneSimilarity*
init(LuceneSimilarity *self);
+
+ public float
+ Coord(LuceneSimilarity *self, uint32_t overlap, uint32_t max_overlap);
}
/* Copyright 2010 The Apache Software Foundation
Modified: lucene/lucy/trunk/core/Lucy/Index/Similarity/LuceneSimilarity.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Index/Similarity/LuceneSimilarity.c?rev=956162&r1=956161&r2=956162&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Index/Similarity/LuceneSimilarity.c (original)
+++ lucene/lucy/trunk/core/Lucy/Index/Similarity/LuceneSimilarity.c Sat Jun 19 00:22:04 2010
@@ -18,6 +18,17 @@ LuceneSim_init(LuceneSimilarity *self)
return self;
}
+float
+LuceneSim_coord(LuceneSimilarity *self, uint32_t overlap,
+ uint32_t max_overlap)
+{
+ UNUSED_VAR(self);
+ if (max_overlap == 0)
+ return 1;
+ else
+ return (float)overlap / (float)max_overlap;
+}
+
/* Copyright 2010 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
Added: lucene/lucy/trunk/core/Lucy/Search/PolyMatcher.bp
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Search/PolyMatcher.bp?rev=956162&view=auto
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Search/PolyMatcher.bp (added)
+++ lucene/lucy/trunk/core/Lucy/Search/PolyMatcher.bp Sat Jun 19 00:22:04 2010
@@ -0,0 +1,38 @@
+parcel Lucy;
+
+/** Base class for composite Matchers.
+ */
+
+class Lucy::Search::PolyMatcher extends Lucy::Search::Matcher {
+
+ VArray *children;
+ Similarity *sim;
+ uint32_t num_kids;
+ uint32_t matching_kids;
+ float *coord_factors;
+
+ inert incremented PolyMatcher*
+ new(VArray *children, Similarity *similarity);
+
+ inert PolyMatcher*
+ init(PolyMatcher *self, VArray *children, Similarity *similarity);
+
+ public void
+ Destroy(PolyMatcher *self);
+}
+
+/* Copyright 2010 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
Propchange: lucene/lucy/trunk/core/Lucy/Search/PolyMatcher.bp
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/lucy/trunk/core/Lucy/Search/PolyMatcher.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Search/PolyMatcher.c?rev=956162&view=auto
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Search/PolyMatcher.c (added)
+++ lucene/lucy/trunk/core/Lucy/Search/PolyMatcher.c Sat Jun 19 00:22:04 2010
@@ -0,0 +1,55 @@
+#define C_LUCY_POLYMATCHER
+#include "Lucy/Util/ToolSet.h"
+
+#include "Lucy/Search/PolyMatcher.h"
+#include "Lucy/Index/Similarity.h"
+
+PolyMatcher*
+PolyMatcher_new(VArray *children, Similarity *sim)
+{
+ PolyMatcher *self = (PolyMatcher*)VTable_Make_Obj(POLYMATCHER);
+ return PolyMatcher_init(self, children, sim);
+}
+
+PolyMatcher*
+PolyMatcher_init(PolyMatcher *self, VArray *children, Similarity *similarity)
+{
+ uint32_t i;
+
+ Matcher_init((Matcher*)self);
+ self->num_kids = VA_Get_Size(children);
+ self->sim = (Similarity*)INCREF(similarity);
+ self->children = (VArray*)INCREF(children);
+ self->coord_factors = (float*)MALLOCATE((self->num_kids + 1) * sizeof(float));
+ for (i = 0; i <= self->num_kids; i++) {
+ self->coord_factors[i] = similarity
+ ? Sim_Coord(similarity, i, self->num_kids)
+ : 1.0f;
+ }
+ return self;
+}
+
+void
+PolyMatcher_destroy(PolyMatcher *self)
+{
+ DECREF(self->children);
+ DECREF(self->sim);
+ FREEMEM(self->coord_factors);
+ SUPER_DESTROY(self, POLYMATCHER);
+}
+
+/* Copyright 2010 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
Propchange: lucene/lucy/trunk/core/Lucy/Search/PolyMatcher.c
------------------------------------------------------------------------------
svn:eol-style = native