<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>超群.com的博客 &#187; Open Source</title>
	<atom:link href="http://www.fuchaoqun.com/category/open_source/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fuchaoqun.com</link>
	<description></description>
	<lastBuildDate>Thu, 22 Jul 2010 23:31:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>ColaPHP 0.6beta发布</title>
		<link>http://www.fuchaoqun.com/2010/02/colaphp-0-6-beta/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=colaphp-0-6-beta</link>
		<comments>http://www.fuchaoqun.com/2010/02/colaphp-0-6-beta/#comments</comments>
		<pubDate>Sat, 27 Feb 2010 17:39:33 +0000</pubDate>
		<dc:creator>超群.com</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ColaPHP]]></category>

		<guid isPermaLink="false">http://www.fuchaoqun.com/?p=330</guid>
		<description><![CDATA[ColaPHP月度发布计划版本，代号：Easy，和0.5beta相比变化不大，主要修改如下： 增加Yaml处理，底层调用symfony yaml包处理 增加自定义异常类，后续准备将框架中的异常细分（好处是将来可以对异常做针对性处理） 少量代码重构以及bug fix 下载ColaPHP 0.6beta，阅读ColaPHP文档，访问ColaPHP项目。 下一个版本0.7beta开发代号：Recode，主要对代码做进一步重构优化。]]></description>
			<content:encoded><![CDATA[<p>ColaPHP月度发布计划版本，代号：Easy，和0.5beta相比变化不大，主要修改如下：</p>
<ul>
<li>增加Yaml处理，底层调用symfony yaml包处理</li>
<li> 增加自定义异常类，后续准备将框架中的异常细分（好处是将来可以对异常做针对性处理）</li>
<li> 少量代码重构以及bug fix</li>
</ul>
<p><a href="http://colaphp.googlecode.com/files/ColaPHP-0.6-beta.zip" target="_blank">下载ColaPHP 0.6beta</a>，阅读<a href="http://code.google.com/p/colaphp/w/list" target="_blank">ColaPHP文档</a>，访问<a href="http://code.google.com/p/colaphp/" target="_blank">ColaPHP项目</a>。</p>
<p>下一个版本0.7beta开发代号：Recode，主要对代码做进一步重构优化。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fuchaoqun.com/2010/02/colaphp-0-6-beta/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>[视频]MongoDb In Action</title>
		<link>http://www.fuchaoqun.com/2010/02/mongodb-in-action-video/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=mongodb-in-action-video</link>
		<comments>http://www.fuchaoqun.com/2010/02/mongodb-in-action-video/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 11:09:26 +0000</pubDate>
		<dc:creator>超群.com</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[mongodb]]></category>

		<guid isPermaLink="false">http://www.fuchaoqun.com/?p=325</guid>
		<description><![CDATA[上次OpenParty上分享MongoDb In Action的视频，Slides在这里，貌似偶有点结巴:)]]></description>
			<content:encoded><![CDATA[<p><embed src="http://player.ku6.com/refer/1lgfJoJtkmReFR3q/v.swf" quality="high" width="414" height="305" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash"></embed></p>
<p>上次OpenParty上分享MongoDb In Action的视频，Slides在<a href="http://www.fuchaoqun.com/2010/01/mongodb-in-action/" target="_blank">这里</a>，貌似偶有点结巴:)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fuchaoqun.com/2010/02/mongodb-in-action-video/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>ChinaUnix网络优化论坛归来</title>
		<link>http://www.fuchaoqun.com/2009/01/cu-net-opt-salon/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=cu-net-opt-salon</link>
		<comments>http://www.fuchaoqun.com/2009/01/cu-net-opt-salon/#comments</comments>
		<pubDate>Sat, 10 Jan 2009 03:56:39 +0000</pubDate>
		<dc:creator>超群.com</dc:creator>
				<category><![CDATA[Arch]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[chinaunix]]></category>
		<category><![CDATA[load balance]]></category>
		<category><![CDATA[lvs]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://chaoqun.17348.com/?p=129</guid>
		<description><![CDATA[本博客所有原创文章采用知识共享署名-非商业性使用-相同方式共享，转载请保留链接http://chaoqun.17348.com/2009/01/cu-net-opt-salon/ 特意把调休放在1.9，主要是想去听听CU组织的网络优化论坛，报名的时候有点意外，貌似丢失了报名信息，和组织者沟通了一下，感谢周平同学的热心帮助，说到的时候找他就可以，去的时候其实也没有查邀请函什么的，还给了件CU的T-Shirt，甚是感谢，一般这种开源技术研讨会都是很开放的。 首先是TOM网的曹刚带来的“浅析系统架构”，主要讲的是Myspace和SOHU社区架构的演变过程，基本的内容可以参考构建可扩展网络应用的七个步骤，一般他们的历程都是从第一步到第四步，大体上差不多，我这里列举这个关键词： 64位：Myspace为了让服务器管理更多的内容，操作系统由32位升级到64位，我们都知道32位的操作系统最多支持4G内存（当然有方法可以实现超过4G，不推荐。），64位操作系统理论上支持4G个G，估计我是看不到用完的那天，这里要注意的是32位操作系统下，一个处理器最多处理2G内存，所以如果是Memcached服务器，不要一个进程给超过2G内存，浪费。好的做法是多开几个服务，或者直接把Memcached服务器和APP服务器合二为一，很多公司都这样。 分表：论坛的特点是数据一般是按照板块分组，所以对于论坛这样的应用来说，最好是按照板块ID分表甚至分库分机器。 板块帖子列表页：论坛的特性是新帖子、新更新的帖子排在最前面，所以可能的情况是每次刷新的时候页面都在变，SOHU社区的做法是把板块新帖子保持在一个链表里面，链表的特点是插入和删除都很快，问题是查询的时候只能遍历。 其实对于一个论坛板块来说，热门的帖子不会太多，估计大家也就翻前几页，大可以把这个数据放进缓存中，比如维护一个队列，最新的500个帖子ID，帖子Title，新帖子放在最前面，自动顶掉最后一个，大可以用数组而不用链表，虽然插入的时候慢点，读取的时候却不用遍历链表。 对于跟帖数据，一般都是按照时间顺序排列，新增加的帖子自动在最后，压力不会很大。 google去搜一下Carp算法，一致性哈希算法consistent hashing（可以参考http://tech.idv2.com/2008/08/17/memcached-pdf/），Amazon S3 环形算法（是不是就是consistent hashing?不知）。 曹刚最后做了个总结，个人觉得：熟悉业务需求应该是核心。 第二位演讲者是来自占座网的吴炳锡，讲的是LVS和Nginx的负载均衡，这块以前只是从资料上看过，接触比较少，不过炳锡的介绍深入浅出，以前觉得LVS晦涩难懂，不敢动手，听完之后无知者无畏了，有机会试试看去。其实很多事情都这样，看上去挺难，做起来就容易了，下面是几个关键字： DR模式：LVS有NAT、TUN、DR模式，推荐使用DR模式，更多的信息去google吧。 LVS-&#62;Nginx-&#62;Squid：组合的模式，LVS是四层的转发，Nginx是七层的转发，可以支持URL规则的转发，组合起来用就可以随心所欲了。 性能：Nginx的性能和LVS NAT模式相当，都是很好的解决方案，熟悉哪个就用哪个吧，性能都不是问题。 keepalived：LVS居家旅行、杀人灭口必配武器。 搜房网：搜房网前端采用LVS做负载均衡，中间用Nginx做URL负载均衡，动态的URL跳到App服务器，静态的URL跳转到Squid服务器。 第三位演讲者来自某个赞助商，感谢他们对活动的赞助，就不做广告了，一句话概括：适合钱多人傻。 第四位演讲者来自SOHU的MySQL DBA叶金荣，报告的内容网上大多有，这里也列出一些关键字： 发现问题：系统响应慢、load avg &#62;=5、IO wait &#62;= 10、swap使用情况、mysql status、mysql report、mysql 5.1 profline xfs：如果可能，mysql数据文件系统分区采用xfs，效果高30％～50％ innodb_buffer_pool_size：如果是专用的数据库服务器，设定为内存的80％吧 MyIsam适合低并发、低更新、高读取的需求，InnoDB适合高并发、高更新、高读取的需求，MyIsam读取的速度比InnoDB快许多。 Explain：查询检查、查询优化 联合索引：貌似MySQL一次查询只用到一个索引，联合索引要注意先后顺序的问题，“左派”比较吃香。 字段按需配置，能用TinyINT的不用INT，字段越短越好，具体差别可以参见：http://chaoqun.17348.com/2008/11/mysql-data-types-int/ 把大表拆成小表，如果表字段里面有Text，尽量拆开吧。 缩短事务周期 字符型的字段，最好采用前缀索引。 复杂的查询拆成小的简单的查询，比如用循环查询替代。这点不敢苟同，还是按照自己的业务测试一下吧。一条sql语句总比N条要快吧，除非有问题。 left join：把条目数少的放左边，如果你了解left join的话，这个是肯定的。 实时备份：用slave做实时备份吧，一个slave就是一个备份。 第五个演讲最为精彩，走了的人实在可惜，掌声和笑声不断，田逸这个家伙说话太有意思的，有机会要认识一下。讲的是CDN方面的事情，关键字：策略，技术很重要，策略更重要。 昨天的网络优化论坛受益匪浅，演讲者都有丰富的经验，其实网站架构就那么点事情，多分享才能共同进步，不过从互动环节可以看出国内做技术的对这方面关注还是比较少，有些问题比较原始，多关注一些就不会那样了。 PS:报告盖茨：我上周四叛逃到Linux了。]]></description>
			<content:encoded><![CDATA[<blockquote><p>本博客所有原创文章采用<a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"><span style="color: #356aa0;">知识共享署名-非商业性使用-相同方式共享</span></a>，转载请保留链接<a href="http://chaoqun.17348.com/2009/01/cu-net-opt-salon/">http://chaoqun.17348.com/2009/01/cu-net-opt-salon/</a></p></blockquote>
<p>特意把调休放在1.9，主要是想去听听CU组织的网络优化论坛，报名的时候有点意外，貌似丢失了报名信息，和组织者沟通了一下，感谢周平同学的热心帮助，说到的时候找他就可以，去的时候其实也没有查邀请函什么的，还给了件CU的T-Shirt，甚是感谢，一般这种开源技术研讨会都是很开放的。</p>
<p>首先是TOM网的曹刚带来的“浅析系统架构”，主要讲的是Myspace和SOHU社区架构的演变过程，基本的内容可以参考<a href="http://chaoqun.17348.com/2008/09/7-stages-scaling-of-web-apps/" target="_blank">构建可扩展网络应用的七个步骤</a>，一般他们的历程都是从第一步到第四步，大体上差不多，我这里列举这个关键词：</p>
<ul>
<li>64位：Myspace为了让服务器管理更多的内容，操作系统由32位升级到64位，我们都知道32位的操作系统最多支持4G内存（当然有方法可以实现超过4G，不推荐。），64位操作系统理论上支持4G个G，估计我是看不到用完的那天，这里要注意的是32位操作系统下，一个处理器最多处理2G内存，所以如果是Memcached服务器，不要一个进程给超过2G内存，浪费。好的做法是多开几个服务，或者直接把Memcached服务器和APP服务器合二为一，很多公司都这样。</li>
<li>分表：论坛的特点是数据一般是按照板块分组，所以对于论坛这样的应用来说，最好是按照板块ID分表甚至分库分机器。</li>
<li>板块帖子列表页：论坛的特性是新帖子、新更新的帖子排在最前面，所以可能的情况是每次刷新的时候页面都在变，SOHU社区的做法是把板块新帖子保持在一个链表里面，链表的特点是插入和删除都很快，问题是查询的时候只能遍历。
<p>其实对于一个论坛板块来说，热门的帖子不会太多，估计大家也就翻前几页，大可以把这个数据放进缓存中，比如维护一个队列，最新的500个帖子ID，帖子Title，新帖子放在最前面，自动顶掉最后一个，大可以用数组而不用链表，虽然插入的时候慢点，读取的时候却不用遍历链表。</p>
<p>对于跟帖数据，一般都是按照时间顺序排列，新增加的帖子自动在最后，压力不会很大。</li>
<li>google去搜一下<a href="http://www.google.cn/search?q=carp" target="_blank">Carp算法</a>，一致性哈希算法consistent hashing（可以参考<a href="http://tech.idv2.com/2008/08/17/memcached-pdf/" target="_blank">http://tech.idv2.com/2008/08/17/memcached-pdf/</a>），Amazon S3 环形算法（是不是就是consistent hashing?不知）。</li>
</ul>
<p>曹刚最后做了个总结，个人觉得：熟悉业务需求应该是核心。</p>
<p>第二位演讲者是来自占座网的吴炳锡，讲的是LVS和Nginx的负载均衡，这块以前只是从资料上看过，接触比较少，不过炳锡的介绍深入浅出，以前觉得LVS晦涩难懂，不敢动手，听完之后无知者无畏了，有机会试试看去。其实很多事情都这样，看上去挺难，做起来就容易了，下面是几个关键字：</p>
<ul>
<li>DR模式：LVS有NAT、TUN、DR模式，推荐使用DR模式，更多的信息去google吧。</li>
<li>LVS-&gt;Nginx-&gt;Squid：组合的模式，LVS是四层的转发，Nginx是七层的转发，可以支持URL规则的转发，组合起来用就可以随心所欲了。</li>
<li>性能：Nginx的性能和LVS NAT模式相当，都是很好的解决方案，熟悉哪个就用哪个吧，性能都不是问题。</li>
<li><a href="http://www.keepalived.org/" target="_blank">keepalived</a>：LVS居家旅行、杀人灭口必配武器。</li>
<li>搜房网：搜房网前端采用LVS做负载均衡，中间用Nginx做URL负载均衡，动态的URL跳到App服务器，静态的URL跳转到Squid服务器。</li>
</ul>
<p>第三位演讲者来自某个赞助商，感谢他们对活动的赞助，就不做广告了，一句话概括：适合钱多人傻。</p>
<p>第四位演讲者来自SOHU的MySQL DBA叶金荣，报告的内容网上大多有，这里也列出一些关键字：</p>
<ul>
<li>发现问题：系统响应慢、load avg &gt;=5、IO wait &gt;= 10、swap使用情况、mysql status、mysql report、mysql 5.1 profline</li>
<li>xfs：如果可能，mysql数据文件系统分区采用xfs，效果高30％～50％</li>
<li>innodb_buffer_pool_size：如果是专用的数据库服务器，设定为内存的80％吧</li>
<li>MyIsam适合低并发、低更新、高读取的需求，InnoDB适合高并发、高更新、高读取的需求，MyIsam读取的速度比InnoDB快许多。</li>
<li>Explain：查询检查、查询优化</li>
<li>联合索引：貌似MySQL一次查询只用到一个索引，联合索引要注意先后顺序的问题，“左派”比较吃香。</li>
<li>字段按需配置，能用TinyINT的不用INT，字段越短越好，具体差别可以参见：<a href="http://chaoqun.17348.com/2008/11/mysql-data-types-int/" target="_blank">http://chaoqun.17348.com/2008/11/mysql-data-types-int/</a></li>
<li>把大表拆成小表，如果表字段里面有Text，尽量拆开吧。</li>
<li>缩短事务周期</li>
<li>字符型的字段，最好采用前缀索引。</li>
<li>复杂的查询拆成小的简单的查询，比如用循环查询替代。这点不敢苟同，还是按照自己的业务测试一下吧。一条sql语句总比N条要快吧，除非有问题。</li>
<li>left join：把条目数少的放左边，如果你了解left join的话，这个是肯定的。</li>
<li>实时备份：用slave做实时备份吧，一个slave就是一个备份。</li>
</ul>
<p>第五个演讲最为精彩，走了的人实在可惜，掌声和笑声不断，田逸这个家伙说话太有意思的，有机会要认识一下。讲的是CDN方面的事情，关键字：策略，技术很重要，策略更重要。</p>
<p>昨天的网络优化论坛受益匪浅，演讲者都有丰富的经验，其实网站架构就那么点事情，多分享才能共同进步，不过从互动环节可以看出国内做技术的对这方面关注还是比较少，有些问题比较原始，多关注一些就不会那样了。</p>
<p>PS:报告盖茨：我上周四叛逃到Linux了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fuchaoqun.com/2009/01/cu-net-opt-salon/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Sphinx在windows下安装使用[支持中文全文检索]</title>
		<link>http://www.fuchaoqun.com/2008/11/sphinx-on-windows-xp/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=sphinx-on-windows-xp</link>
		<comments>http://www.fuchaoqun.com/2008/11/sphinx-on-windows-xp/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 07:29:23 +0000</pubDate>
		<dc:creator>超群.com</dc:creator>
				<category><![CDATA[Full Text Search]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[默认分类]]></category>
		<category><![CDATA[chinese]]></category>
		<category><![CDATA[sphinx]]></category>

		<guid isPermaLink="false">http://chaoqun.17348.com/?p=106</guid>
		<description><![CDATA[本博客所有原创文章采用知识共享署名-非商业性使用-相同方式共享，转载请保留链接http://chaoqun.17348.com/2008/11/sphinx-on-windows-xp/ 前一阵子尝试使用了一下Sphinx，一个能够被各种语言(PHP/Python/Ruby/etc)方便调用的全文检索系统。网上的资料大多是在linux环境下的安装使用，当然，作为生产环境很有必要部署在*nix环境下，作为学习测试，还是windows环境比较方便些。 本文旨在提供一种便捷的方式让Sphinx在windows下安装配置以支持中文全文检索，配置部分在linux下通用。 一、关于Sphinx Sphinx 是一个在GPLv2 下发布的一个全文检索引擎，商业授权（例如, 嵌入到其他程序中）需要联系作者（Sphinxsearch.com）以获得商业授权。 一般而言，Sphinx是一个独立的搜索引擎，意图为其他应用提供高速、低空间占用、高结果相关度的全文搜索功能。Sphinx可以非常容易的与SQL数据库和脚本语言集成。 当前系统内置MySQL和PostgreSQL 数据库数据源的支持，也支持从标准输入读取特定格式的XML数据。通过修改源代码，用户可以自行增加新的数据源（例如：其他类型的DBMS的原生支持）。 搜索API支持PHP、Python、Perl、Rudy和Java，并且也可以用作MySQL存储引擎。搜索API非常简单，可以在若干个小时之内移植到新的语言上。 Sphinx特性： 高速的建立索引(在当代CPU上，峰值性能可达到10MB/秒); 高性能的搜索(在2–4GB的文本数据上，平均每次检索响应时间小于0.1秒); 可处理海量数据(目前已知可以处理超过100GB的文本数据,在单一CPU的系统上可处理100M文档); 提供了优秀的相关度算法，基于短语相似度和统计（BM25）的复合Ranking方法; 支持分布式搜索; 提供文件的摘录生成; 可作为MySQL的存储引擎提供搜索服务; 支持布尔、短语、词语相似度等多种检索模式; 文档支持多个全文检索字段(最大不超过32个); 文档支持多个额外的属性信息(例如：分组信息，时间戳等); 停止词查询; 支持单一字节编码和UTF-8编码; 原生的MySQL支持(同时支持MyISAM和InnoDB); 原生的PostgreSQL支持. 中文手册可以在这里获得，感谢译者的辛勤工作。 二、Sphinx在windows上的安装 1.直接在http://www.sphinxsearch.com/downloads.html找到最新的windows版本，我这里下的是Win32 release binaries with MySQL support，下载后解压在D:\sphinx目录下； 2.在D:\sphinx\下新建一个data目录用来存放索引文件，一个log目录方日志文件，复制D:\sphinx\sphinx.conf.in到D:\sphinx\bin\sphinx.conf（注意修改文件名）； 3.修改D:\sphinx\bin\sphinx.conf，我这里列出需要修改的几个： type        = mysql # 数据源，我这里是mysql sql_host    = localhost # 数据库服务器 sql_user    = root # 数据库用户名 sql_pass    = '' # 数据库密码 [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>本博客所有原创文章采用<a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"><span style="color: #356aa0;">知识共享署名-非商业性使用-相同方式共享</span></a>，转载请保留链接<a href="http://chaoqun.17348.com/2008/11/sphinx-on-windows-xp/" target="_blank">http://chaoqun.17348.com/2008/11/sphinx-on-windows-xp/</a></p></blockquote>
<p>前一阵子尝试使用了一下Sphinx，一个能够被各种语言(PHP/Python/Ruby/etc)方便调用的全文检索系统。网上的资料大多是在linux环境下的安装使用，当然，作为生产环境很有必要部署在*nix环境下，作为学习测试，还是windows环境比较方便些。</p>
<p>本文旨在提供一种便捷的方式让Sphinx在windows下安装配置以支持中文全文检索，配置部分在linux下通用。</p>
<p>一、关于Sphinx</p>
<p>Sphinx 是一个在GPLv2 下发布的一个全文检索引擎，商业授权（例如, 嵌入到其他程序中）需要联系作者（Sphinxsearch.com）以获得商业授权。</p>
<p>一般而言，Sphinx是一个独立的搜索引擎，意图为其他应用提供高速、低空间占用、高结果相关度的全文搜索功能。Sphinx可以非常容易的与SQL数据库和脚本语言集成。</p>
<p>当前系统内置MySQL和PostgreSQL 数据库数据源的支持，也支持从标准输入读取特定格式的XML数据。通过修改源代码，用户可以自行增加新的数据源（例如：其他类型的DBMS的原生支持）。</p>
<p>搜索API支持PHP、Python、Perl、Rudy和Java，并且也可以用作MySQL存储引擎。搜索API非常简单，可以在若干个小时之内移植到新的语言上。</p>
<p>Sphinx特性：</p>
<ul>
<li>高速的建立索引(在当代CPU上，峰值性能可达到10MB/秒);</li>
<li>高性能的搜索(在2–4GB的文本数据上，平均每次检索响应时间小于0.1秒);</li>
<li>可处理海量数据(目前已知可以处理超过100GB的文本数据,在单一CPU的系统上可处理100M文档);</li>
<li>提供了优秀的相关度算法，基于短语相似度和统计（BM25）的复合Ranking方法;</li>
<li>支持分布式搜索;</li>
<li>
<div id="result_box" style="TEXT-ALIGN: left" dir="ltr">提供文件的摘录生成;</div>
</li>
<li>
<div style="TEXT-ALIGN: left" dir="ltr">可作为MySQL的存储引擎提供搜索服务;</div>
</li>
<li>
<div style="TEXT-ALIGN: left" dir="ltr">支持布尔、短语、词语相似度等多种检索模式;</div>
</li>
<li>
<div style="TEXT-ALIGN: left" dir="ltr">文档支持多个全文检索字段(最大不超过32个);</div>
</li>
<li>
<div style="TEXT-ALIGN: left" dir="ltr">文档支持多个额外的属性信息(例如：分组信息，时间戳等);</div>
</li>
<li>
<div style="TEXT-ALIGN: left" dir="ltr">停止词查询;</div>
</li>
<li>
<div style="TEXT-ALIGN: left" dir="ltr">支持单一字节编码和UTF-8编码;</div>
</li>
<li>
<div style="TEXT-ALIGN: left" dir="ltr">原生的MySQL支持(同时支持MyISAM和InnoDB);</div>
</li>
<li>
<div style="TEXT-ALIGN: left" dir="ltr">原生的PostgreSQL支持.</div>
</li>
</ul>
<p style="TEXT-ALIGN: left" dir="ltr">中文手册可以在<a href="http://www.coreseek.com/uploads/pdf/sphinx_doc_zhcn_0.9.pdf" target="_blank">这里</a>获得，感谢<a href="http://www.coreseek.com" target="_blank">译者</a>的辛勤工作。</p>
<p style="TEXT-ALIGN: left" dir="ltr">二、Sphinx在windows上的安装</p>
<p style="TEXT-ALIGN: left" dir="ltr">1.直接在<a href="http://www.sphinxsearch.com/downloads.html" target="_blank">http://www.sphinxsearch.com/downloads.html</a>找到最新的windows版本，我这里下的是<a href="http://www.sphinxsearch.com/downloads/sphinx-0.9.8.1-win32.zip" target="_blank">Win32 release binaries with MySQL support</a>，下载后解压在D:\sphinx目录下；</p>
<p style="TEXT-ALIGN: left" dir="ltr">2.在D:\sphinx\下新建一个data目录用来存放索引文件，一个log目录方日志文件，复制D:\sphinx\sphinx.conf.in到D:\sphinx\bin\sphinx.conf（注意修改文件名）；</p>
<p style="TEXT-ALIGN: left" dir="ltr">3.修改D:\sphinx\bin\sphinx.conf，我这里列出需要修改的几个：</p>
<blockquote>
<pre style="TEXT-ALIGN: left" dir="ltr">type        = mysql # 数据源，我这里是mysql
sql_host    = localhost # 数据库服务器
sql_user    = root # 数据库用户名
sql_pass    = '' # 数据库密码
sql_db      = test # 数据库
sql_port    = 3306 # 数据库端口</pre>
<pre style="TEXT-ALIGN: left" dir="ltr">sql_query_pre   = SET NAMES utf8 # 去掉此行前面的注释，如果你的数据库是uft8编码的</pre>
<pre style="TEXT-ALIGN: left" dir="ltr">index test1
{
# 放索引的目录
 path   = D:/sphinx/data/
# 编码
 charset_type  = utf-8
 #  指定utf-8的编码表
 charset_table  = 0..9, A..Z-&gt;a..z, _, a..z, U+410..U+42F-&gt;U+430..U+44F, U+430..U+44F
 # 简单分词，只支持0和1，如果要搜索中文，请指定为1
 ngram_len    = 1
# 需要分词的字符，如果要搜索中文，去掉前面的注释
 ngram_chars   = U+3000..U+2FA1F
}</pre>
<pre style="TEXT-ALIGN: left" dir="ltr"># index test1stemmed : test1
# {
 # path   = @CONFDIR@/data/test1stemmed
 # morphology  = stem_en
# }

# 如果没有分布式索引，注释掉下面的内容

# index dist1
# {
 # 'distributed' index type MUST be specified
 # type    = distributed</pre>
<pre style="TEXT-ALIGN: left" dir="ltr"> # local index to be searched
 # there can be many local indexes configured
 # local    = test1
 # local    = test1stemmed</pre>
<pre style="TEXT-ALIGN: left" dir="ltr"> # remote agent
 # multiple remote agents may be specified
 # syntax is 'hostname:port:index1,[index2[,...]]
 # agent    = localhost:3313:remote1
 # agent    = localhost:3314:remote2,remote3</pre>
<pre style="TEXT-ALIGN: left" dir="ltr"> # remote agent connection timeout, milliseconds
 # optional, default is 1000 ms, ie. 1 sec
 # agent_connect_timeout = 1000</pre>
<pre style="TEXT-ALIGN: left" dir="ltr"> # remote agent query timeout, milliseconds
 # optional, default is 3000 ms, ie. 3 sec
 # agent_query_timeout  = 3000
# }</pre>
<pre style="TEXT-ALIGN: left" dir="ltr"># 搜索服务需要修改的部分
searchd
{
 # 日志
 log     = D:/sphinx/log/searchd.log</pre>
<pre style="TEXT-ALIGN: left" dir="ltr"> # PID file, searchd process ID file name
 pid_file   = D:/sphinx/log/searchd.pid</pre>
<pre style="TEXT-ALIGN: left" dir="ltr"> # windows下启动searchd服务一定要注释掉这个
 # seamless_rotate  = 1
}</pre>
</blockquote>
<p>4.导入测试数据</p>
<p>C:\Program Files\MySQL\MySQL Server 5.0\bin&gt;mysql -uroot test&lt;d:/sphinx/example.sql</p>
<p>5.建立索引</p>
<blockquote><p>D:\sphinx\bin&gt;indexer.exe &#8211;all<br />
Sphinx 0.9.8-release (r1533)<br />
Copyright (c) 2001-2008, Andrew Aksyonoff</p>
<p>using config file &#8216;./sphinx.conf&#8217;&#8230;<br />
indexing index &#8216;test1&#8242;&#8230;<br />
collected 4 docs, 0.0 MB<br />
sorted 0.0 Mhits, 100.0% done<br />
total 4 docs, 193 bytes<br />
total 0.101 sec, 1916.30 bytes/sec, 39.72 docs/sec</p>
<p>D:\sphinx\bin&gt;</p></blockquote>
<p>6.搜索&#8217;test&#8217;试试</p>
<blockquote><p>D:\sphinx\bin&gt;search.exe test<br />
Sphinx 0.9.8-release (r1533)<br />
Copyright (c) 2001-2008, Andrew Aksyonoff</p>
<p>using config file &#8216;./sphinx.conf&#8217;&#8230;<br />
index &#8216;test1&#8242;: query &#8216;test &#8216;: returned 3 matches of 3 total in 0.000 sec</p>
<p>displaying matches:<br />
1. document=1, weight=2, group_id=1, date_added=Wed Nov 26 14:58:59 2008<br />
        id=1<br />
        group_id=1<br />
        group_id2=5<br />
        date_added=2008-11-26 14:58:59<br />
        title=test one<br />
        content=this is my test document number one. also checking search within<br />
 phrases.<br />
2. document=2, weight=2, group_id=1, date_added=Wed Nov 26 14:58:59 2008<br />
        id=2<br />
        group_id=1<br />
        group_id2=6<br />
        date_added=2008-11-26 14:58:59<br />
        title=test two<br />
        content=this is my test document number two<br />
3. document=4, weight=1, group_id=2, date_added=Wed Nov 26 14:58:59 2008<br />
        id=4<br />
        group_id=2<br />
        group_id2=8<br />
        date_added=2008-11-26 14:58:59<br />
        title=doc number four<br />
        content=this is to test groups</p>
<p>words:<br />
1. &#8216;test&#8217;: 3 documents, 5 hits<br />
D:\sphinx\bin&gt;</p></blockquote>
<p>都所出来了吧。</p>
<p>6.测试中文搜索</p>
<p>修改test数据库中documents数据表，</p>
<blockquote><p>UPDATE `test`.`documents` SET `title` = &#8216;测试中文&#8217;, `content` = &#8216;this is my test document number two，应该搜的到吧&#8217; WHERE `documents`.`id` = 2;</p></blockquote>
<p>重建索引：</p>
<p>D:\sphinx\bin&gt;indexer.exe &#8211;all</p>
<p>搜索&#8217;中文&#8217;试试：</p>
<blockquote><p>D:\sphinx\bin&gt;search.exe 中文<br />
Sphinx 0.9.8-release (r1533)<br />
Copyright (c) 2001-2008, Andrew Aksyonoff</p>
<p>using config file &#8216;./sphinx.conf&#8217;&#8230;<br />
index &#8216;test1&#8242;: query &#8216;中文 &#8216;: returned 0 matches of 0 total in 0.000 sec</p>
<p>words:<br />
D:\sphinx\bin&gt;</p></blockquote>
<p>貌似没有搜到，这是因为windows命令行中的编码是gbk，当然搜不出来。我们可以用程序试试，在D:\sphinx\api下新建一个foo.php的文件，注意utf-8编码</p>
<blockquote><p>&lt;?php<br />
require &#8216;sphinxapi.php&#8217;;<br />
$s = new SphinxClient();<br />
$s-&gt;SetServer(&#8216;localhost&#8217;,3312);<br />
$result = $s-&gt;Query(&#8216;中文&#8217;);<br />
var_dump($result);<br />
?&gt;</p></blockquote>
<p>启动Sphinx searchd服务</p>
<blockquote><p>D:\sphinx\bin&gt;searchd.exe<br />
Sphinx 0.9.8-release (r1533)<br />
Copyright (c) 2001-2008, Andrew Aksyonoff</p>
<p>WARNING: forcing &#8211;console mode on Windows<br />
using config file &#8216;./sphinx.conf&#8217;&#8230;<br />
creating server socket on 0.0.0.0:3312<br />
accepting connections</p></blockquote>
<p>执行PHP查询：</p>
<blockquote><p>php d:/sphinx/api/foo.php</p></blockquote>
<p>结果是不是出来？剩下的工作就是去看手册，慢慢摸索高阶的配置。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fuchaoqun.com/2008/11/sphinx-on-windows-xp/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>OpenSlopeOne: An Open Source Project implementing Slope One in PHP&amp;MySQL</title>
		<link>http://www.fuchaoqun.com/2008/09/openslopeone-open-source-php-mysql/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=openslopeone-open-source-php-mysql</link>
		<comments>http://www.fuchaoqun.com/2008/09/openslopeone-open-source-php-mysql/#comments</comments>
		<pubDate>Fri, 12 Sep 2008 15:37:34 +0000</pubDate>
		<dc:creator>超群.com</dc:creator>
				<category><![CDATA[Data Mining]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Collaborative filtering]]></category>
		<category><![CDATA[openslopeone]]></category>
		<category><![CDATA[slope one]]></category>

		<guid isPermaLink="false">http://chaoqun.17348.com/?p=68</guid>
		<description><![CDATA[About OpenSlopeOne OpenSlopeOne is an implementation of Slope One based on PHP&#38;MySQL, it&#8217;s an open source project under GPL V3. It aims to a fast way to use Slope One with PHP&#38;MySQL, and it can handle tons of data. It&#8217;s localed on Google Code:     http://code.google.com/p/openslopeone/ You can get the latest code here:     svn [...]]]></description>
			<content:encoded><![CDATA[<p><strong>About OpenSlopeOne</strong></p>
<p>OpenSlopeOne is an implementation of Slope One based on PHP&amp;MySQL, it&#8217;s an open source project under GPL V3.</p>
<p>It aims to a fast way to use Slope One with PHP&amp;MySQL, and it can handle tons of data.</p>
<p>It&#8217;s localed on Google Code:</p>
<p>    <a href="http://code.google.com/p/openslopeone/" target="_blank">http://code.google.com/p/openslopeone/</a></p>
<p>You can get the latest code here:</p>
<p>    svn checkout https://openslopeone.googlecode.com/svn/trunk/openslopeone</p>
<p>it uses Zend_Db as its database layer.PHP5&amp;MySQL5 or higher.</p>
<p><strong>About Slope One</strong></p>
<p>Slope One is a family of algorithms used for <a href="http://en.wikipedia.org/wiki/Collaborative_filtering" target="_blank">Collaborative filtering</a> introduced in Slope One Predictors for Online Rating-Based Collaborative Filtering by <a href="http://www.daniel-lemire.com/fr/abstracts/SDM2005.html" target="_blank">Daniel Lemire</a> and Anna Maclachlan.</p>
<p>You can check <a href="http://en.wikipedia.org/wiki/Slope_One" target="_blank">http://en.wikipedia.org/wiki/Slope_One</a> to know more about Slope One.</p>
<p><strong>What&#8217;s the difference between OpenSlopeOne and Vogoo?</strong></p>
<p>As you know,there is also another implementation of Slope One based on PHP&amp;MySQL:<a href="http://sourceforge.net/projects/vogoo" target="_blank">Vogoo</a></p>
<p>What&#8217;s the difference?</p>
<p>OpenSlopeOne aims to a fast way to use Slope One with PHP&amp;MySQL, so it cares more about performance.</p>
<p>OpenSlopeOne has two modes to init the slope one table, one is based on pure PHP, the other is based on MySQL procedure, as you know, it will be much faster, and you can use it with any other programming language.</p>
<p>the bottleneck of Vogoo(read the source code of cronslope.php Line 70~Line 150, version 2.2) is to check whether the record exits or not. If there is tons of data, the performance is very bad.</p>
<p>In OpenSlopeOne, first I get distinct item ids, then foreach item id, i calculate the slope one of it. I do not have to check whether if it exits, and i am faster.</p>
<p><strong>Installation</strong></p>
<p>1. Modify the config ini file: config.ini.php</p>
<p>   ; &lt;?php exit; ?&gt; DO NOT REMOVE THIS LINE<br />
   [database]<br />
   host                 = localhost ; database host name or ip<br />
   username             = root      ; database user name<br />
   password             =           ; user password<br />
   dbname               =           ; database name<br />
   port                 = 3306      ; database host port,3306 as default<br />
   adapter              = PDO_MYSQL ; PDO_MYSQL or MYSQLI</p>
<p>2. Create user&#8217;s rating table:</p>
<p>    CREATE TABLE IF NOT EXISTS `oso_user_ratings` (<br />
      `user_id` int(11) NOT NULL,<br />
      `item_id` int(11) NOT NULL,<br />
      `rating` decimal(14,4) NOT NULL default &#8217;0.0000&#8242;,<br />
      KEY `item_id` (`item_id`),<br />
      KEY `user_id` (`user_id`,`item_id`)<br />
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;</p>
<p>there is a sample data file:sample.data, you can load it into the table</p>
<p>    load data infile &#8216;sample.data&#8217; into table oso_user_ratings;</p>
<p>3. Create slope one table:</p>
<p>    CREATE TABLE IF NOT EXISTS `oso_slope_one` (<br />
      `item_id1` int(11) NOT NULL,<br />
      `item_id2` int(11) NOT NULL,<br />
      `times` int(11) NOT NULL,<br />
      `rating` decimal(14,4) NOT NULL<br />
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;</p>
<p><strong>Usage<br />
</strong><br />
The main also the only PHP file is OpenSlopeOne.php, you must include it in your own PHP file:</p>
<p>    require &#8216;./OpenSlopeOne.php&#8217;;</p>
<p>    $openslopeone = new OpenSlopeOne();</p>
<p>1. Init the slope one table:</p>
<p>before you get the recommendtion, you must pre-computation the slope one table.</p>
<p>    $openslopeone-&gt;initSlopeOneTable($factory);</p>
<p>you can specify the mode use &#8216;PHP&#8217; or &#8216;MySQL&#8217;,If you user &#8216;PHP&#8217; mode, it&#8217;s a pure php implementation, and it might be very slow when there is tons of data.You can also use &#8216;MySQL&#8217; mode, it&#8217;s based on mysql procedure, and it will be mutch faster.</p>
<p>If you have tons of data to pre-computation, a good advice is that you do not index any colum on oso_slope_one before it done.</p>
<p>2. Get recommended items by item&#8217;s id</p>
<p>    $recommendedItems = $openslopeone-&gt;getRecommendedItemsById(9527);</p>
<p>3. Get recommended items by user&#8217;s id</p>
<p>    $recommendedItems = $openslopeone-&gt;getRecommendedItemsByUser(30002);<br />
<strong>About Author</strong></p>
<p>I am a PHP programmer in China, my blog:http://chaoqun.17348.com, mostly written in Chinese.</p>
<p>You can contack me with gtalk or mail:fuchaoqun@gmail.com</p>
<p>Welcom to any bug and advice.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fuchaoqun.com/2008/09/openslopeone-open-source-php-mysql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Slope one:简单高效的推荐算法</title>
		<link>http://www.fuchaoqun.com/2008/09/slope_one/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=slope_one</link>
		<comments>http://www.fuchaoqun.com/2008/09/slope_one/#comments</comments>
		<pubDate>Tue, 02 Sep 2008 16:05:10 +0000</pubDate>
		<dc:creator>超群.com</dc:creator>
				<category><![CDATA[Data Mining]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Collaborative]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[filtering]]></category>
		<category><![CDATA[mining]]></category>
		<category><![CDATA[one]]></category>
		<category><![CDATA[slope]]></category>

		<guid isPermaLink="false">http://chaoqun.17348.com/?p=57</guid>
		<description><![CDATA[本博客所有原创文章采用知识共享署名-非商业性使用-相同方式共享，转载请保留链接http://chaoqun.17348.com/2008/09/slope_one/ 推荐系统最早在亚马逊的网站上应用，根据以往用户的购买行为，推荐出购买某种产品同时可能购买的其他产品，国内做的不错的当当网,有时候买书，它总能给我推荐出我感兴趣的其他书来，也算是技术极大的促进了销售。 一般的协同过滤算法，首先是收集用户对事物（产品）的评分情况，一种直接对某本书，或者某个歌曲打分，另种是隐性的打分，比如商务系统中，购买了表示打2分，浏览了打1分，其他的0分。我比较看好隐性打分，因为直接打分需要用户的参与程度比较高，很多网站都在内容页中留一个打分的按钮，从1～5选一个，我可能喜欢这篇文章，可我哪里知道我喜欢的程度是几分啊，还要我去思考，而网站设计中一条很重要的原则是:Do not let me think!，于是我就胡打一个分数或者不打，而隐性的打分则不同，只有你喜欢的图书你才会购买，只有你喜欢的歌曲才会听多次。 收集好用户的打分之后，通过最近邻搜索到和某个事物或者某个人特征或者兴趣相近的其他事物或者人，最近邻搜索算法一般是皮尔森相关系数（Person Correlation Coefficient）、余弦相似性（Cosine-based Similarity）以及调整余弦相似性（Adjusted Cosine Similarity）。关于余弦定理在数据挖掘中的应用，google黑白报有过介绍，可以参考数学之美 系列 12 &#8211; 余弦定理和新闻的分类。 剩下的工作就是根据最近邻集进行推荐了。 最近邻集的运算相对来说成本比较高，尤其是大量数据的时候，今天和大家分享的是一种简单高效的协同过滤算法：Slope one 基本原理 用户          对事物A打分 对事物B打分 X 3 4 Y 2 4 Z 4 ? 用户Z对事物B的打分可能是多少呢？股票上有个说法是平均值可以掩盖一切异常波动，所以股票上的各个技术指标收拾不同时间段的平均值的曲线图或者柱状图等。同样的，Slope one算法也认为：平均值也可以代替某两个未知个体之间的打分差异，事物A对事物B的平均很差是：((3 &#8211; 4) + (2 &#8211; 4)) / 2 = -1.5，也就是说人们对事物B的打分一般比事物A的打分要高1.5，于是Slope one算法就猜测Z对事物B的打分是4 + 1.5 = 5.5 是不是非常的简单？ 加权算法 有n个人对事物A和事物B打分了，R(A-&#62;B)表示这n个人对A和对B打分的平均差（A-B）,有m个人对事物B和事物C打分了，R（C-&#62;B）表示这m个人对C和对B打分的平均差（C-B），注意都是平均差而不是平方差，现在某个用户对A的打分是ra，对C的打分是rc，那么A对B的打分可能是： rb = [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>本博客所有原创文章采用<a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"><span style="color: #356aa0;">知识共享署名-非商业性使用-相同方式共享</span></a>，转载请保留链接<a href="http://chaoqun.17348.com/2008/09/slope_one/"><span style="color: #356aa0;">http://chaoqun.17348.com/2008/09/slope_one/</span></a></p></blockquote>
<p>推荐系统最早在<a href="http://www.amazon.com/" target="_blank">亚马逊</a>的网站上应用，根据以往用户的购买行为，推荐出购买某种产品同时可能购买的其他产品，国内做的不错的<a href="http://www.dangdang.com" target="_blank">当当网</a>,有时候买书，它总能给我推荐出我感兴趣的其他书来，也算是技术极大的促进了销售。</p>
<p>一般的协同过滤算法，首先是收集用户对事物（产品）的评分情况，一种直接对某本书，或者某个歌曲打分，另种是隐性的打分，比如商务系统中，购买了表示打2分，浏览了打1分，其他的0分。我比较看好隐性打分，因为直接打分需要用户的参与程度比较高，很多网站都在内容页中留一个打分的按钮，从1～5选一个，我可能喜欢这篇文章，可我哪里知道我喜欢的程度是几分啊，还要我去思考，而网站设计中一条很重要的原则是:Do not let me think!，于是我就胡打一个分数或者不打，而隐性的打分则不同，只有你喜欢的图书你才会购买，只有你喜欢的歌曲才会听多次。</p>
<p>收集好用户的打分之后，通过最近邻搜索到和某个事物或者某个人特征或者兴趣相近的其他事物或者人，最近邻搜索算法一般是皮尔森相关系数（<a href="http://en.wikipedia.org/wiki/Correlation" target="_blank">Person Correlation Coefficient</a>）、余弦相似性（<a href="http://www10.org/cdrom/papers/519/node12.html" target="_blank">Cosine-based Similarity</a>）以及调整余弦相似性（<a href="http://www10.org/cdrom/papers/519/node14.html" target="_blank">Adjusted Cosine Similarity</a>）。关于余弦定理在数据挖掘中的应用，google黑白报有过介绍，可以参考<a href="http://www.googlechinablog.com/2006/07/12.html" target="_blank">数学之美 系列 12 &#8211; 余弦定理和新闻的分类</a>。</p>
<p>剩下的工作就是根据最近邻集进行推荐了。</p>
<p>最近邻集的运算相对来说成本比较高，尤其是大量数据的时候，今天和大家分享的是一种简单高效的协同过滤算法：<a href="http://en.wikipedia.org/wiki/Slope_One" target="_blank">Slope one</a></p>
<p><strong>基本原理</strong></p>
<blockquote>
<table style="width: 300px; height: 184px;" border="0">
<tbody>
<tr>
<td><strong>用户          </strong></td>
<td><strong>对事物A打分</strong></td>
<td><strong>对事物B打分</strong></td>
</tr>
<tr>
<td><strong>X</strong></td>
<td><strong>3</strong></td>
<td><strong>4</strong></td>
</tr>
<tr>
<td><strong>Y</strong></td>
<td><strong>2</strong></td>
<td><strong>4</strong></td>
</tr>
<tr>
<td><strong>Z</strong></td>
<td><strong>4</strong></td>
<td><strong>?</strong></td>
</tr>
</tbody>
</table>
</blockquote>
<p>用户Z对事物B的打分可能是多少呢？股票上有个说法是平均值可以掩盖一切异常波动，所以股票上的各个技术指标收拾不同时间段的平均值的曲线图或者柱状图等。同样的，Slope one算法也认为：平均值也可以代替某两个未知个体之间的打分差异，事物A对事物B的平均很差是：((3 &#8211; 4) + (2 &#8211; 4)) / 2 = -1.5，也就是说人们对事物B的打分一般比事物A的打分要高1.5，于是Slope one算法就猜测Z对事物B的打分是4 + 1.5 = 5.5</p>
<p>是不是非常的简单？</p>
<p><strong>加权算法</strong></p>
<p>有n个人对事物A和事物B打分了，R(A-&gt;B)表示这n个人对A和对B打分的平均差（A-B）,有m个人对事物B和事物C打分了，R（C-&gt;B）表示这m个人对C和对B打分的平均差（C-B），注意都是平均差而不是平方差，现在某个用户对A的打分是ra，对C的打分是rc，那么A对B的打分可能是：</p>
<p><strong>rb = (n * (ra &#8211; R(A-&gt;B)) + m * (rc - R(C-&gt;B)))/(m+n)</strong></p>
<p>开源的Slope one的程序包</p>
<ul>
<li>Python
<p><a href="http://www.serpentine.com/blog/2006/12/12/collaborative-filtering-made-easy/" target="_blank">http://www.serpentine.com/blog/2006/12/12/collaborative-filtering-made-easy/</a></li>
<li>Java
<p><a href="http://taste.sourceforge.net/" target="_blank">http://taste.sourceforge.net/</a></p>
<p><a href="http://www.daniel-lemire.com/fr/documents/publications/SlopeOne.java" target="_blank">http://www.daniel-lemire.com/fr/documents/publications/SlopeOne.java</a></p>
<p><a href="http://www.nongnu.org/cofi/" target="_blank">http://www.nongnu.org/cofi/</a></li>
<li>PHP
<p><a href="http://sourceforge.net/projects/vogoo" target="_blank">http://sourceforge.net/projects/vogoo</a></p>
<p><a href="http://www.drupal.org/project/cre" target="_blank">http://www.drupal.org/project/cre</a></p>
<p><a href="http://www.daniel-lemire.com/fr/documents/publications/webpaper.txt" target="_blank">http://www.daniel-lemire.com/fr/documents/publications/webpaper.txt</a> Slope one算法作者写的，简单明了，强烈推荐。</li>
<li>Erlang<br />
<a href="http://chlorophil.blogspot.com/2007/06/collaborative-filtering-weighted-slope.html" target="_blank">http://chlorophil.blogspot.com/2007/06/collaborative-filtering-weighted-slope.html</a></li>
<li>C#<br />
<a href="http://www.cnblogs.com/kuber/articles/SlopeOne_CSharp.html" target="_blank">http://www.cnblogs.com/kuber/articles/SlopeOne_CSharp.html</a> 国人写的C#版本</li>
<li>T-SQL<br />
<a href="http://blog.charliezhu.com/2008/07/21/implementing-slope-one-in-t-sql/" target="_blank">http://blog.charliezhu.com/2008/07/21/implementing-slope-one-in-t-sql/</a></li>
</ul>
<p>还有一些其他语言的版本，请参考<a href="http://en.wikipedia.org/wiki/Slope_One" target="_blank">http://en.wikipedia.org/wiki/Slope_One</a>，即将面世的，居于PHP &amp; Mysql的Slope one算法实现将会在<a href="http://code.google.com/p/openslopeone/" target="_blank">http://code.google.com/p/openslopeone/</a>开源出来，主要优化的是海量数据以及分布式处理，目前在我的笔记本上（迅驰＋1.5G内存），对440W打分记录进行测试，单一线程，3小时47分处理完。速度还算是不错了，最近工作实在太忙了，等我整理好会开源出来放在上面的地址。过几天会有一篇我的算法的详细介绍，盼诸位批评指正，共同学习，共同进步。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fuchaoqun.com/2008/09/slope_one/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->