Class: NewsScraper::Configuration
- Inherits:
-
Object
- Object
- NewsScraper::Configuration
- Defined in:
- lib/news_scraper/configuration.rb
Constant Summary collapse
- DEFAULT_SCRAPE_PATTERNS_FILEPATH =
File.('../../../config/article_scrape_patterns.yml', __FILE__)
- STOPWORDS_FILEPATH =
File.('../../../config/stopwords.yml', __FILE__)
Instance Attribute Summary collapse
-
#scrape_patterns_fetch_method ⇒ Object
Returns the value of attribute scrape_patterns_fetch_method.
-
#scrape_patterns_filepath ⇒ Object
Returns the value of attribute scrape_patterns_filepath.
-
#stopwords_fetch_method ⇒ Object
Returns the value of attribute stopwords_fetch_method.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
NewsScraper::Configuration.initialize
initializes the scrape_patterns_filepath and the scrape_patterns_fetch_method to theDEFAULT_SCRAPE_PATTERNS_FILEPATH
. -
#scrape_patterns ⇒ Object
NewsScraper::Configuration.scrape_patterns
proxies scrape_patterns requests toscrape_patterns_fetch_method
:. -
#stopwords ⇒ Object
NewsScraper::Configuration.stopwords
proxies stopwords requests tostopwords_fetch_method
:.
Constructor Details
#initialize ⇒ Configuration
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
13 14 15 16 17 |
# 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 |
Instance Attribute Details
#scrape_patterns_fetch_method ⇒ Object
Returns the value of attribute scrape_patterns_fetch_method.
5 6 7 |
# File 'lib/news_scraper/configuration.rb', line 5 def scrape_patterns_fetch_method @scrape_patterns_fetch_method end |
#scrape_patterns_filepath ⇒ Object
Returns the value of attribute scrape_patterns_filepath.
5 6 7 |
# File 'lib/news_scraper/configuration.rb', line 5 def scrape_patterns_filepath @scrape_patterns_filepath end |
#stopwords_fetch_method ⇒ Object
Returns the value of attribute stopwords_fetch_method.
5 6 7 |
# File 'lib/news_scraper/configuration.rb', line 5 def stopwords_fetch_method @stopwords_fetch_method end |
Instance Method Details
#scrape_patterns ⇒ Object
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
25 26 27 |
# File 'lib/news_scraper/configuration.rb', line 25 def scrape_patterns scrape_patterns_fetch_method.call end |
#stopwords ⇒ Object
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
35 36 37 |
# File 'lib/news_scraper/configuration.rb', line 35 def stopwords stopwords_fetch_method.call end |