﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>博客园-雨中漫步的太阳-最新评论</title><link>http://www.cnblogs.com/suyuan/CommentsRSS.aspx</link><description>雨中漫步,笑看人生百态,优哉游哉</description><language>zh-cn</language><pubDate>Mon, 18 Aug 2008 10:15:01 GMT</pubDate><lastBuildDate>Mon, 18 Aug 2008 10:15:01 GMT</lastBuildDate><generator>cnblogs</generator><item><title>re: Asp.net2005 使用 NVelocity 实现 MVC </title><link>http://www.cnblogs.com/suyuan/archive/2008/08/18/1169756.html#1290720</link><dc:creator>乐游游</dc:creator><author>乐游游</author><pubDate>Mon, 18 Aug 2008 14:56:39 GMT</pubDate><guid>http://www.cnblogs.com/suyuan/archive/2008/08/18/1169756.html#1290720</guid><description><![CDATA[正遇到楼主所描述的问题 - -！<br><br>0.4好像有个 NVelocity.Http 可以实现呢，到 Castle 维护后就没了 @_@<br><br>这种模式，使用过程中有没遇到重大问题？<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/suyuan/" target="_blank">乐游游</a> 2008-08-18 22:56 <a href="http://www.cnblogs.com/suyuan/archive/2008/08/18/1169756.html#1290720#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 自己动手实现 lucene 搜索代码高亮显示</title><link>http://www.cnblogs.com/suyuan/archive/2008/08/01/1256775.html#1274562</link><dc:creator>雨中漫步的太阳</dc:creator><author>雨中漫步的太阳</author><pubDate>Fri, 01 Aug 2008 03:36:54 GMT</pubDate><guid>http://www.cnblogs.com/suyuan/archive/2008/08/01/1256775.html#1274562</guid><description><![CDATA[Lucene 中文分词的 highlight 显示<br/><br/>1 、问题的来源<br/><br/>增加分词以后结果的准确度提高了，但是用户反映返回结果的速度很慢。原因是， Lucene 做每一篇文档的相关关键词的高亮显示时，在运行时执行了很多遍的分词操作。这样降低了性能。<br/><br/>2 、解决方法<br/><br/>在 Lucene1.4.3 版本中的一个新功能可以解决这个问题。 Term Vector 现在支持保存 Token.getPositionIncrement() 和 Token.startOffset() 以及 Token.endOffset() 信息。利用 Lucene 中新增加的 Token 信息的保存结果以后，就不需要为了高亮显示而在运行时解析每篇文档。通过 Field 方法控制是否保存该信息。修改 HighlighterTest.java 的代码如下：<br/><br/>// 增加文档时保存 Term 位置信息。<br/><br/>private void addDoc(IndexWriter writer, String text) throws IOException<br/><br/>{<br/><br/>Document d = new Document();<br/><br/>//Field f = new Field(FIELD_NAME, text, true, true, true);<br/><br/>Field f = new Field(FIELD_NAME, text ,<br/><br/>Field.Store.YES, Field.Index.TOKENIZED,<br/><br/>Field.TermVector.WITH_POSITIONS_OFFSETS);<br/><br/>d.add(f);<br/><br/>writer.addDocument(d);<br/><br/>}<br/><br/>// 利用 Term 位置信息节省 Highlight 时间。<br/><br/>void doStandardHighlights() throws Exception<br/><br/>{<br/><br/>Highlighter highlighter =new Highlighter(this,new QueryScorer(query));<br/><br/>highlighter.setTextFragmenter(new SimpleFragmenter(20));<br/><br/>for (int i = 0; i &lt; hits.length(); i++)<br/><br/>{<br/><br/>String text = hits.doc(i).get(FIELD_NAME);<br/><br/>int maxNumFragmentsRequired = 2;<br/><br/>String fragmentSeparator = &quot;...&quot;;<br/><br/>TermPositionVector tpv = (TermPositionVector)reader.getTermFreqVector(hits.id(i),FIELD_NAME);<br/><br/>// 如果没有 stop words 去除还可以改成 TokenSources.getTokenStream(tpv,true); 进一步提速。<br/><br/>TokenStream tokenStream=TokenSources.getTokenStream(tpv);<br/><br/>//analyzer.tokenStream(FIELD_NAME,new StringReader(text));<br/><br/>String result =<br/><br/>highlighter.getBestFragments(<br/><br/>tokenStream,<br/><br/>text,<br/><br/>maxNumFragmentsRequired,<br/><br/>fragmentSeparator);<br/><br/>System.out.println(&quot;\t&quot; + result);<br/><br/>}<br/><br/>}<br/><br/>最后把 highlight 包中的一个额外的判断去掉。对于中文来说没有明显的单词界限，所以下面这个判断是错误的：<br/><br/>tokenGroup.isDistinct(token)<br/><br/>这样中文分词就不会影响到查询速度了。 <br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/suyuan/" target="_blank">雨中漫步的太阳</a> 2008-08-01 11:36 <a href="http://www.cnblogs.com/suyuan/archive/2008/08/01/1256775.html#1274562#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 自己动手实现 lucene 搜索代码高亮显示</title><link>http://www.cnblogs.com/suyuan/archive/2008/07/31/1256775.html#1273288</link><dc:creator>雨中漫步的太阳</dc:creator><author>雨中漫步的太阳</author><pubDate>Thu, 31 Jul 2008 02:42:43 GMT</pubDate><guid>http://www.cnblogs.com/suyuan/archive/2008/07/31/1256775.html#1273288</guid><description><![CDATA[--引用--------------------------------------------------<br/>jowo: 这种效率肯定差<br/>--------------------------------------------------------<br/>我这里简单做了测试,搜索分页的时候由于仅仅对10条信息处理 ,使用此方法和不使用此方法 时间上大致相差 10毫秒  具体和heiglight来比较的话 没有严格的比较, 但是我想heiglight还有通过分词器对比字典来先分词后replace的方式 不知道会比这个快多少, jowo 希望你有时间做个测试<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/suyuan/" target="_blank">雨中漫步的太阳</a> 2008-07-31 10:42 <a href="http://www.cnblogs.com/suyuan/archive/2008/07/31/1256775.html#1273288#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 自己动手实现 lucene 搜索代码高亮显示</title><link>http://www.cnblogs.com/suyuan/archive/2008/07/31/1256775.html#1273279</link><dc:creator>雨中漫步的太阳</dc:creator><author>雨中漫步的太阳</author><pubDate>Thu, 31 Jul 2008 02:39:42 GMT</pubDate><guid>http://www.cnblogs.com/suyuan/archive/2008/07/31/1256775.html#1273279</guid><description><![CDATA[--引用--------------------------------------------------<br/>小龟爬爬: 博主 试没试过用替换字符串的办法<br/>比如“博客园,程序员的家园”想要高亮显示“园”字<br/>就可以用“&amp;lt;font color=red&amp;gt;园&amp;lt;/font&amp;gt;”替换字符串里的“园”字就可以了……<br/>--------------------------------------------------------<br/>我文章里面说了 &quot;有些朋友仅仅使用了套红也就是仅仅replaceall 那样会造成假如你的文本太长 你想substr的时候,很可能你的套红根本没有显示出来 原因很简单 被你cut掉了 呵呵 而这个就不会,可以避免上述情况.&quot;<br/><br/><br/><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/suyuan/" target="_blank">雨中漫步的太阳</a> 2008-07-31 10:39 <a href="http://www.cnblogs.com/suyuan/archive/2008/07/31/1256775.html#1273279#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 自己动手实现 lucene 搜索代码高亮显示</title><link>http://www.cnblogs.com/suyuan/archive/2008/07/31/1256775.html#1273272</link><dc:creator>jowo</dc:creator><author>jowo</author><pubDate>Thu, 31 Jul 2008 02:36:21 GMT</pubDate><guid>http://www.cnblogs.com/suyuan/archive/2008/07/31/1256775.html#1273272</guid><description><![CDATA[这种效率肯定差<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/suyuan/" target="_blank">jowo</a> 2008-07-31 10:36 <a href="http://www.cnblogs.com/suyuan/archive/2008/07/31/1256775.html#1273272#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 自己动手实现 lucene 搜索代码高亮显示</title><link>http://www.cnblogs.com/suyuan/archive/2008/07/31/1256775.html#1273158</link><dc:creator>小龟爬爬</dc:creator><author>小龟爬爬</author><pubDate>Thu, 31 Jul 2008 01:42:53 GMT</pubDate><guid>http://www.cnblogs.com/suyuan/archive/2008/07/31/1256775.html#1273158</guid><description><![CDATA[博主 试没试过用替换字符串的办法<br/>比如“博客园,程序员的家园”想要高亮显示“园”字<br/>就可以用“&lt;font color=red&gt;园&lt;/font&gt;”替换字符串里的“园”字就可以了……<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/suyuan/" target="_blank">小龟爬爬</a> 2008-07-31 09:42 <a href="http://www.cnblogs.com/suyuan/archive/2008/07/31/1256775.html#1273158#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 自己动手实现 lucene 搜索代码高亮显示</title><link>http://www.cnblogs.com/suyuan/archive/2008/07/31/1256775.html#1273023</link><dc:creator>雨中漫步的太阳</dc:creator><author>雨中漫步的太阳</author><pubDate>Thu, 31 Jul 2008 00:42:57 GMT</pubDate><guid>http://www.cnblogs.com/suyuan/archive/2008/07/31/1256775.html#1273023</guid><description><![CDATA[@Birdshover<br/>你做过测试么?<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/suyuan/" target="_blank">雨中漫步的太阳</a> 2008-07-31 08:42 <a href="http://www.cnblogs.com/suyuan/archive/2008/07/31/1256775.html#1273023#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 自己动手实现 lucene 搜索代码高亮显示</title><link>http://www.cnblogs.com/suyuan/archive/2008/07/30/1256775.html#1272861</link><dc:creator>Birdshover</dc:creator><author>Birdshover</author><pubDate>Wed, 30 Jul 2008 15:30:08 GMT</pubDate><guid>http://www.cnblogs.com/suyuan/archive/2008/07/30/1256775.html#1272861</guid><description><![CDATA[用Lucene的Token啊，用正则效率太低了<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/suyuan/" target="_blank">Birdshover</a> 2008-07-30 23:30 <a href="http://www.cnblogs.com/suyuan/archive/2008/07/30/1256775.html#1272861#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 一个字符串str=&amp;quot;fsdafdsaf&amp;quot; 任意个字符,求出这个字符串中出现次数最多的字符和出现的次数</title><link>http://www.cnblogs.com/suyuan/archive/2008/07/30/1241067.html#1272844</link><dc:creator>SK_Bogdan</dc:creator><author>SK_Bogdan</author><pubDate>Wed, 30 Jul 2008 15:19:35 GMT</pubDate><guid>http://www.cnblogs.com/suyuan/archive/2008/07/30/1241067.html#1272844</guid><description><![CDATA[1楼答案时间复杂度最小,尤其当字符串规模大的时候.因为字符的取值范围是确定的,所以可以引入计数排序的思想.这是典型的用空间换时间的办法.用Hash的话空间规模与数组相比不敢恭维.<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/suyuan/" target="_blank">SK_Bogdan</a> 2008-07-30 23:19 <a href="http://www.cnblogs.com/suyuan/archive/2008/07/30/1241067.html#1272844#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 自己动手实现 lucene 搜索代码高亮显示</title><link>http://www.cnblogs.com/suyuan/archive/2008/07/30/1256775.html#1272824</link><dc:creator>留恋星空</dc:creator><author>留恋星空</author><pubDate>Wed, 30 Jul 2008 14:55:36 GMT</pubDate><guid>http://www.cnblogs.com/suyuan/archive/2008/07/30/1256775.html#1272824</guid><description><![CDATA[......<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/suyuan/" target="_blank">留恋星空</a> 2008-07-30 22:55 <a href="http://www.cnblogs.com/suyuan/archive/2008/07/30/1256775.html#1272824#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>