Class: Stockade::Lexemes::Dict
- Inherits:
-
Base
- Object
- Base
- Stockade::Lexemes::Dict
show all
- Extended by:
- Memoist
- Defined in:
- lib/stockade/lexemes/dict.rb
Overview
Abstract Dictionary lexeme
Dictionary lexemes are those that can only be verified by checking the corresponding dictionary
Instance Attribute Summary
Attributes inherited from Base
#raw_value, #start_pos
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#==, #end_pos, #initialize, #mask, #range, #token, #type, types, #value
Class Method Details
.dict ⇒ Object
39
40
41
|
# File 'lib/stockade/lexemes/dict.rb', line 39
def dict
Rambling::Trie.load("data/#{dict_name}.zip")
end
|
.dict_name ⇒ Object
37
|
# File 'lib/stockade/lexemes/dict.rb', line 37
def dict_name; end
|
.regex ⇒ Object
11
12
13
14
15
|
# File 'lib/stockade/lexemes/dict.rb', line 11
def self.regex
/
[a-zA-Z]+
/x
end
|
Instance Method Details
#capitalized? ⇒ Boolean
30
31
32
|
# File 'lib/stockade/lexemes/dict.rb', line 30
def capitalized?
raw_value[0] == raw_value[0].upcase
end
|
#common_word? ⇒ Boolean
26
27
28
|
# File 'lib/stockade/lexemes/dict.rb', line 26
def common_word?
Word.new(value: value).valid?
end
|
#name ⇒ Object
22
23
24
|
# File 'lib/stockade/lexemes/dict.rb', line 22
def name
raise 'Abstract'
end
|
#valid? ⇒ Boolean
17
18
19
20
|
# File 'lib/stockade/lexemes/dict.rb', line 17
def valid?
return false unless self.class.dict
self.class.dict.include?(value)
end
|