首页 \ 问答 \ Lucene的连字符(Hyphens in Lucene)

Lucene的连字符(Hyphens in Lucene)

我正在玩Lucene并注意到使用连字符(例如“半决赛”)将导致两个单词(索引中的“半”和“最终”。如果用户搜索,这应该如何匹配对于“半决赛”,用一个词来说?

编辑:我实际上只是在玩StandardTokenizer类,也许这就是为什么? 我错过了过滤器吗?

谢谢!

(编辑)我的代码如下所示:

            StandardAnalyzer sa = new StandardAnalyzer();
            TokenStream ts = sa.TokenStream("field", new StringReader("semi-final"));

            while (ts.IncrementToken())
            {
                string t = ts.ToString();
                Console.WriteLine("Token: " + t);
            }

I'm playing around with Lucene and noticed that the use of a hyphen (e.g. "semi-final") will result in two words ("semi" and "final" in the index. How is this supposed to match if the users searches for "semifinal", in one word?

Edit: I'm just playing around with the StandardTokenizer class actually, maybe that is why? Am I missing a filter?

Thanks!

(Edit) My code looks like this:

            StandardAnalyzer sa = new StandardAnalyzer();
            TokenStream ts = sa.TokenStream("field", new StringReader("semi-final"));

            while (ts.IncrementToken())
            {
                string t = ts.ToString();
                Console.WriteLine("Token: " + t);
            }

原文:https://stackoverflow.com/questions/2600940
更新时间:2024-01-04 06:01

最满意答案

要同时执行任何两个动画,您必须在两个效果上使用“队列”选项,将值设置为false。 默认情况下,每个效果都是同步排队的。 将“queue”设置为false将使它们异步运行。

在下面的第一个小提琴中,两个div基于按钮单击向左/向右滑动。 你会注意到我做了一些额外的css操作来将div相对放在一起以实现所需的滑动效果,并且我已经在元素上设置了特定的宽度。 在进行幻灯片效果时,动画元素在显示或隐藏时需要额外的空间来“转到”,因此宽度和位置操作可以克服这个问题。 使用“队列”,javascript看起来像这样:

$("#previous").on('click', function(){
    $("#2DivT").css("left", "-179px").effect("slide", { direction: "left", duration: 900, mode: "hide", queue: false });
    $("#1DivT").effect("slide", { direction: "right", duration: 900, mode: "show", queue: false });
});

$("#next").on('click', function(){
    $("#2DivT").effect("slide", { direction: "left", duration: 900, mode: "show", queue: false }, function() { $(this).css("left", "0"); });
    $("#1DivT").effect("slide", { direction: "right", duration: 900, mode: "hide", queue: false });
});

https://jsfiddle.net/f6rtrst3/34/

在下面的第二个小提琴中,我尽可能地保持你的结构,但默认动画效果为“swing”。 这显示了两个动画同时运行并且彼此重叠。 使用默认的“swing”动画,javascript看起来像这样:

$("#previous").on('click', function(){
    $("#2DivT").hide({ queue : false, duration : 900 });
    $("#1DivT").show({ queue : false, duration : 900} );
});

$("#next").on('click', function(){
    $("#1DivT").hide({ queue : false, duration : 900 });
    $("#2DivT").show({ queue : false, duration : 900 });
});

https://jsfiddle.net/f6rtrst3/36/

希望这两个小提琴的某些组合可以让你到达目的地。


To do any two animations simultaneously, you have to use the "queue" option on both effects, setting the value to false. By default, each effect is queued synchronously. Setting "queue" to false will make them run asynchronously.

In my first fiddle below, two divs slide out going left / right based on the button click. You'll notice I did some extra css manipulation to position the divs relatively on top of one another to achieve the desired sliding effect, and I have set specific widths on the elements. When doing the slide effect, extra room is required for the animated element to "go to" when showing or hiding it, thus the width and position manipulations to overcome this. Using "queue", the javascript looks like this:

$("#previous").on('click', function(){
    $("#2DivT").css("left", "-179px").effect("slide", { direction: "left", duration: 900, mode: "hide", queue: false });
    $("#1DivT").effect("slide", { direction: "right", duration: 900, mode: "show", queue: false });
});

$("#next").on('click', function(){
    $("#2DivT").effect("slide", { direction: "left", duration: 900, mode: "show", queue: false }, function() { $(this).css("left", "0"); });
    $("#1DivT").effect("slide", { direction: "right", duration: 900, mode: "hide", queue: false });
});

https://jsfiddle.net/f6rtrst3/34/

In my second fiddle below, I have maintained your structuring as close as possible but defaulted the animation effect to "swing". This shows two animations running simultaneously and also on top of one another. Using the default "swing" animation, the javascript looks like this:

$("#previous").on('click', function(){
    $("#2DivT").hide({ queue : false, duration : 900 });
    $("#1DivT").show({ queue : false, duration : 900} );
});

$("#next").on('click', function(){
    $("#1DivT").hide({ queue : false, duration : 900 });
    $("#2DivT").show({ queue : false, duration : 900 });
});

https://jsfiddle.net/f6rtrst3/36/

Hopefully some combination of these two fiddles will get you where you're going.

相关问答

更多
  • 要同时执行任何两个动画,您必须在两个效果上使用“队列”选项,将值设置为false。 默认情况下,每个效果都是同步排队的。 将“queue”设置为false将使它们异步运行。 在下面的第一个小提琴中,两个div基于按钮单击向左/向右滑动。 你会注意到我做了一些额外的css操作来将div相对放在一起以实现所需的滑动效果,并且我已经在元素上设置了特定的宽度。 在进行幻灯片效果时,动画元素在显示或隐藏时需要额外的空间来“转到”,因此宽度和位置操作可以克服这个问题。 使用“队列”,javascript看起来像这样: ...
  • 定位外部div但是你想要的,然后使用绝对位置内部div。 他们都会堆积起来
    1
    2
    3
    4
    Pos ...
  • 2
    的内容设置为浮动。 在
    的结束
    标记之前添加
    解决了这个问题。 The contents of the 2
    's were set to float. Adding a
    before the closing
    tag for both the
    's solved the issue.
  • 看看这段代码 HTML
    Foobar
    +
    为了在页面加载时隐藏它,我在id =“slidingable”的 div添加了一个“ 隐藏” class 。 如果你不想要它,你可以删除。 CSS (只有更改是我添加了hide类) #side{ float:right; width: ...
  • 然后你可以使用hover()函数 $(document).ready(function() { $('#crossfadingImages img').hover(function() { $('#crossfadingImages img:first-child').stop().fadeOut(500); $('#crossfadingImages img:last-child').stop().fadeIn(500); }, function() ...
  • 删除#ballWrapper和.centerText的当前样式。 喜欢这个: #ballWrapper { margin: 200px auto; position: relative; } .centerText { line-height: 200px; position: absolute; text-align: center; width: 100%; z-index: 1; } 演示 Remove the current styles f ...
  • jquery hover()接受两个函数:in和out事件...... http://api.jquery.com/hover/ 所以修改你的代码如下: