|
2 | 2 | require 'nokogiri'
|
3 | 3 | require 'extlib'
|
4 | 4 | require 'ostruct'
|
5 |
| -require 'active_support/core_ext/module/attr_accessor_with_default' |
6 | 5 |
|
7 | 6 | module SemanticExtraction
|
8 | 7 |
|
9 | 8 | class << self
|
10 |
| - attr_accessor_with_default :preferred_extractor, "alchemy" |
11 |
| - attr_accessor_with_default :alchemy_api_key, "" |
12 |
| - attr_accessor_with_default :yahoo_api_key, "" |
13 |
| - attr_accessor_with_default :valid_extractors, ["yahoo", "alchemy"] |
14 |
| - attr_accessor_with_default :requires_api_key, ["yahoo", "alchemy"] |
| 9 | + attr_reader :valid_extractors |
| 10 | + attr_writer :valid_extractors |
| 11 | + |
| 12 | + attr_reader :requires_api_key |
| 13 | + attr_writer :requires_api_key |
| 14 | + |
| 15 | + attr_reader :yahoo_api_key |
| 16 | + attr_writer :yahoo_api_key |
| 17 | + |
| 18 | + attr_reader :alchemy_api_key |
| 19 | + attr_writer :alchemy_api_key |
| 20 | + |
| 21 | + attr_reader :preferred_extractor |
15 | 22 | end
|
16 | 23 |
|
| 24 | + self.valid_extractors = ["yahoo", "alchemy"] |
| 25 | + |
| 26 | + self.requires_api_key = ["yahoo", "alchemy"] |
| 27 | + |
17 | 28 | # By default, we assume you want to use Alchemy.
|
18 | 29 | # To override, just set SemanticExtraction.preferred_extractor somewhere and define the appropriate api_key.
|
19 | 30 | def self.preferred_extractor=(value)
|
20 | 31 | if self.valid_extractors.include?(value)
|
21 |
| - @@preferred_extractor = value |
| 32 | + @preferred_extractor = value |
22 | 33 | else
|
23 | 34 | raise NotSupportedExtractor
|
24 | 35 | end
|
25 |
| - end |
| 36 | + end |
26 | 37 |
|
| 38 | + self.preferred_extractor = "alchemy" |
| 39 | + |
| 40 | + |
27 | 41 | # Screw it. Hard-code time!
|
28 | 42 | require 'semantic_extraction/utility_methods'
|
29 | 43 | require 'semantic_extraction/extractors/yahoo'
|
|
0 commit comments