class NewsScraper::Configuration
Constants
- DEFAULT_SCRAPE_PATTERNS_FILEPATH
- STOPWORDS_FILEPATH
Attributes
scrape_patterns_fetch_method[RW]
scrape_patterns_filepath[RW]
stopwords_fetch_method[RW]
Public Class Methods
new()
click to toggle source
NewsScraper::Configuration.initialize
initializes the scrape_patterns_filepath
and the scrape_patterns_fetch_method
to the DEFAULT_SCRAPE_PATTERNS_FILEPATH
. It also sets stopwords to be used during extraction to a default set contained in STOPWORDS_FILEPATH
Set the scrape_patterns_filepath
to nil
to disable saving during training
# File lib/news_scraper/configuration.rb, line 13 def initialize self.scrape_patterns_filepath = DEFAULT_SCRAPE_PATTERNS_FILEPATH self.scrape_patterns_fetch_method = proc { default_scrape_patterns } self.stopwords_fetch_method = proc { YAML.load_file(STOPWORDS_FILEPATH) } end
Public Instance Methods
scrape_patterns()
click to toggle source
NewsScraper::Configuration.scrape_patterns
proxies scrape_patterns
requests to scrape_patterns_fetch_method
:
Returns
-
The result of calling the
scrape_patterns_fetch_method
proc, expected to be a hash
# File lib/news_scraper/configuration.rb, line 25 def scrape_patterns scrape_patterns_fetch_method.call end
stopwords()
click to toggle source
NewsScraper::Configuration.stopwords
proxies stopwords requests to stopwords_fetch_method
:
Returns
-
The result of calling the
stopwords_fetch_method
proc, expected to be an array
# File lib/news_scraper/configuration.rb, line 35 def stopwords stopwords_fetch_method.call end
Private Instance Methods
default_scrape_patterns()
click to toggle source
# File lib/news_scraper/configuration.rb, line 41 def default_scrape_patterns @default_scrape_patterns ||= {} @default_scrape_patterns[scrape_patterns_filepath] ||= YAML.load_file(scrape_patterns_filepath) end