Commit 7a3d10f9 authored by alexlag's avatar alexlag
Browse files

doc fix

parent 714e5c78
......@@ -28,7 +28,7 @@ module TexterraKBM
end
# If concept isn't provided, returns concepts with their commonness, corresponding to the found meanings of the given term. Commonness denotes, how often the given term is associated with the given concept.
# With concept(format is {id}:{kbname}) returns commonness of given concept for the given term.
# With concept(format is {id}:{kbname}) returns commonness of given concept for the given term.
#
# @param term [String] term
# @param concept [String] concept as {id}:{kbname}
......@@ -39,11 +39,17 @@ module TexterraKBM
end
# Return neighbour concepts for the given concepts(list or single concept, each concept is {id}:{kbname}).
# If at least one traverse parameter(check REST Documentation for values) is specified, all other parameters should also be specified
#
# @param concepts [String, Array] either concept as {id}:{kbname} or array of such concepts
# @param traverse_params [Hash] optional, should contain :linkType, :nodeType, :minDepth, :maxDepth keys with values
# @param concepts [String, Array<String>] either concept as {id}:{kbname} or array of such concepts
# @param traverse_params [Hash] optional
# @option traverse_params [String] :linkType searching for neightbour concepts only along these link types
# @option traverse_params [String] :nodeType searching for neightbour concepts only of these types
# @option traverse_params [Fixnum] :minDepth minimum distance from original to result concepts
# @option traverse_params [Fixnum] :maxDepth maximum distance from original to result concepts
#
# @result [Hash] with :elements field
#
# If at least one traverse parameter(check REST Documentation for values) is specified, all other parameters should also be specified
def neighbours(concepts, traverse_params={})
traverse = traverse_params.inject('') do |res, (name, value)|
res += ";#{name}=#{value}"
......@@ -53,10 +59,16 @@ module TexterraKBM
# Return neighbour concepts size for the given concepts(list or single concept, each concept is {id}:{kbname}).
#
# @param concepts [String, Array] either concept as {id}:{kbname} or array of such concepts
# @param traverse_params [Hash] optional, should contain :linkType, :nodeType, :minDepth, :maxDepth keys with values
# If at least one traverse parameter(check REST Documentation for values) is specified, all other parameters should also be specified
# @param concepts [String, Array<String>] either concept as {id}:{kbname} or array of such concepts
# @param traverse_params [Hash] optional
# @option traverse_params [String] :linkType searching for neightbour concepts only along these link types
# @option traverse_params [String] :nodeType searching for neightbour concepts only of these types
# @option traverse_params [Fixnum] :minDepth minimum distance from original to result concepts
# @option traverse_params [Fixnum] :maxDepth maximum distance from original to result concepts
#
# @result [Hash] with :size field
#
# @note If at least one traverse parameter(check REST Documentation for values) is specified, all other parameters should also be specified
def neighbours_size(concepts, traverse_params={})
traverse = traverse_params.inject('') do |res, (name, value)|
res += ";#{name}=#{value}"
......@@ -66,82 +78,73 @@ module TexterraKBM
# Compute similarity for each pair of concepts(list or single concept, each concept is {id}:{kbname}).
#
# @param concepts [Array] array of concepts as {id}:{kbname}
# @param linkWeight [String] pecifies method for computation of link weight in case of multiple link types - check REST Documentation for values
# @param [Array<String>] concepts Array of concepts as {id}:{kbname}
# @param [String] linkWeight Specifies method for computation of link weight in case of multiple link types - check REST Documentation for values
def similarity_graph(concepts, linkWeight='MAX')
presetKBM :similarityGraph, "#{wrap_concepts(concepts)}linkWeight=#{linkWeight}"
end
# Computes sum of similarities from each concepts(list or single concept, each concept is {id}:{kbname}) from the first list to all concepts(list or single concept, each concept is {id}:{kbname}) from the second one.
#
# @param first_concepts [Array] array of concepts as {id}:{kbname}
# @param second_concepts [Array] array of concepts as {id}:{kbname}
# @param linkWeight [String] pecifies method for computation of link weight in case of multiple link types - check REST Documentation for values
# @param [Array<String>] first_concepts Array of concepts as {id}:{kbname}
# @param [Array<String>] second_concepts Array of concepts as {id}:{kbname}
# @param [String] linkWeight Specifies method for computation of link weight in case of multiple link types - check REST Documentation for values
def all_pairs_similarity(first_concepts, second_concepts, linkWeight='MAX')
presetKBM :allPairsSimilarity, ["#{wrap_concepts(first_concepts)}linkWeight=#{linkWeight}", wrap_concepts(second_concepts)]
end
# Compute similarity from each concept from the first list to all concepts(list or single concept, each concept is {id}:{kbname}) from the second list as a whole.
# Links of second list concepts(each concept is {id}:{kbname}) are collected together, thus forming a "virtual" article, similarity to which is computed.
# Links of second list concepts(each concept is {id}:{kbname}) are collected together, thus forming a "virtual" article, similarity to which is computed.
#
# @param concepts [Array] array of concepts as {id}:{kbname}
# @param virtual_aricle [Array] array of concepts as {id}:{kbname}
# @param linkWeight [String] pecifies method for computation of link weight in case of multiple link types - check REST Documentation for values
# @param [Array<String>] concepts Array of concepts as {id}:{kbname}
# @param [Array<String>] virtual_aricle Array of concepts as {id}:{kbname}
# @param [String] linkWeight Specifies method for computation of link weight in case of multiple link types - check REST Documentation for values
def similarity_to_virtual_article(concepts, virtual_aricle, linkWeight='MAX')
presetKBM :similarityToVirtualArticle, ["#{wrap_concepts(concepts)}linkWeight=#{linkWeight}", wrap_concepts(virtual_aricle)]
end
# Compute similarity between two sets of concepts(list or single concept, each concept is {id}:{kbname}) as between "virtual" articles from these sets.
# The links of each virtual article are composed of links of the collection of concepts.
# The links of each virtual article are composed of links of the collection of concepts.
#
# @param first_virtual_aricle [Array] array of concepts as {id}:{kbname}
# @param second_virtual_article [Array] array of concepts as {id}:{kbname}
# @param linkWeight [String] pecifies method for computation of link weight in case of multiple link types - check REST Documentation for values
# @param [Array<String>] first_virtual_aricle Array of concepts as {id}:{kbname}
# @param [Array<String>] second_virtual_article Array of concepts as {id}:{kbname}
# @param [String] linkWeight Specifies method for computation of link weight in case of multiple link types - check REST Documentation for values
def similarity_between_virtual_articles(first_virtual_aricle, second_virtual_article, linkWeight='MAX')
presetKBM :similarityBetweenVirtualArticle, ["#{wrap_concepts(first_virtual_aricle)}linkWeight=#{linkWeight}", wrap_concepts(second_virtual_article)]
end
# Search for similar concepts among the first neighbours of the given ones(list or single concept, each concept is {id}:{kbname}).
#
# @param concepts [Array] array of concepts as {id}:{kbname}
# @param linkWeight [String] pecifies method for computation of link weight in case of multiple link types - check REST Documentation for values
# @param params [Hash]
# => linkWeight [String] pecifies method for computation of link weight in case of multiple link types - check REST Documentation for values
# => offset [Integer] provides a possibility to skip several concepts from the start of the result
# => limit [Integer] provides a possibility to limit size of result
# check REST Documentation for values
# @param [Array<String>] concepts Array of concepts as {id}:{kbname}
# @param [Hash] params
# @option params [String] :linkWeight Specifies method for computation of link weight in case of multiple link types
# @option params [Fixnum] :offset Provides a possibility to skip several concepts from the start of the result
# @option params [Fixnum] :limit Provides a possibility to limit size of result
#
# @note check REST Documentation for values
def similar_over_first_neighbours(concepts, params={linkWeight:'MAX'})
presetKBM :similarOverFirstNeighbours, "#{wrap_concepts(concepts)};linkWeight=#{params[:linkWeight]}", params
end
# Search for similar concepts over filtered set of the first and the second neighbours of the given ones(list or single concept, each concept is {id}:{kbname}).
#
# @param concepts [Array] array of concepts as {id}:{kbname}
# @param linkWeight [String] pecifies method for computation of link weight in case of multiple link types - check REST Documentation for values
# @param params [Hash]
# => :linkWeight [String] pecifies method for computation of link weight in case of multiple link types - check REST Documentation for values
# => :offset [Integer] provides a possibility to skip several concepts from the start of the result
# => :limit [Integer] provides a possibility to limit size of result
# => :among [SimilarCandidatesFilter] specifies how to filter neighbour concepts when searching for most similar
# check REST Documentation for values
# @param [Array<String>] concepts Array of concepts as {id}:{kbname}
# @param [Hash] params
# @option params [String] :linkWeight Specifies method for computation of link weight in case of multiple link types
# @option params [Fixnum] :offset Provides a possibility to skip several concepts from the start of the result
# @option params [Fixnum] :limit Provides a possibility to limit size of result
# @option params [String] :among Specifies how to filter neighbour concepts when searching for most similar
#
# @note check REST Documentation for values
def similar_over_filtered_neighbours(concepts, params={linkWeight:'MAX'})
presetKBM :similarOverFilteredNeighbours, "#{wrap_concepts(concepts)};linkWeight=#{params[:linkWeight]}", params
end
# Get attributes for concepts(list or single concept, each concept is {id}:{kbname})
#
# @param concepts [String, Array] either concept as {id}:{kbname} or array of such concepts
# @param attributes [Array] specifies attributes to be included into response
# => Supported attributes:
# coordinates - GPS coordinates
# definition - brief concept definition
# url(<language>) - URL to page with description of the given concept on the specified language
# <language> - language code, like: en, de, fr, ko, ru, ...
# synonym - different textual representations of the concept
# title - concept title
# translation(<language>) textual representation of the concept on the specified language
# <language> - language code, like: en, de, fr, ko, ru, ...
# type - concept type
# @param [String, Array<String>] concepts Either concept as {id}:{kbname} or array of such concepts
# @param [Array<String>] attributes Specifies attributes to be included into response
# @note check REST Documentation for supported attributes
def get_attributes(concepts, attributes=[])
presetKBM :getAttributes, wrap_concepts(concepts), attribute: attributes
end
......
......@@ -4,7 +4,7 @@ module TexterraNLP
include TexterraNLPSpecs
# Detects language of given text
#
# @param text [String] text to process
# @param [String] text Text to process
# @return [Array] Texterra annotations
def language_detection_annotate(text)
presetNLP(:languageDetection, text)
......@@ -12,7 +12,7 @@ module TexterraNLP
# Detects boundaries of sentences in a given text
#
# @param text [String] text to process
# @param [String] text Text to process
# @return [Array] Texterra annotations
def sentence_detection(text)
presetNLP(:sentenceDetection, text)
......@@ -20,7 +20,7 @@ module TexterraNLP
# Detects all tokens (minimal significant text parts) in a given text
#
# @param text [String] text to process
# @param [String] text Text to process
# @return [Array] Texterra annotations
def tokenization_annotate(text)
presetNLP(:tokenization, text)
......@@ -28,7 +28,7 @@ module TexterraNLP
# Detects lemma of each word of a given text
#
# @param text [String] text to process
# @param [String] text Text to process
# @return [Array] Texterra annotations
def lemmatization_annotate(text)
presetNLP(:lemmatization, text)
......@@ -36,7 +36,7 @@ module TexterraNLP
# Detects part of speech tag for each word of a given text
#
# @param text [String] text to process
# @param [String] text Text to process
# @return [Array] Texterra annotations
def pos_tagging_annotate(text)
presetNLP(:posTagging, text)
......@@ -44,7 +44,7 @@ module TexterraNLP
# Tries to correct disprints and other spelling errors in a given text
#
# @param text [String] text to process
# @param [String] text Text to process
# @return [Array] Texterra annotations
def spelling_correction_annotate(text)
presetNLP(:spellingCorrection, text)
......@@ -52,7 +52,7 @@ module TexterraNLP
# Finds all named entities occurences in a given text
#
# @param text [String] text to process
# @param [String] text Text to process
# @return [Array] Texterra annotations
def named_entities_annotate(text)
presetNLP(:namedEntities, text)
......@@ -60,7 +60,7 @@ module TexterraNLP
# Extracts not overlapping terms within a given text; term is a textual representation for some concept of the real world
#
# @param text [String] text to process
# @param [String] text Text to process
# @return [Array] Texterra annotations
def term_detection_annotate(text)
presetNLP(:termDetection, text)
......@@ -68,7 +68,7 @@ module TexterraNLP
# Detects the most appropriate meanings (concepts) for terms occurred in a given text
#
# @param text [String] text to process
# @param [String] text Text to process
# @return [Array] Texterra annotations
def disambiguation_annotate(text)
presetNLP(:disambiguation, text)
......@@ -77,7 +77,7 @@ module TexterraNLP
# Key concepts are the concepts providing short (conceptual) and informative text description.
# This service extracts a set of key concepts for a given text
#
# @param text [String] text to process
# @param [String] text Text to process
# @return [Array] Texterra annotations
def key_concepts_annotate(text)
presetNLP(:keyConcepts, text)
......@@ -87,7 +87,7 @@ module TexterraNLP
# Currently only 2 specific domains are supported: 'movie' and 'politics'
# If no domain from this list has been detected, the text is assumed to be no domain, or general domain
#
# @param text [String] text to process
# @param [String] text Text to process
# @return [Array] Texterra annotations
def domain_detection_annotate(text)
presetNLP(:domainDetection, text)
......@@ -95,7 +95,7 @@ module TexterraNLP
# Detects whether the given text is subjective or not
#
# @param text [String] text to process
# @param [String] text Text to process
# @return [Array] Texterra annotations
def subjectivity_detection_annotate(text)
presetNLP(:subjectivityDetection, text)
......@@ -103,7 +103,7 @@ module TexterraNLP
# Detects whether the given text has positive, negative or no sentiment
#
# @param text [String] text to process
# @param [String] text Text to process
# @return [Array] Texterra annotations
def polarity_detection_annotate(text)
presetNLP(:polarityDetection, text)
......@@ -113,7 +113,8 @@ module TexterraNLP
# If domain isn't provided, Domain detection is applied, this way method tries to achieve best results.
# If no domain is detected general domain algorithm is applied
#
# @param text [String] text to process
# @param [String] text Text to process
# @param [String] domain Domain for polarity detection
# @return [Array] Texterra annotations
def domain_polarity_detection_annotate(text, domain='')
specs = NLPSpecs[:domainPolarityDetection]
......@@ -130,7 +131,7 @@ module TexterraNLP
# Detects Twitter-specific entities: Hashtags, User names, Emoticons, URLs.
# And also: Stop-words, Misspellings, Spelling suggestions, Spelling corrections
#
# @param text [String] text to process
# @param [String] text Text to process
# @return [Array] Texterra annotations
def tweet_normalization(text)
presetNLP(:tweetNormalization, text)
......
......@@ -20,8 +20,8 @@ class TexterraAPI < IsprasAPI
# Key concepts are the concepts providing short (conceptual) and informative text description.
# This service extracts a set of key concepts for a given text
#
# @param text [String] text to process
# @return [Array] list of weighted key concepts
# @param [String] text Text to process
# @return [Array] Array of weighted key concepts
def key_concepts(text)
key_concepts = key_concepts_annotate(text)[0][:value][:concepts_weights][:entry] || []
key_concepts = [].push key_concepts unless key_concepts.is_a? Array
......@@ -33,7 +33,7 @@ class TexterraAPI < IsprasAPI
# Detects whether the given text has positive, negative or no sentiment
#
# @param text [String] text to process
# @param [String] text Text to process
# @return [Array] Sentiment of the text
def sentiment_analysis(text)
begin
......@@ -44,10 +44,10 @@ class TexterraAPI < IsprasAPI
end
# Detects whether the given text has positive, negative, or no sentiment, with respect to domain.
# If domain isn't provided, Domain detection is applied, this way method tries to achieve best results.
# If no domain is detected general domain algorithm is applied
# If domain isn't provided, Domain detection is applied, this way method tries to achieve best results.
# If no domain is detected general domain algorithm is applied
#
# @param text [String] text to process
# @param [String] text Text to process
# @param domain [String] domain to use. Can be empty
# @return [Hash] used :domain and detected :polarity
def domain_sentiment_analysis(text, domain='')
......@@ -65,7 +65,7 @@ class TexterraAPI < IsprasAPI
# Detects the most appropriate meanings (concepts) for terms occurred in a given text
#
# @param text [String] text to process
# @param [String] text Text to process
# @return [Array] Texterra annotations
def disambiguation(text)
disambiguation_annotate(text)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment