xinci is a Python interface for chinese words extraction & new words extraction.
[https://pypi.org/project/xinci/]
## Requirements
Python >= 2.7
## Installation
### 1. using pip
```shell
pip install xinci
```
### 2. using setup.py
``` shell
git clone git@github.com:Lapis-Hong/xinci.git
cd xinci
pip setup.py install
```
## Usage
This package has two main use cases: words extraction and
find new words.
### 1. command line
```shell
cd xinci
python word_extraction.py
```
or
```
./run.sh
```
### 2. python package
```python
import xinci
# if you want to see logging events.
import logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s : %(levelname)s : %(message)s')
# init default dictionary or user dic,
dic = xinci.Dictionary()
# load vocab, vocab is a python set.
vocab = dic.load() # or dic.dictionary
print(vocab)
# add words to dic
dic.add(['神马']) # or dic.add_from_file('user.dic')
# remove words from dic
dic.remove(['神马']) # or dic.remove_from_file('user.dic')
# extract new words, xc is a set
xc = xinci.extract('corpus.txt')
for w in xc:
print(w)
# extract all words, c is a set
c = xinci.extract('corpus.txt', all_words=True)
for w in xc:
print(w)
```
result
```angular2html
发现5个新词如下:
@新词 @词频
祛斑 13
后再 7
今日头条 9
洗净切 7
蛋液 9
```
### Notes: Iteratively add "not seems to new words" in result to common dic will improve a lot.
## API documentation
```python
xc = xinci.extract(params)
```
List of available `params` and their default value:
```angular2html
corpus_file: string, input corpus file (required)
common_words_file: string, common words dic file [common.dic]
min_candidate_len: int, min candidate word length [2]
max_candidate_len: int, max candidate word length [5]
least_cnt_threshold: int, least word count to extract [5]
solid_rate_threshold: float, solid rate threshold [0.018]
entropy_threshold: float, entropy threshold [1.92]
all_words: bool, set True to extract all words mode [False]
save_file: string, output file [None]
```
## References
The code is based on this java version
[https://github.com/GeorgeBourne/grid]
Metadata
Release files for xinci 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xinci-1.2.0.tar.gz | 1.0 MB | Without provenance | Details for xinci-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xinci-1.2.0-py2-none-any.whl | Python 2 | none | any | Details for xinci-1.2.0-py2-none-any.whl |
Total release size: 2.0 MB
Release files / xinci-1.2.0.tar.gz
| Download URL | xinci-1.2.0.tar.gz |
|---|---|
| Size | 1.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
05076fa33ef32dcd9dd8bc502603df07fddef1ec42c45fdb17e964c5a64b14de
|
|
BLAKE2b-256 checksum How to use checksums |
089180ecc85e199caaeeb90e13c1d5cd79c36cbcb822c40f6d8c9be48e3deee1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / xinci-1.2.0-py2-none-any.whl
| Download URL | xinci-1.2.0-py2-none-any.whl |
|---|---|
| Size | 1.0 MB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
7540bad5163572058a64b857449c829f7849a02c144e834cb29992336cb734e5
|
|
BLAKE2b-256 checksum How to use checksums |
b8d9c88909d9f3d891f2ec368f6abc789ac6e10015b3bd5273ae481fb72e5b6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for xinci 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.