Class: RDFObject::IndexSet
- Inherits:
-
Object
- Object
- RDFObject::IndexSet
- Defined in:
- lib/rdf_objects/pho/index_set.rb
Class Method Summary collapse
Instance Method Summary collapse
- #<<(index) ⇒ Object
- #get_index(name) ⇒ Object
-
#initialize(store_name = nil) ⇒ IndexSet
constructor
A new instance of IndexSet.
- #set_store(store_name) ⇒ Object
- #to_fpmap ⇒ Object
- #to_qp ⇒ Object
Constructor Details
#initialize(store_name = nil) ⇒ IndexSet
Returns a new instance of IndexSet.
48 49 50 51 |
# File 'lib/rdf_objects/pho/index_set.rb', line 48 def initialize(store_name=nil) @fields = {} @store = nil end |
Class Method Details
.new_from_response(fpmap, qp) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/rdf_objects/pho/index_set.rb', line 96 def self.new_from_response(fpmap, qp) index_set = self.new(fpmap.uri.sub("/config/fpmaps/1","")) [*fpmap["http://schemas.talis.com/2006/frame/schema#mappedDatatypeProperty"]].each do |field| next unless field index = RDFObject::Index.new index.set_name(field["http://schemas.talis.com/2006/frame/schema#name"].to_s) index.set_property(field["http://schemas.talis.com/2006/frame/schema#property"].resource) if field["http://schemas.talis.com/2006/bigfoot/configuration#analyzer"] index.set_analyzer(field["http://schemas.talis.com/2006/bigfoot/configuration#analyzer"].resource) end index_set << index end [*qp["http://schemas.talis.com/2006/bigfoot/configuration#fieldWeight"]].each do |weight| next unless weight name = weight["http://schemas.talis.com/2006/frame/schema#name"].to_s index = index_set.get_index(name) unless index puts "Warn: discarding #{name} - does not appear in field/predicate map." next end index.set_weight(weight["http://schemas.talis.com/2006/bigfoot/configuration#weight"].value) end return index_set end |
Instance Method Details
#<<(index) ⇒ Object
53 54 55 |
# File 'lib/rdf_objects/pho/index_set.rb', line 53 def <<(index) @fields[index.name] = index end |
#get_index(name) ⇒ Object
58 59 60 |
# File 'lib/rdf_objects/pho/index_set.rb', line 58 def get_index(name) return @fields[name] end |
#set_store(store_name) ⇒ Object
62 63 64 |
# File 'lib/rdf_objects/pho/index_set.rb', line 62 def set_store(store_name) @store = store_name end |
#to_fpmap ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/rdf_objects/pho/index_set.rb', line 67 def to_fpmap raise unless @store fpmap = RDFObject::Resource.new("#{@store}/config/fpmaps/1") fpmap.relate("[rdf:type]","http://schemas.talis.com/2006/bigfoot/configuration#FieldPredicateMap") @fields.values.each do |index| field = RDFObject::Resource.new("#{fpmap.uri}##{index.name}") field.relate("http://schemas.talis.com/2006/frame/schema#property", index.property) field.assert("http://schemas.talis.com/2006/frame/schema#name", index.name) if index.analyzer field.relate("http://schemas.talis.com/2006/bigfoot/configuration#analyzer", index.analyzer) end fpmap.relate("http://schemas.talis.com/2006/frame/schema#mappedDatatypeProperty", field) end fpmap end |
#to_qp ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/rdf_objects/pho/index_set.rb', line 83 def to_qp raise unless @store qp = RDFObject::Resource.new("#{@store}/config/queryprofiles/1") qp.relate("[rdf:type]", "http://schemas.talis.com/2006/bigfoot/configuration#QueryProfile") @fields.values.each do |index| next unless index.weight weight = RDFObject::Resource.new("#{qp.uri}##{index.name}") weight.assert("http://schemas.talis.com/2006/bigfoot/configuration#weight", index.weight.to_s) weight.assert("http://schemas.talis.com/2006/frame/schema#name", index.name) end qp end |