Module: Abstractor::CustomNlpProvider
- Defined in:
- lib/abstractor/custom_nlp_provider.rb
Class Method Summary collapse
-
.determine_suggestion_endpoint(custom_nlp_provider) ⇒ String
Determines the suggestion endpoint for the passed in custom NLP provider.
-
.format_body_for_suggestion_endpoint(abstractor_abstraction, abstractor_abstraction_source, abstractor_text, source) ⇒ Hash
Formats the JSON body in preparation for submision to a custom NLP provider endpoint.
Class Method Details
.determine_suggestion_endpoint(custom_nlp_provider) ⇒ String
Determines the suggestion endpoint for the passed in custom NLP provider.
The endpoint is assumed to be configured in config/abstractor/custom_nlp_providers.yml. A template configratuon file can be generated in the host application by calling the rake task abstractor:custom_nlp_provider.
11 12 13 |
# File 'lib/abstractor/custom_nlp_provider.rb', line 11 def self.determine_suggestion_endpoint(custom_nlp_provider) suggestion_endpoint = YAML.load_file("#{Rails.root}/config/abstractor/custom_nlp_providers.yml")[custom_nlp_provider]['suggestion_endpoint'][Rails.env] end |
.format_body_for_suggestion_endpoint(abstractor_abstraction, abstractor_abstraction_source, abstractor_text, source) ⇒ Hash
Formats the JSON body in preparation for submision to a custom NLP provider endpoint.
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/abstractor/custom_nlp_provider.rb', line 35 def self.format_body_for_suggestion_endpoint(abstractor_abstraction, abstractor_abstraction_source, abstractor_text, source) { abstractor_abstraction_schema_id: abstractor_abstraction.abstractor_subject.abstractor_abstraction_schema.id, abstractor_abstraction_schema_uri: Abstractor::Engine.routes.url_helpers.abstractor_abstraction_schema_url(abstractor_abstraction.abstractor_subject.abstractor_abstraction_schema, format: :json), abstractor_abstraction_abstractor_suggestions_uri: Abstractor::Engine.routes.url_helpers.abstractor_abstraction_abstractor_suggestions_url(abstractor_abstraction, format: :json), abstractor_abstraction_id: abstractor_abstraction.id, abstractor_abstraction_source_id: abstractor_abstraction_source.id, source_id: source[:source_id], source_type: source[:source_type].to_s, source_method: source[:source_method], text: abstractor_text } end |