[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/WorksApplications/SudachiPy/develop/docs/tutorial.md [Back]  [Original]

#  SudachiPy 
[![PyPi version](https://img.shields.io/pypi/v/sudachipy.svg)](https://pypi.python.org/pypi/sudachipy/)
[![](https://img.shields.io/badge/python-3.5+-blue.svg)](https://www.python.org/downloads/release/python-350/)
[![build](https://github.com/WorksApplications/SudachiPy/actions/workflows/build.yml/badge.svg)](https://github.com/WorksApplications/SudachiPy/actions/workflows/build.yml)
[![](https://img.shields.io/github/license/WorksApplications/SudachiPy.svg)](https://github.com/WorksApplications/SudachiPy/blob/develop/LICENSE)

SudachiPy[Sudachi](https://github.com/WorksApplications/Sudachi)python


## 

```
$ pip install sudachipy sudachidict_core

$ echo "" | sudachipy
	,,,*,*,*	
EOS

$ echo "" | sudachipy -m A
	,,,,*,*	
	,,,*,*,*	
	,,,*,*,*	
EOS

$ echo "" | sudachipy -a
	,,,*,*,*				0
	,,,*,*,*				0
	,,,*,*,*				0
EOS
```

## 

SudachiPy


### Step 1. SudachiPy

```bash
$ pip install sudachipy
```

### Step 2. 

Python

 (`core`70MB ).

```bash
$ pip install sudachidict_core
```

[](#)


## CLI
CLI

```bash
$ echo "" | sudachipy
	,,,*,*,*	
EOS
$ echo "" | sudachipy -m A
	,,,*,*,*	
	,,,*,*,*	
	,,,*,*,*	
	,,,*,*,*	
EOS
```

```bash
$ sudachipy tokenize -h
usage: sudachipy tokenize [-h] [-r file] [-m {A,B,C}] [-o file] [-s string]
                          [-a] [-d] [-v]
                          [file [file ...]]

Tokenize Text

positional arguments:
  file           text written in utf-8

optional arguments:
  -h, --help     show this help message and exit
  -r file        the setting file in JSON format
  -m {A,B,C}     the mode of splitting
  -o file        the output file
  -s string      sudachidict type
  -a             print all of the fields
  -d             print the debug information
  -v, --version  print sudachipy version
```

### 



- 
- 
- 

 `-a` 

- 
- 
- ID
  - `0` 
  - `1` 
  - `-1\t(OOV)` 

```bash
$ echo "" | sudachipy -a
	,,,*,*,*				0
EOS
```

```bash
echo "quei" | sudachipy -a
	,,,*,*,*				-1	(OOV)
quei	,,,*,*,*	quei	quei		-1	(OOV)
EOS
```

## (Python )

 

```python
from sudachipy import tokenizer
from sudachipy import dictionary

tokenizer_obj = dictionary.Dictionary().create()
```

```python
# 

mode = tokenizer.Tokenizer.SplitMode.C
[m.surface() for m in tokenizer_obj.tokenize("", mode)]
# => ['']

mode = tokenizer.Tokenizer.SplitMode.B
[m.surface() for m in tokenizer_obj.tokenize("", mode)]
# => ['', '']

mode = tokenizer.Tokenizer.SplitMode.A
[m.surface() for m in tokenizer_obj.tokenize("", mode)]
# => ['', '', '']
```

```python
# 

m = tokenizer_obj.tokenize("", mode)[0]

m.surface() # => ''
m.dictionary_form() # => ''
m.reading_form() # => ''
m.part_of_speech() # => ['', '', '*', '*', '-', '-']
```

```python
# 

tokenizer_obj.tokenize("", mode)[0].normalized_form()
# => ''
tokenizer_obj.tokenize("SUMMER", mode)[0].normalized_form()
# => ''
tokenizer_obj.tokenize("", mode)[0].normalized_form()
# => ''
```

( `20200330` `core`  )

## 

**WARNING: `sudachipy link`  SudachiPy v0.5.2 . **

Sudachi`small``core``full`3 [WorksApplications/SudachiDict](https://github.com/WorksApplications/SudachiDict)

SudachiPy`sudachidict_core`

`sudachidict_small`, `sudachidict_core`, `sudachidict_full`Python

* [SudachiDict-small  PyPI](https://pypi.org/project/SudachiDict-small/)
* [SudachiDict-core  PyPI](https://pypi.org/project/SudachiDict-core/)
* [SudachiDict-full  PyPI](https://pypi.org/project/SudachiDict-full/)



### : 

`-s`


```bash
$ pip install sudachidict_small
$ echo "" | sudachipy -s small
```

```bash
$ pip install sudachidict_full
$ echo "" | sudachipy -s full
```

### : Python 

Dictionary  `config_path`  `dict_type` 

```python
class Dictionary(config_path=None, resource_dir=None, dict_type=None)
```

1. `config_path`
    * `config_path` [](#) 
    *  `systemDict` 
2. `dict_type`
    * `dict_type` 
    * `small`, `core`, `full` 
    * `config_path`  `dict_type` **`dict_type` ** 

```python
from sudachipy import tokenizer
from sudachipy import dictionary

#  sudachidict_core 
tokenizer_obj = dictionary.Dictionary().create()  

# /path/to/sudachi.json  systemDict 
tokenizer_obj = dictionary.Dictionary(config_path="/path/to/sudachi.json").create()  

# dict_type 
tokenizer_obj = dictionary.Dictionary(dict_type="core").create()  # sudachidict_core 
tokenizer_obj = dictionary.Dictionary(dict_type="small").create()  # sudachidict_small
tokenizer_obj = dictionary.Dictionary(dict_type="full").create()  # sudachidict_full

# dict_type (sudachidict_full) 
tokenizer_obj = dictionary.Dictionary(config_path="/path/to/sudachi.json", dict_type="full").create()  
```


### 

`sudachi.json`

 `systemDict` 




```
{
    "systemDict" : "relative/path/to/system.dic",
    ...
}
```

[sudachipy/resources/sudachi.json](https://github.com/WorksApplications/SudachiPy/blob/develop/sudachipy/resources/sudachi.json) `sudachi.json` `-r`.

```bash
$ sudachipy -r path/to/sudachi.json
``` 

## 
`user.dic`[sudachi.json](https://github.com/WorksApplications/SudachiPy/blob/develop/sudachipy/resources/sudachi.json)`sudachi.json``user.dic`userDict

```js
{
    "userDict" : ["relative/path/to/user.dic"],
    ...
}
```

 `sudachi.json``-r`

```bash
$ sudachipy -r path/to/sudachi.json
``` 

`ubuild`

**WARNING: v0.3.\* ubuild**

```bash
$ sudachipy ubuild -h
usage: sudachipy ubuild [-h] [-d string] [-o file] [-s file] file [file ...]

Build User Dictionary

positional arguments:
  file        source files with CSV format (one or more)

optional arguments:
  -h, --help  show this help message and exit
  -d string   description comment to be embedded on dictionary
  -o file     output file (default: user.dic)
  -s file     system dictionary path (default: system core dictionary path)
```

[user_dict.md](https://github.com/WorksApplications/Sudachi/blob/develop/docs/user_dict.md) 


## 

```bash
$ sudachipy build -h
usage: sudachipy build [-h] [-o file] [-d string] -m file file [file ...]

Build Sudachi Dictionary

positional arguments:
  file        source files with CSV format (one of more)

optional arguments:
  -h, --help  show this help message and exit
  -o file     output file (default: system.dic)
  -d string   description comment to be embedded on dictionary

required named arguments:
  -m file     connection matrix file with MeCab's matrix.def format
```

`system.dic`[sudachi.json](https://github.com/WorksApplications/SudachiPy/blob/develop/sudachipy/resources/sudachi.json)`sudachi.json``system.dic`systemDict

```
{
    "systemDict" : "relative/path/to/system.dic",
    ...
}
```

 `sudachi.json``-r`

```bash
$ sudachipy -r path/to/sudachi.json
``` 

## 
### Cython Build

```sh
$ python setup.py build_ext --inplace
```

### Code Format

`scripts/format.sh`

`flake8` `flake8-import-order` `flake8-buitins` (`requirements.txt`).

### Test

`scripts/test.sh`


## Contact

SudachiSudachiPy[WAP Tokushima Laboratory of AI and NLP](http://nlp.worksap.co.jp/).

Slack

- https://sudachi-dev.slack.com/ ([](https://join.slack.com/t/sudachi-dev/shared_invite/enQtMzg2NTI2NjYxNTUyLTMyYmNkZWQ0Y2E5NmQxMTI3ZGM3NDU0NzU4NGE1Y2UwYTVmNTViYjJmNDI0MWZiYTg4ODNmMzgxYTQ3ZmI2OWU))



Web Proxy Viewer  |  New URL  |  Original Page