Skip to main content

Cotoha API, created by NTT Communications Corporation, for Python

Project description

CotohapPy: Cotoha for Python

CotohapPy (Japanese: コトハッピー) is for connecting Cotoha, one of the Japanese morphological analysis engines, and is for reshaping the response more readably.

Installation

The easiest way to install the latest version is by using pip/easy_install to pull it from PyPI:

pip install cotohappy

You may also use Git to clone the repository from GitHub and install it manually:

git clone https://github.com/278Mt/cotohappy.git
cd cotohappy
python setup.py install

Python 3.7 and 3.8 are supported (frequently updated).

Requirements

  • json
  • requests

Usage

This is one of the examples.

import cotohappy

coy = cotohappy.API()   # created instance of CotohapPy

print('\n#### parse origin ####')
sentence = '犬は歩く。'
type_    = 'default'
parse_li = coy.parse(sentence, type_)
for parse in parse_li:
    print(parse)

print(parse.key_name)

print('\n#### parse tokens ####')
for parse in parse_li:
    for token in parse.tokens:
        print(token)

print(token.key_name)

Output:

#### parse origin ####
犬は	 0,1,D,0,1
歩く。	 1,-1,O,0,1
form     id,head,dep,chunk_head,chunk_func

#### parse tokens ####
犬	 0,イヌ,犬,名詞,*,*,*,*,*
は	 1,ハ,は,連用助詞,*,*,*,*,*
歩	 2,アル,歩く,動詞語幹,K,*,*,*,*
く	 3,ク,く,動詞接尾辞,終止,*,*,*,*
。	 4,,。,句点,*,*,*,*,*
form     id,kana,lemma,pos,features[:5]

Please chek details on examples.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for cotohappy, version 0.0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size cotohappy-0.0.1.2-py3-none-any.whl (9.3 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page