From 9089a6c0fb595afe96c04094d42039512cb71a0a Mon Sep 17 00:00:00 2001 From: "Chris M. Hostetter" Date: Wed, 29 Feb 2012 01:00:59 +0000 Subject: [PATCH] javadocs: picture is worth 1000 words git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1294920 13f79535-47bb-0310-9956-ffa450edef68 --- .../lucene/misc/SweetSpotSimilarity.java | 6 +- .../lucene/misc/doc-files/ss.baselineTf.svg | 208 ++++++++++++++++++ .../misc/doc-files/ss.computeLengthNorm.svg | 201 +++++++++++++++++ .../apache/lucene/misc/doc-files/ss.gnuplot | 67 ++++++ .../lucene/misc/doc-files/ss.hyperbolicTf.svg | 193 ++++++++++++++++ 5 files changed, 674 insertions(+), 1 deletion(-) create mode 100644 lucene/contrib/misc/src/java/org/apache/lucene/misc/doc-files/ss.baselineTf.svg create mode 100644 lucene/contrib/misc/src/java/org/apache/lucene/misc/doc-files/ss.computeLengthNorm.svg create mode 100644 lucene/contrib/misc/src/java/org/apache/lucene/misc/doc-files/ss.gnuplot create mode 100644 lucene/contrib/misc/src/java/org/apache/lucene/misc/doc-files/ss.hyperbolicTf.svg diff --git a/lucene/contrib/misc/src/java/org/apache/lucene/misc/SweetSpotSimilarity.java b/lucene/contrib/misc/src/java/org/apache/lucene/misc/SweetSpotSimilarity.java index d8a275ddf4e..b52dcbac476 100644 --- a/lucene/contrib/misc/src/java/org/apache/lucene/misc/SweetSpotSimilarity.java +++ b/lucene/contrib/misc/src/java/org/apache/lucene/misc/SweetSpotSimilarity.java @@ -41,6 +41,7 @@ import org.apache.lucene.index.Norm; * subclasses can choose between. *

