Skip to content

Commit e594c48

Browse files
committed
add 3blog
1 parent b26005f commit e594c48

File tree

4 files changed

+186
-1
lines changed

4 files changed

+186
-1
lines changed
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# 使用Postgresql进行中文分词
2+
> 2017年11月19日 23:05:37
3+
4+
# 使用Postgresql进行中文分词
5+
6+
## 安装 postgresql 数据库
7+
8+
### 解压
9+
```
10+
tar -zxvf postgresql-9.6.6.tar.gz
11+
```
12+
### 配置
13+
```
14+
./configure
15+
```
16+
### 可能会缺少这个依赖,安装readline开发包
17+
```
18+
yum install readline-devel
19+
```
20+
## 编译
21+
```
22+
make
23+
```
24+
## 安装
25+
```
26+
make install
27+
```
28+
## 添加postgres用户并加入到postgres用户组
29+
```
30+
groupadd postgres
31+
useradd -g postgres postgres
32+
```
33+
## 创建数据目录
34+
```
35+
mkdir -p /data/pgdata/
36+
```
37+
## 添加环境变量
38+
在/etc/profile中添加
39+
```
40+
export PATH=/usr/local/pgsql/bin:$PATH
41+
```
42+
43+
刷新配置文件,使之立即生效
44+
```
45+
source /etc/profile
46+
```
47+
### 修改数据目录和pg程序目录的权限
48+
```
49+
chown postgres:postgres /data/pgdata/
50+
chown postgres:postgres /usr/local/pgsql/
51+
```
52+
### 初始化数据库
53+
```
54+
su - postgres
55+
/usr/local/pgsql/bin/initdb -D /data/pgdata/
56+
```
57+
### 添加postgresql到系统服务
58+
```
59+
vim postgresql-9.6.6/contrib/start-scripts/linux
60+
PGDATA="/data/pgdata/"
61+
chmod a+x postgresql-9.6.6/contrib/start-scripts/linux
62+
cp postgresql-9.6.6/contrib/start-scripts/linux /etc/init.d/postgresql
63+
```
64+
### 用系统服务的方式启动postgresql
65+
```
66+
service postgresql start
67+
```
68+
#### 查看postgresql的端口起来了没有
69+
```
70+
netstat -tlnp | grep 5432
71+
```
72+
### 设置开机启动
73+
```
74+
chkconfig postgresql on
75+
```
76+
## 安装分词程序
77+
```
78+
tar -jxvf scws-1.2.3.tar.bz2
79+
cd scws-1.2.3/
80+
```
81+
### 配置
82+
```
83+
./configure
84+
```
85+
### 编译
86+
```
87+
make
88+
```
89+
### 安装
90+
```
91+
make install
92+
```
93+
## 安装postgresql的分词插件,这个插件依赖scws程序
94+
95+
### 解压
96+
```
97+
unzip zhparser-0.1.4.zip
98+
cd zhparser-0.1.4
99+
```
100+
### 编译
101+
```
102+
SCWS_HOME=/usr/local make
103+
```
104+
### 安装
105+
```
106+
make install
107+
```
108+
## 测试
109+
110+
### 进入postgres用户
111+
```
112+
su - postgres
113+
```
114+
### 进入pg数据库
115+
```
116+
psql
117+
```
118+
119+
### 切换到postgres数据库
120+
121+
```
122+
\c postgres
123+
```
124+
125+
### 创建扩展
126+
```
127+
CREATE EXTENSION zhparser;
128+
CREATE TEXT SEARCH CONFIGURATION testzhcfg (PARSER = zhparser);
129+
ALTER TEXT SEARCH CONFIGURATION testzhcfg ADD MAPPING FOR n,v,a,i,e,l WITH simple;
130+
```
131+
### 查询分词
132+
```
133+
SELECT to_tsvector('testzhcfg','南京市长江大桥');
134+
```
135+
![这里写图片描述](https://imgconvert.csdnimg.cn/aHR0cDovL2ltZy5ibG9nLmNzZG4ubmV0LzIwMTcxMTE5MjMwNDE0MTk3?x-oss-process=image/format,png)
136+
## ps:分词的粒度可以从配置中调整。
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Lua的包管理器LuaRockts
2+
3+
> 2016年12月19日 11:27:49
4+
5+
带宽廉价的时代,每种编程语言都有自己的包管理器(易于快速简洁的安装模块扩展库)、构建工具、软件包管理工具:
6+
7+
- PHP之于Composer
8+
- Java之于Maven(算是构建工具)
9+
- Python之于Pip
10+
- Android之于Gradle(构建工具)
11+
- Debian系之于apt-get
12+
- RedHat系之于yum
13+
- NodeJS之于npm
14+
15+
lua也有自己的包管理工具luarockts.
16+
使用包管理工具可以轻松的安装需要的模块扩展库,而不需要下载编译进系统lib,同样不需要下载复制进项目目录.
17+
## Debian系安装:
18+
```
19+
apt-get install luarockts
20+
```
21+
22+
## RedHat系安装:
23+
24+
```
25+
yum install luarockts
26+
```
27+
28+
由命令提示符可知,都在root权限下安装。
29+
之后安装扩展可能出现
30+
lua.h找不到的错误。
31+
安装lua-devel即development
32+
33+
```
34+
apt-get install lua-devel
35+
yum install lua-devel
36+
```

life/note.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,10 @@ openfire
6767
项目管理平台
6868
https://github.com/micromata/projectforge
6969

70-
70+
2019-9-25 08:17:55
71+
EAI
72+
SOA
73+
docker && sqlserver
74+
单点登录
75+
SDN
76+
workflow
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Linux命令对文本去重统计行数
2+
3+
>2018年01月11日 19:59:10
4+
5+
```shell
6+
sort target.txt | uniq | wc -l
7+
```

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy