Sha256: a4ef29d8b276c589c5604f9b55b85f3215df1248a6fa52ca88d6e8799365732a
Contents?: true
Size: 1.15 KB
Versions: 6
Compression:
Stored size: 1.15 KB
Contents
class WitAiParseModelExample < ApplicationRecord belongs_to :wit_ai_parse_model # after_create :make_wit_ai_request after_create :import_to_google_aml_nlp_ee def make_wit_ai_request wit_server = Wit.new(access_token: self.wit_ai_parse_model.wit_ai_server_token) wit_server.post_entities({id: self.entity_name}) rescue nil samples = [{ "text": self.parsable_resource_text[0...280], "entities": [ { "entity": self.entity_name, "start": self.parsable_resource_entity_value_start_index, "end": self.parsable_resource_entity_value_end_index, "value": self.entity_value } ] }] self.wit_ai_server_response = ` curl -XPOST 'https://api.wit.ai/samples?v=20170307' \ -H "Authorization: Bearer #{self.wit_ai_parse_model.wit_ai_server_token}" \ -H "Content-Type: application/json" \ -d '#{samples.to_json}' ` self.save! end def import_to_google_aml_nlp_ee # create jsonl for example and copy it to gstorage # add jsonl to csv (csv should be namespaced by wit_ai_parse_model.id) # import csv to gamllnlpee via http rest request end end
Version data entries
6 entries across 6 versions & 2 rubygems