Class: Semcheck::Application
- Inherits:
-
Object
- Object
- Semcheck::Application
- Defined in:
- lib/semcheck.rb
Instance Attribute Summary collapse
-
#schemas ⇒ Object
Returns the value of attribute schemas.
-
#synonyms ⇒ Object
Returns the value of attribute synonyms.
-
#terms ⇒ Object
Returns the value of attribute terms.
Instance Method Summary collapse
-
#initialize(args) ⇒ Application
constructor
A new instance of Application.
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ Application
13 14 15 16 17 |
# File 'lib/semcheck.rb', line 13 def initialize(args) @terms = args @synonyms = [] @schemas = [] end |
Instance Attribute Details
#schemas ⇒ Object
Returns the value of attribute schemas.
11 12 13 |
# File 'lib/semcheck.rb', line 11 def schemas @schemas end |
#synonyms ⇒ Object
Returns the value of attribute synonyms.
11 12 13 |
# File 'lib/semcheck.rb', line 11 def synonyms @synonyms end |
#terms ⇒ Object
Returns the value of attribute terms.
11 12 13 |
# File 'lib/semcheck.rb', line 11 def terms @terms end |
Instance Method Details
#run ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/semcheck.rb', line 19 def run puts "Searching semweb resources for: #{terms}" string_or_array_of(terms).each do |term| # bronto gives us a sparse, but local dict results = Bronto::Thesaurus.new.lookup(term) if !results.nil? results.keys.each do |word_type| synonyms << results[word_type][:syn] end end end synonyms.flatten! # schema.org just uses google to do search schemas << Google::Search::Web.new do |search| search.query = "site:schema.org " + maybe_array_of(terms).join(" OR ") end.map(&:uri) # oddly, if i just do a giant or chain i can lose # the results i wouldve gotten from the single term schemas << Google::Search::Web.new do |search| search.query = "site:schema.org " + maybe_array_of(synonyms).join(" OR ") end.map(&:uri) @schemas = schemas.flatten.reject! do |url| blacklist.include?(url) || url =~ schema_blog end.uniq puts "Possible schema matches:\n#{schemas.join("\n")}" return self end |