linux递归删除文件夹

If you want remove directory named “.svn” under basedir recutively, you can use the command, find basedir -name .svn |xargs rm -rf 作者:豆博草堂

June 14, 2011 · 1 min · Space

mysql 数据热备份

http://www.fengfly.com/plus/view-28380-1.html http://www.koven.org/archives/203.html

June 14, 2011 · 1 min · Space

MySQL中文问题

 今天花了一个晚上终于解决了MySQL中中文插入显示问题,当然少不了Google的帮忙:)把解决方法写出来以供参考。 现象: 用JDBC将中文字段插入MySQL数据库中,然后打开表发现,那些字段都是"??".用java做出select方法进行select后也是"??". 原因: 1.创建数据库时没有指定默认的编码方式,导致数据库使用了MySql的默认字符集latin1。 2.Client端字符集为latin1. 3.进行jdbc链接时使用了不匹配的字符集。 解决办法: 1.创建数据库时将数据库的缺省字符集指定为utf8。sql: create database dbname DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; 2.修改Client默认字符集为utf8。windows下在mysql安装目录下找到my.ini(linux下,mysql的配置一般是/etc/my.conf,其中的datadir指明了数据存储目录。),将里面的default-character-set=latin1 改为default-character-set=UTF8,然后重起mysql服务即可将数据库默认字符集改为utf8.此时应该在mysql命令行用s命令检查一下看是否改好了。 3.修改jdbc的链接,将原来的 jdbc:mysql://localhost:3306/YourDb 改为 jdbc:mysql://localhost:3306/YourDb?useUnicode=true& characterEncoding=UTF-8 做完以上工作后,插入到mysql的中文应该不会再是乱码了. 作者:豆博草堂

June 14, 2011 · 1 min · Space

MySQL最大连接数设置

客户端登录:mysql -uusername -ppassword 设置新的最大连接数为200:mysql> set GLOBAL max_connections=200 显示当前运行的Query:mysql> show processlist 显示当前状态:mysql> show status 退出客户端:mysql> exit 查看当前最大连接数:mysqladmin -uusername -ppassword variables |find “max_con”

June 14, 2011 · 1 min · Space

mysql表结构修改命令

/主键 alter table tabelname add new_field_id int(5) unsigned default 0 not null auto_increment ,add primary key (new_field_id); //增加一个新列 alter table t2 add d timestamp; alter table infos add ex tinyint not null default ‘0’; //删除列 alter table t2 drop column c; //重命名列 alter table t1 change a b integer; //改变列的类型 alter table t1 change b b bigint not null; alter table infos change list list tinyint not null default ‘0’; ...

June 14, 2011 · 1 min · Space

n-Gram splitter

While we process chinese, we need to split chinese sentences into chinaese words,a statistical algorithm is N-Gram split algorithm, which needn’t dictionary. 2-gram is very easy to implemente,but the algorithm becomes complex while n > 2. Now, I have implemented the prototype of 2-gram, I will implement the algorithm n-gram while n >2 and HMM algorithm.These algorithms are very useful on finding new words. Oyeah!

June 14, 2011 · 1 min · Space

n-gram 分词程序

经过一个月的开发,我的N-gram程序终于可以进行分词了,虽然由于语料库太小导致统计数据不足,分词效果不是很理想,但至少我终于从零开始完成了这个程序的开发,开发了分词程序的基本模块,包括语料预处理,分解,词典管理,从语料中统计信息,分词等功能。通过开发,我终于初步明白了数据挖掘、自然语言处理、搜索技术中数据处理所面临的一些问题,也明白了自己努力的方向。在大语料方面,我自己开发了一个小方案,但效率却比较低。 春节,也许还会有新的进展,特别是大语料的处理还需要进一步优化。 2010-10-18:今天找出了以前的代码,上传到了 http://idocbox.googlecode.com/files/xSpliter-0.1.zip 供大家了解一些简单的原理。 注意,我的代码是5年前写的,现在看,这个代码有很多问题的。所以,大家就当我献丑了,仅仅学习下就可以。 **用法:**下载完了,把代码解压后的工程导入到eclipse, 通过执行里面的单元测试来了解统计、建统计词典、分词的过程。 有问题欢迎交流,如果我有时间,我会写一个分布式、更加智能、灵活、高效的算法实现给大家的。 作者:豆博草堂

June 14, 2011 · 1 min · Space

N-Gram转移概率计算中的若干问题

这几天晚上,我对2-gram时计算词的转移概率的程序进行了优化,现在已经可以在100秒内完成30000多字的文本的预处理到并计算词长1到4时的转移概率了。当得到这样的测试结果时,自己竟兴奋的久久不能关机入睡眨眼:) 在优化过程中,主要是避免不必要得重复查找,对一些词的查找采用了新的算法,还有就是,log输出实际耗费了大量资源,将log级别设置到error级,可以减少大量的IO操作。 虽然100秒处理30000多字在时间上可以接受,但那夜在仔细研究后发现,还有较大的优化空间可以提高计算速度。我已经想到一个方法,正在考虑如何较好地实现它。 为了试验程序在处理较大的语料文本时的速度,我将文本提高到了23万多字,但问题出现了,程序出现了OutOfMemory错误,是创建对象时Heap中空间不足。对这种问题一种办法是在虚拟机中添加参数[-Xms 128m -Xmx 256m]来增大堆内存,但这种做法却不能解决根本问题,当要处理的数据再大一些,比如200万字,还是有可能再次出现OutOfMemory错误的。根本的解决办法是设计新方案,对大文本进行特殊处理,具体方案正在设计之中。 现在还有一个问题需要解决,当语料库增加新的预料时(语料减少时需要重新计算),如何增量计算?这里面有较多的细节需要处理。

June 14, 2011 · 1 min · Space

platform

Platform is a product engine, its owner would effect product trends. Microsoft’s windows and Linux/Unix are platforms based on personal computer, Google, Facebook and Live.com have been developing their own platform based on internet. If you have been used google search engine, google earth, google doc, gmail, reader, map etc, you may find there have many API supplied with these products, which can be used to develop your own products,for example, you can develop a guide system based on google earth. These products and API can be viewed as platforms. Platform is a great thing, which can be used to improve the power and efficiency of developer, also the manufacturer’s power in market. ...

June 14, 2011 · 1 min · Space

python解析xml

import xml.parsers.expat level = 0 def start_element(name, attrs): global level print ’ ’ * level, ‘Start element:’, name, attrs level = level + 1 def end_element(name): global level level = level - 1 print ’ ’ * level, ‘End element:’, name def char_data(data): if(data == ’n’): return if(data.isspace()): return global level print ’ ’ * level, ‘Character data:’, data if __name__ == “__main__”: p = xml.parsers.expat.ParserCreate() p.StartElementHandler = start_element p.EndElementHandler = end_element p.CharacterDataHandler = char_data p.returns_unicode = False ...

June 14, 2011 · 1 min · Space