Module: ActiveTriple::Search

Defined in:
lib/active_triple/search.rb

Class Method Summary collapse

Class Method Details

.about(text) ⇒ Object



14
15
16
# File 'lib/active_triple/search.rb', line 14

def self.about(text)
  %Q{#{ActiveTriple.binding_variable} ontology:about resource:#{underscore_spaces(text)} .}
end

.location(place_name, radius = '8km') ⇒ Object

At the moment, I think this is the only search method that is working.



5
6
7
8
9
10
11
12
# File 'lib/active_triple/search.rb', line 5

def self.location(place_name, radius = '8km')
  [
    %Q{resource:#{place_name} geo-pos:lat ?Latitude .},
    %Q{resource:#{place_name} geo-pos:long ?Longitude .},
    %Q{?location omgeo:nearby(?Latitude ?Longitude "#{radius}") .},
    %Q{#{ActiveTriple.binding_variable} ontology:about ?location .}
  ]
end

.mentions(text) ⇒ Object



18
19
20
# File 'lib/active_triple/search.rb', line 18

def self.mentions(text)
  %Q{#{ActiveTriple.binding_variable} ontology:mentions resource:#{underscore_spaces(text)} .}
end

.subject(text) ⇒ Object



22
23
24
# File 'lib/active_triple/search.rb', line 22

def self.subject(text)
  %Q{#{ActiveTriple.binding_variable} dc:terms:subject resource:#{text} .}
end

.title(text) ⇒ Object



33
34
35
# File 'lib/active_triple/search.rb', line 33

def self.title(text)
  %Q{#{ActiveTriple.binding_variable} dc:terms:title text:en:"#{text}" .}
end

.underscore_spaces(text) ⇒ Object



37
38
39
# File 'lib/active_triple/search.rb', line 37

def self.underscore_spaces(text)
  text.gsub(/\s+/, "_")
end

.where(hash) ⇒ Object

ActiveTriple.where(‘dc:terms:subject’ => ‘resource:London’) is equivalent to ActiveTriple.subject(‘London’)



27
28
29
30
31
# File 'lib/active_triple/search.rb', line 27

def self.where(hash)
  statements = Array.new
  hash.each{|predicate, object| statements << %Q{#{ActiveTriple.binding_variable} #{predicate} #{object} .}}
  return statements
end