README.md

rcotoha: R for COTOHA API

Wrapper functions for using COTOHA API from R. COTOHA API is a natural language processing API by NTT Comunnications. This API is only for Japanese text. You can check details on COTOHA API here. This is just an interface by a volunteer (not by a company). So you have to register for COTOHA API and you must follow the terms of use by NTT Comunnications.

Installation

remotes::install_github("ocean-v/rcotoha")

Preparation

You have to check out the information about API on your account home page.

Usage

Make configulation files

make_cotoha_config(clientId = "xxxxxx", clientSecret = "xxxxxx", tokenURL = "https://xxxxxx", baseURL = "https://xxxxxx")

You will get "config.json" & "endpoint.json" on your current working directory.

Get access token

get_cotoha_token(config = "config.json", endpoint = "endpoint.json")

Execute COTOHA analysis

Details here -> https://api.ce-cotoha.com/contents/reference/apireference.html

execute_cotoha_analysis(
       access_token = "Your access token",
       API = "parse",
       sentence = "Your text"
     )
execute_cotoha_analysis(
       access_token = "Your access token",
       API = "ne",
       sentence = "Your text"
     )
execute_cotoha_analysis(
       access_token = "Your access token",
       API = "coreference",
       document = "Your text"
     )
execute_cotoha_analysis(
       access_token = "Your access token",
       API = "keyword",
       document = "Your text"
     )
execute_cotoha_analysis(
       access_token = "Your access token",
       API = "similarity",
       s1 = "Your text1",
       s2 = "Your text2"
     )
execute_cotoha_analysis(
       access_token = "Your access token",
       API = "sentence_type",
       sentence = "Your text"
     )
execute_cotoha_analysis(
       access_token = "Your access token",
       API = "sentence_type",
       sentence = "Your text"
     )
# example
execute_cotoha_analysis(
       access_token = "Your access token",
       API = "keyword",
       document = "Your text",
       opptional = list(max_keyword_num = 10)
     )

Reshape response into data.frame

Mainly for Named entity extraction 固有表現抽出 & Keyword extraction キーワード抽出.

cotoha_as_df(response = [your response])

Otherwise, you can extract the result as a list from the response by httr::content.



ocean-v/rcotoha documentation built on April 27, 2020, 9:29 p.m.