Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method for extracting Concepts tag using AlchemyLanguage API. #6

Closed
abhinaykumar opened this issue Aug 24, 2016 · 4 comments
Closed

Comments

@abhinaykumar
Copy link

abhinaykumar commented Aug 24, 2016

I am trying to use AlchemyApi for extracting concepts tag from a text but for some reason it keeps throwing the error undefined method concepts for #<WatsonAPIClient::AlchemyLanguage:0x007f9d86754088> when trying to pass text using the similar syntax as shown in the exmaple. service.concepts(....). I am not sure if this is the right method also, I couldn't find any relevant info. regarding the same. Can you please tell me what is the method name for concepts tag and how to pass a text to it.

@suchowan
Copy link
Owner

Alchemy API was originally by a third-party service, later has been integrated into Watson API.
Therefore, its API specifications deviate from the local rule at the first time.
The rearranging of a naming convention of the method names is necessary.
I am thankful when you can suggest some idea.

@abhinaykumar
Copy link
Author

I figured out on how to post data using RestClient to get Concept-Tags , Personality-Insight and Tone-Analyzer.
below is the working sample code for Concept-Tags:

concept_api_url = "https://gateway-a.watsonplatform.net/calls/text/TextGetRankedConcepts"
options = { text: "text", content_type: 'text/plain', apikey: 'xxxxx', url: 'http://example.com', outputMode: 'json', knowledgeGraph: 1 }
begin
  response = RestClient.post(concept_api_url, options)
rescue RestClient::ExceptionWithResponse => err
  puts err.response
end

Sample code for Personality-Insight:

profile_api_url = "https://gateway.watsonplatform.net/personality-insights/api/v2/profile"
client = RestClient::Resource.new(profile_api_url, 'username given by Api', 'password given by Api')
begin
  response = client.post text, content_type: 'text/plain'
rescue RestClient::ExceptionWithResponse => err
  puts err.response
end

I thought of adding the same to your library but I think you are following a different way to hit the Api endpoints.

@suchowan
Copy link
Owner

suchowan commented Sep 2, 2016

I'm going to have made sure that the APIs which belong to the Alchemy APIs will also work, but does it work at your place well?

@abhinaykumar
Copy link
Author

Yeah it works pretty much everywhere.

@suchowan suchowan closed this as completed Sep 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants