zhparser
a parser for full-text search of Chinese
Repository
amutu/zhparser
https://github.com/amutu/zhparser
Source
zhparser-2.3.tar.gz
zhparser-2.3.tar.gz
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
zhparser | 2.3 | FTS | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 2130 | zhparser | No | Yes | No | Yes | No | Yes | - |
| Related | pgroonga pg_cjk_parser pg_jieba pg_bigm pg_tokenizer pg_pinyin unaccent dict_xsyn icu_ext pg_xenophile |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 2.3 | 1817161514 | zhparser | - |
| RPM | PIGSTY | 2.3 | 1817161514 | zhparser_$v | - |
| DEB | PIGSTY | 2.3 | 1817161514 | postgresql-$v-zhparser | - |
Build
You can build the RPM / DEB packages for zhparser using pig build:
Install
You can install zhparser directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
Install the extension using pig or apt/yum/dnf:
Install
pig
dnf
apt
Create Extension:
Usage
zhparser is a PostgreSQL extension for full-text search of Chinese, based on the Simple Chinese Word Segmentation (SCWS) library.
Features
- Chinese text segmentation for PostgreSQL full-text search
- Built on the SCWS (Simple Chinese Word Segmentation) library
- Supports custom dictionaries (TXT and XDB formats)
- Database-level custom word tables (since v2.1)
- Multiple tunable parameters for segmentation behavior
Quick Start
Configuration Parameters
zhparser provides several GUC parameters to control segmentation behavior:
| Parameter | Default | Description |
|---|---|---|
zhparser.punctuation_ignore | off | Ignore all punctuation |
zhparser.seg_with_duality | off | Perform duality segmentation on long words |
zhparser.dict_in_memory | off | Load the whole dictionary into memory |
zhparser.multi_short | off | Short word compound segmentation |
zhparser.multi_duality | off | Duality compound segmentation |
zhparser.multi_zmain | off | Key word in first compound segmentation |
zhparser.multi_zall | off | Use all compound segmentation |
Token Types
zhparser supports the following token types from SCWS:
| Code | Description |
|---|---|
a | Adjective |
b | Distinguishing word |
c | Conjunction |
d | Adverb |
e | Exclamation |
f | Position word |
g | Root word |
h | Prefix |
i | Idiom |
j | Abbreviation |
k | Suffix |
l | Temporary idiom |
m | Numeral |
n | Noun |
o | Onomatopoeia |
p | Preposition |
q | Classifier |
r | Pronoun |
s | Locative word |
t | Time word |
u | Auxiliary |
v | Verb |
w | Punctuation |
x | Unknown |
y | Modal particle |
z | State word |
Custom Dictionaries
File-based Dictionaries
Place custom dictionary files in the share directory (typically $SHAREDIR/tsearch_data/):
- TXT format: one word per line
- XDB format: compiled SCWS dictionary format
Custom dictionaries take precedence over built-in dictionaries.
Database-level Custom Words (v2.1+)
Docker Quick Start
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)