Trying to count the number of noun appeared in a paragraph with Google's NL api using ruby.
Been looking up the document, couldn't find how to do this.
Work out a solution last night
text = 'xxxxxxxxxx'
response = language.analyze_syntax content: text, type: :PLAIN_TEXT
sentences = response.sentences
tokens = response.tokens
x= tokens.count
a = Array.new(x-1)
for i in 1..x
a[i-1] = tokens[i-1].part_of_speech.tag.to_s
end
for i in 1..x
if a[i-1] == 'NOUN'
num= num+1
end
end
still wondering if there exist something like (tokens.noun.count ?) in the nl api https://cloud.google.com/natural-language/docs/analyzing-syntax#language-syntax-string-ruby.