Module: TexterraKBM
Constant Summary
Constants included from TexterraKBMSpecs
Instance Method Summary collapse
-
#all_pairs_similarity(first_concepts, second_concepts, linkWeight = 'MAX') ⇒ Object
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.
-
#get_attributes(concepts, attributes = []) ⇒ Object
Get attributes for concepts(list or single concept, each concept is id:kbname).
-
#neighbours(concepts, traverse_params = {}) ⇒ Object
Return neighbour concepts for the given concepts(list or single concept, each concept is id:kbname).
-
#neighbours_size(concepts, traverse_params = {}) ⇒ Object
Return neighbour concepts size for the given concepts(list or single concept, each concept is id:kbname).
-
#similar_over_filtered_neighbours(concepts, params = { linkWeight: 'MAX' }) ⇒ Object
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).
-
#similar_over_first_neighbours(concepts, params = { linkWeight: 'MAX' }) ⇒ Object
Search for similar concepts among the first neighbours of the given ones(list or single concept, each concept is id:kbname).
-
#similarity_between_virtual_articles(first_virtual_aricle, second_virtual_article, linkWeight = 'MAX') ⇒ Object
Compute similarity between two sets of concepts(list or single concept, each concept is id:kbname) as between “virtual” articles from these sets.
-
#similarity_graph(concepts, linkWeight = 'MAX') ⇒ Object
Compute similarity for each pair of concepts(list or single concept, each concept is id:kbname).
-
#similarity_to_virtual_article(concepts, virtual_aricle, linkWeight = 'MAX') ⇒ Object
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.
-
#term_commonness(term, concept = '') ⇒ Object
If concept isn’t provided, returns concepts with their commonness, corresponding to the found meanings of the given term.
-
#term_info_measure(term) ⇒ Object
Returns information measure for the given term.
-
#term_meanings(term) ⇒ Object
Return concepts resource from the Knowledge base corresponding to the found meanings of the given term.
-
#term_presence(term) ⇒ Hash
Determines if Knowledge base contains the specified term.
Instance Method Details
#all_pairs_similarity(first_concepts, second_concepts, linkWeight = 'MAX') ⇒ Object
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.
96 97 98 |
# File 'lib/ispras-api/texterra/kbm.rb', line 96 def all_pairs_similarity(first_concepts, second_concepts, linkWeight = 'MAX') preset_kbm :allPairsSimilarity, ["#{wrap_concepts(first_concepts)}linkWeight=#{linkWeight}", wrap_concepts(second_concepts)] end |
#get_attributes(concepts, attributes = []) ⇒ Object
check REST Documentation for supported attributes
Get attributes for concepts(list or single concept, each concept is id:kbname)
153 154 155 |
# File 'lib/ispras-api/texterra/kbm.rb', line 153 def get_attributes(concepts, attributes = []) preset_kbm :getAttributes, wrap_concepts(concepts), attribute: attributes end |
#neighbours(concepts, traverse_params = {}) ⇒ Object
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
57 58 59 60 61 62 |
# File 'lib/ispras-api/texterra/kbm.rb', line 57 def neighbours(concepts, traverse_params = {}) traverse = traverse_params.inject('') do |res, (name, value)| res + ";#{name}=#{value}" end unless traverse_params.empty? preset_kbm :neighbours, [wrap_concepts(concepts), traverse] end |
#neighbours_size(concepts, traverse_params = {}) ⇒ Object
If at least one traverse parameter(check REST Documentation for values) is specified, all other parameters should also be specified
Return neighbour concepts size for the given concepts(list or single concept, each concept is id:kbname).
76 77 78 79 80 81 |
# File 'lib/ispras-api/texterra/kbm.rb', line 76 def neighbours_size(concepts, traverse_params = {}) traverse = traverse_params.inject('') do |res, (name, value)| res + ";#{name}=#{value}" end unless traverse_params.empty? preset_kbm :neighbours, [wrap_concepts(concepts), "#{traverse}/size"] end |
#similar_over_filtered_neighbours(concepts, params = { linkWeight: 'MAX' }) ⇒ Object
check REST Documentation for values
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).
143 144 145 146 |
# File 'lib/ispras-api/texterra/kbm.rb', line 143 def similar_over_filtered_neighbours(concepts, params = { linkWeight: 'MAX' }) params[:among] ||= '' preset_kbm :similarOverFilteredNeighbours, "#{wrap_concepts(concepts)};linkWeight=#{params[:linkWeight]}", params end |
#similar_over_first_neighbours(concepts, params = { linkWeight: 'MAX' }) ⇒ Object
check REST Documentation for values
Search for similar concepts among the first neighbours of the given ones(list or single concept, each concept is id:kbname).
129 130 131 |
# File 'lib/ispras-api/texterra/kbm.rb', line 129 def similar_over_first_neighbours(concepts, params = { linkWeight: 'MAX' }) preset_kbm :similarOverFirstNeighbours, "#{wrap_concepts(concepts)};linkWeight=#{params[:linkWeight]}", params end |
#similarity_between_virtual_articles(first_virtual_aricle, second_virtual_article, linkWeight = 'MAX') ⇒ Object
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.
116 117 118 |
# File 'lib/ispras-api/texterra/kbm.rb', line 116 def similarity_between_virtual_articles(first_virtual_aricle, second_virtual_article, linkWeight = 'MAX') preset_kbm :similarityBetweenVirtualArticle, ["#{wrap_concepts(first_virtual_aricle)}linkWeight=#{linkWeight}", wrap_concepts(second_virtual_article)] end |
#similarity_graph(concepts, linkWeight = 'MAX') ⇒ Object
Compute similarity for each pair of concepts(list or single concept, each concept is id:kbname).
87 88 89 |
# File 'lib/ispras-api/texterra/kbm.rb', line 87 def similarity_graph(concepts, linkWeight = 'MAX') preset_kbm :similarityGraph, "#{wrap_concepts(concepts)}linkWeight=#{linkWeight}" end |
#similarity_to_virtual_article(concepts, virtual_aricle, linkWeight = 'MAX') ⇒ Object
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.
106 107 108 |
# File 'lib/ispras-api/texterra/kbm.rb', line 106 def similarity_to_virtual_article(concepts, virtual_aricle, linkWeight = 'MAX') preset_kbm :similarityToVirtualArticle, ["#{wrap_concepts(concepts)}linkWeight=#{linkWeight}", wrap_concepts(virtual_aricle)] end |
#term_commonness(term, concept = '') ⇒ Object
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.
40 41 42 43 |
# File 'lib/ispras-api/texterra/kbm.rb', line 40 def term_commonness(term, concept = '') concept = "id=#{concept}" unless concept.empty? preset_kbm :termCommonness, [term, concept] end |
#term_info_measure(term) ⇒ Object
Returns information measure for the given term. Information measure denotes, how often given term is used as link caption among all its occurences
19 20 21 |
# File 'lib/ispras-api/texterra/kbm.rb', line 19 def term_info_measure(term) preset_kbm :termInfoMeasure, term end |
#term_meanings(term) ⇒ Object
Return concepts resource from the Knowledge base corresponding to the found meanings of the given term
28 29 30 |
# File 'lib/ispras-api/texterra/kbm.rb', line 28 def term_meanings(term) preset_kbm :termMeanings, term end |
#term_presence(term) ⇒ Hash
Determines if Knowledge base contains the specified term
10 11 12 |
# File 'lib/ispras-api/texterra/kbm.rb', line 10 def term_presence(term) preset_kbm :termPresence, term end |