如何使用Lucene IndexReader寻找术语?(How to seek to a term using a Lucene IndexReader?)
我试图通过部分匹配来获得多语法查询。 根据
JavaDoc
forMultiPhraseQuery
:PhraseQuery的通用版本,可以在同一位置添加多个术语,将其视为析取(OR)。 要使用此类搜索短语“Microsoft app *”,首先创建一个Builder并在术语“microsoft”上使用MultiPhraseQuery.Builder.add(Term)(假设小写分析),然后查找所有具有“app”的术语使用LeafReader.terms(String)前缀,寻找“app”然后迭代并收集术语,直到不再有该前缀,最后使用MultiPhraseQuery.Builder.add(Term [])添加它们。 MultiPhraseQuery.Builder.build()返回完全构造(和不可变)的MultiPhraseQuery。
https://lucene.apache.org/core/6_6_0/core/org/apache/lucene/search/MultiPhraseQuery.html
我正在努力解决它所说的部分:
...使用LeafReader.terms(String)查找所有使用“app”作为前缀的术语,寻找“app”然后迭代并收集术语,直到不再有该前缀...
如何在那里寻求条款?
LeafReader.terms(String)
为您提供了一个Terms
,它具有iterator
方法,为您提供可以使用的TermsEnum
。 我只是不确定如何使用提取匹配术语?I'm trying to get a multi-phrased query to with a partial match. According to the
JavaDoc
forMultiPhraseQuery
:A generalized version of PhraseQuery, with the possibility of adding more than one term at the same position that are treated as a disjunction (OR). To use this class to search for the phrase "Microsoft app*" first create a Builder and use MultiPhraseQuery.Builder.add(Term) on the term "microsoft" (assuming lowercase analysis), then find all terms that have "app" as prefix using LeafReader.terms(String), seeking to "app" then iterating and collecting terms until there is no longer that prefix, and finally use MultiPhraseQuery.Builder.add(Term[]) to add them. MultiPhraseQuery.Builder.build() returns the fully constructed (and immutable) MultiPhraseQuery.
https://lucene.apache.org/core/6_6_0/core/org/apache/lucene/search/MultiPhraseQuery.html
I'm struggling with the part where it says:
...find all terms that have "app" as prefix using LeafReader.terms(String), seeking to "app" then iterating and collecting terms until there is no longer that prefix...
How does one seek over there terms?
LeafReader.terms(String)
gives youTerms
which has aniterator
method that gives youTermsEnum
which you canseek
with. I'm just not sure how extract matching terms using that?
原文:https://stackoverflow.com/questions/44703572
最满意答案
我已经注释掉了你不想要的那条线。 通过调用
closePath()
,您将关闭弧的路径。例
JavaScript的
ctx.strokeStyle='rgb(0,250,0)'; ctx.lineWidth=10; ctx.beginPath(); ctx.arc(100,100,45,0,Math.PI/2,true); //use 1/4 of original angle //ctx.closePath(); ctx.stroke();
jsFiddle 。
I've commented out the line you don't want. By calling
closePath()
, you are closing the path of your arc.Example
JavaScript
ctx.strokeStyle='rgb(0,250,0)'; ctx.lineWidth=10; ctx.beginPath(); ctx.arc(100,100,45,0,Math.PI/2,true); //use 1/4 of original angle //ctx.closePath(); ctx.stroke();
相关问答
更多-
最后我得到了这个代码的解决方案: float radius = 20; final RectF oval = new RectF(); oval.set(point1.x - radius, point1.y - radius, point1.x + radius, point1.y+ radius); Path myPath = new Path(); myPath.arcTo(oval, startAngle, -(float) sweepAngle, true); 要计算startAngle ,请使 ...
-
有一个用于创建弧的start选项,用于定义在给定角度时开始绘制的位置。 使用此算法和一些数学运算,您可以使用create_arc -method为任何位置绘制弧: import Tkinter as tk class SampleApp(tk.Tk): def __init__(self, *args, **kwargs): tk.Tk.__init__(self, *args, **kwargs) self.canvas = tk.Canvas(width= ...
-
所有画布路径命令都绘制单宽度笔划。 但这是通过在起点周围反复旋转圆弧“图像”来实现效果的一种方法。 您可以使用内存中的画布创建“图像”。 var canvas=document.getElementById("canvas"); var ctx=canvas.getContext("2d"); var c=document.createElement('canvas'); var cc=c.getContext('2d'); cc.beginPath(); cc.arc(0,52,50,Mat ...
-
您可以使用此函数来获取插入任意两点之间的直线的点数组: function linePoints(x1, y1, x2, y2, frames) { var dx = x2 - x1; var dy = y2 - y1; var length = Math.sqrt(dx * dx + dy * dy); var incrementX = dx / frames; var incrementY = dy / frames; var a = new Array() ...
-
HTML5在javascript中的两个div /点之间绘制一条弧线(HTML5 Draw an arc between two divs/points in javascript)[2023-07-09]
你可以使用JavaScript的画布。 您可以通过调用将画布的两个角与弧连接起来。 var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); ctx.beginPath(); ctx.arc(0,0,c.width,c.height,0.31416*Math.PI); ctx.stroke(); https://www.w3schools.com/tags/canvas_arc.asp 只要你的画布定位正确。 你可以通过o ... -
Android画布 - 在点之间绘制弧并从路径中删除弧(Android canvas - Drawing arc between to points and removing arc from path)[2021-06-28]
我编辑了我的代码如下,现在它正在工作.. public class DrawView extends View implements OnTouchListener { ListpointsD = new ArrayList (); pointsD.add(new Point(520, 70)); pointsD.add(new Point(520, 335)); pointsD.add(new Point(520, 70)); pointsD. ... -
我已经注释掉了你不想要的那条线。 通过调用closePath() ,您将关闭弧的路径。 例 JavaScript的 ctx.strokeStyle='rgb(0,250,0)'; ctx.lineWidth=10; ctx.beginPath(); ctx.arc(100,100,45,0,Math.PI/2,true); //use 1/4 of original angle //ctx.closePath(); ctx.stroke(); jsFiddle 。 I've commented ou ...
-
您可以使用转换。 就像在这个实例中一样 。 context.save() ; context.translate(150,150) ; context.scale(2,1) ; context.translate(-150,-150) ; context.moveTo(150, 150); context.arc(150, 150, 50, 0, 3*Math.PI/4, true); context.closePath(); context.stroke() ; context.restor ...
-
起点很简单(x + radius, y) 。 通过简单的三角函数,结束点是(x + radius*cos(angle), y + radius*sin(angle)) 。 请注意,在这种情况下的起点是更一般的终点的特殊情况, angle等于零。 出于显而易见的原因,这些值也需要四舍五入到最接近的整数。 (请注意,这仅适用于anticlockwise参数为false,并假设所有坐标均从左上角开始测量。如果anticlockwise为真,则反转y坐标的第二个分量的符号。如果坐标是从另一个角测量的,则应用简单的算 ...
-
以下是如何使用滑块逐步绘制四次和三次贝塞尔曲线 示例小提琴: http : //jsfiddle.net/m1erickson/auFam/ 此函数将以Quad曲线的指定百分比返回XY点: // quadratic bezier: percent is 0-1 function getQuadraticBezierXY(percent,startPt,controlPt,endPt) { var x = Math.pow(1-percent,2) * startP ...