Class: Nickel::NLP
- Inherits:
-
Object
- Object
- Nickel::NLP
- Defined in:
- lib/nickel/nlp.rb
Instance Attribute Summary collapse
-
#construct_finder ⇒ Object
readonly
Returns the value of attribute construct_finder.
-
#construct_interpreter ⇒ Object
readonly
Returns the value of attribute construct_interpreter.
-
#input_date ⇒ Object
readonly
Returns the value of attribute input_date.
-
#input_time ⇒ Object
readonly
Returns the value of attribute input_time.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#nlp_query ⇒ Object
readonly
Returns the value of attribute nlp_query.
-
#occurrences ⇒ Object
readonly
Returns the value of attribute occurrences.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Instance Method Summary collapse
-
#initialize(query, date_time = Time.now) ⇒ NLP
constructor
A new instance of NLP.
- #inspect ⇒ Object
- #parse ⇒ Object
Constructor Details
#initialize(query, date_time = Time.now) ⇒ NLP
Returns a new instance of NLP.
14 15 16 17 18 19 20 |
# File 'lib/nickel/nlp.rb', line 14 def initialize(query, date_time = Time.now) str_time = date_time.strftime('%Y%m%dT%H%M%S') validate_input query, str_time @query = query.dup @input_date = ZDate.new str_time[0..7] # up to T, note format is already verified @input_time = ZTime.new str_time[9..14] # after T end |
Instance Attribute Details
#construct_finder ⇒ Object (readonly)
Returns the value of attribute construct_finder.
11 12 13 |
# File 'lib/nickel/nlp.rb', line 11 def construct_finder @construct_finder end |
#construct_interpreter ⇒ Object (readonly)
Returns the value of attribute construct_interpreter.
11 12 13 |
# File 'lib/nickel/nlp.rb', line 11 def construct_interpreter @construct_interpreter end |
#input_date ⇒ Object (readonly)
Returns the value of attribute input_date.
10 11 12 |
# File 'lib/nickel/nlp.rb', line 10 def input_date @input_date end |
#input_time ⇒ Object (readonly)
Returns the value of attribute input_time.
10 11 12 |
# File 'lib/nickel/nlp.rb', line 10 def input_time @input_time end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
12 13 14 |
# File 'lib/nickel/nlp.rb', line 12 def @message end |
#nlp_query ⇒ Object (readonly)
Returns the value of attribute nlp_query.
10 11 12 |
# File 'lib/nickel/nlp.rb', line 10 def nlp_query @nlp_query end |
#occurrences ⇒ Object (readonly)
Returns the value of attribute occurrences.
12 13 14 |
# File 'lib/nickel/nlp.rb', line 12 def occurrences @occurrences end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
10 11 12 |
# File 'lib/nickel/nlp.rb', line 10 def query @query end |
Instance Method Details
#inspect ⇒ Object
38 39 40 |
# File 'lib/nickel/nlp.rb', line 38 def inspect "message: \"#{}\", occurrences: #{occurrences.inspect}" end |
#parse ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/nickel/nlp.rb', line 22 def parse @nlp_query = NLPQuery.new(@query).standardize # standardizes the query @construct_finder = ConstructFinder.new(@nlp_query, @input_date, @input_time) @construct_finder.run correct_case @construct_interpreter = ConstructInterpreter.new(@construct_finder.constructs, @input_date) # input_date only needed for wrappers @construct_interpreter.run @occurrences = @construct_interpreter.occurrences.each { |occ| occ.finalize(@input_date) } # finds start and end dates @occurrences.sort_by(&:start_date) @occurrences end |