CityHelper是一个提供国家,省,市选择框的小插件,这次更新增加了国家和国际化支持,目前只支持简体中文和英语。 安装 $ script/plugin install git://github.com/yzhang/city_helper.git 这会在你的config/locales目录下安装一个cities目录,这个目录包含了i18n的信息,还会在config/initializers目录增加一个city_helper.rb来设置i18n的加载目录。 使用 country_select(:user, :country, { :only => [:china], # 指定要显示的国家 :update => ‘state_select_id’, # 指定国家改变后要更新的省份选择框的id }, html_options) state_select(:user, :state, { :country => :china, # 指定默认显示那个国家的省份 :countries => [:china], # 只有在country_select中设置了update属性时才需设置这个属性 # 这个属性应该与country_select中的:only属性保持一致 :update => ‘city_select_id’, # 指定省份变动时要更新的城市选择框ID }, html_options) city_select(:user, :city, { [...]
Monthly Archives: December 2009
Rseg: 纯Ruby中文分词插件
Rseg是一个基于纯Ruby的中文分词插件,内置了CC-CEDICT和维基百科两本字典,目前只支持Ruby 187以上版本及UTF8编码。 项目地址:http://github.com/yzhang/rseg 分词算法:http://xiecc.blog.163.com/blog/static/14032200671110224190/ 安装 sudo gem install rseg –source=http://gemcutter.org 使用 Rseg目前支持两种用法,本地调用或者C/S模式调用。 1. 本地调用 > require ‘rubygems’ > require ‘rseg’ > Rseg.segment(“需要分词的文章”) ['需要', '分词', '的', '文章'] 第一次执行需要加载字典,大概需要30秒,不过你也可以调用Rseg#load来手动加载字典。 2. C/S方式 $ rseg_server 这条命令会监听4100端口,你可以通过http://localhost:4100/ 访问Web界面,也可以通过rseg命令远程调用: $ rseg ‘需要分词的文章’ 需要 分词 的 文章 还可以调用Rseg#remote_segment > require ‘rubygems’ > require ‘rseg’ > RSeg.remote_segment(“需要分词的文章”) ['需要', '分词', '的', '文章'] 这次就不需要加载字典了。 性能 [...]
Posted in 其它 5 Comments