* + * @see A Gnuplot file used to generate some of the visualizations refrenced from each function. */ public class SweetSpotSimilarity extends DefaultSimilarity { @@ -75,7 +76,7 @@ public class SweetSpotSimilarity extends DefaultSimilarity { * * @param min the minimum tf value to ever be returned (default: 0.0) * @param max the maximum tf value to ever be returned (default: 2.0) - * @param base the base value to be used in the exponential for the hyperbolic function (default: e) + * @param base the base value to be used in the exponential for the hyperbolic function (default: 1.3) * @param xoffset the midpoint of the hyperbolic function (default: 10.0) * @see #hyperbolicTf */ @@ -135,6 +136,7 @@ public class SweetSpotSimilarity extends DefaultSimilarity { *

* * @see #setLengthNormFactors + * @see An SVG visualization of this function */ public float computeLengthNorm(int numTerms) { final int l = ln_min; @@ -175,6 +177,7 @@ public class SweetSpotSimilarity extends DefaultSimilarity { *

* * @see #setBaselineTfFactors + * @see An SVG visualization of this function */ public float baselineTf(float freq) { @@ -198,6 +201,7 @@ public class SweetSpotSimilarity extends DefaultSimilarity { *

* * @see #setHyperbolicTfFactors + * @see An SVG visualization of this function */ public float hyperbolicTf(float freq) { if (0.0f == freq) return 0.0f; diff --git a/lucene/contrib/misc/src/java/org/apache/lucene/misc/doc-files/ss.baselineTf.svg b/lucene/contrib/misc/src/java/org/apache/lucene/misc/doc-files/ss.baselineTf.svg new file mode 100644 index 00000000000..d6cbb953f86 --- /dev/null +++ b/lucene/contrib/misc/src/java/org/apache/lucene/misc/doc-files/ss.baselineTf.svg @@ -0,0 +1,208 @@ + + + +Produced by GNUPLOT 4.2 patchlevel 5 + + + + + + + + + + + + + + + + + + + + + + + + -1 + + + + + 0 + + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + 5 + + + + + 6 + + + + + 7 + + + + + 8 + + + + + 0 + + + + + 5 + + + + + 10 + + + + + 15 + + + + + 20 + + + + + SweetSpotSimilarity.baselineTf(x) + + + + + + + + + + all defaults + + + + + + + + + + + base=1.5 + + + + + + + + + + + min=5 + + + + + + + + + + + min=5, base=1.5 + + + + + + + + + + + diff --git a/lucene/contrib/misc/src/java/org/apache/lucene/misc/doc-files/ss.computeLengthNorm.svg b/lucene/contrib/misc/src/java/org/apache/lucene/misc/doc-files/ss.computeLengthNorm.svg new file mode 100644 index 00000000000..cdae3dd0249 --- /dev/null +++ b/lucene/contrib/misc/src/java/org/apache/lucene/misc/doc-files/ss.computeLengthNorm.svg @@ -0,0 +1,201 @@ + + + +Produced by GNUPLOT 4.2 patchlevel 5 + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + 0.2 + + + + + 0.4 + + + + + 0.6 + + + + + 0.8 + + + + + 1 + + + + + 1.2 + + + + + 0 + + + + + 5 + + + + + 10 + + + + + 15 + + + + + 20 + + + + + SweetSpotSimilarity.computeLengthNorm(t) + + + + + + + + + + all defaults + + + + + + + + + + + steepness=0.2 + + + + + + + + + + + max=6, steepness=0.2 + + + + + + + + + + + min=3, max=5 + + + + + + + + + + + diff --git a/lucene/contrib/misc/src/java/org/apache/lucene/misc/doc-files/ss.gnuplot b/lucene/contrib/misc/src/java/org/apache/lucene/misc/doc-files/ss.gnuplot new file mode 100644 index 00000000000..68403b2e89e --- /dev/null +++ b/lucene/contrib/misc/src/java/org/apache/lucene/misc/doc-files/ss.gnuplot @@ -0,0 +1,67 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. +# +# #################################################################### +# +# Instructions for generating SVG renderings of the functions +# used in SweetSpotSimilarity +# +# #################################################################### +# +# +set terminal svg size 600,400 dynamic enhanced fname 'arial' fsize 11 butt solid +set key inside left top vertical Right noreverse enhanced autotitles box linetype -1 linewidth 1.000 +# +# ####### BASELINE TF +# +set output 'ss.baselineTf.svg' +set title "SweetSpotSimilarity.baselineTf(x)" +set xrange [0:20] +set yrange [-1:8] +btf(base,min,x)=(x <= min) ? base : sqrt(x+(base**2)-min) +# +plot btf(0,0,x) ti "all defaults", \ + btf(1.5,0,x) ti "base=1.5", \ + btf(0,5,x) ti "min=5", \ + btf(1.5,5,x) ti "min=5, base=1.5" +# +# ####### HYPERBOLIC TF +# +set output 'ss.hyperbolicTf.svg' +set title "SweetSpotSimilarity.hyperbolcTf(x)" +set xrange [0:20] +set yrange [0:3] +htf(min,max,base,xoffset,x)=min+(max-min)/2*(((base**(x-xoffset)-base**-(x-xoffset))/(base**(x-xoffset)+base**-(x-xoffset)))+1) +# +plot htf(0,2,1.3,10,x) ti "all defaults", \ + htf(0,2,1.3,5,x) ti "xoffset=5", \ + htf(0,2,1.2,10,x) ti "base=1.2", \ + htf(0,1.5,1.3,10,x) ti "max=1.5" +# +# ####### LENGTH NORM +# +set key inside right top +set output 'ss.computeLengthNorm.svg' +set title "SweetSpotSimilarity.computeLengthNorm(t)" +set xrange [0:20] +set yrange [0:1.2] +set mxtics 5 +cln(min,max,steepness,x)=1/sqrt( steepness * (abs(x-min) + abs(x-max) - (max-min)) + 1 ) +# +plot cln(1,1,0.5,x) ti "all defaults", \ + cln(1,1,0.2,x) ti "steepness=0.2", \ + cln(1,6,0.2,x) ti "max=6, steepness=0.2", \ + cln(3,5,0.5,x) ti "min=3, max=5" diff --git a/lucene/contrib/misc/src/java/org/apache/lucene/misc/doc-files/ss.hyperbolicTf.svg b/lucene/contrib/misc/src/java/org/apache/lucene/misc/doc-files/ss.hyperbolicTf.svg new file mode 100644 index 00000000000..0f2d01c6c6e --- /dev/null +++ b/lucene/contrib/misc/src/java/org/apache/lucene/misc/doc-files/ss.hyperbolicTf.svg @@ -0,0 +1,193 @@ + + + +Produced by GNUPLOT 4.2 patchlevel 5 + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + 0.5 + + + + + 1 + + + + + 1.5 + + + + + 2 + + + + + 2.5 + + + + + 3 + + + + + 0 + + + + + 5 + + + + + 10 + + + + + 15 + + + + + 20 + + + + + SweetSpotSimilarity.hyperbolcTf(x) + + + + + + + + + + all defaults + + + + + + + + + + + xoffset=5 + + + + + + + + + + + base=1.2 + + + + + + + + + + + max=1.5 + + + + + + + + + + +