Class: Excite::Token
- Inherits:
-
Object
- Object
- Excite::Token
- Defined in:
- lib/excite/crfparser.rb
Instance Attribute Summary collapse
-
#idx_in_node ⇒ Object
readonly
Returns the value of attribute idx_in_node.
-
#label ⇒ Object
Returns the value of attribute label.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#node_token_count ⇒ Object
readonly
Returns the value of attribute node_token_count.
-
#part_of_speech ⇒ Object
readonly
Returns the value of attribute part_of_speech.
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #for_join(prev) ⇒ Object
-
#initialize(str, part_of_speech = nil) ⇒ Token
constructor
A new instance of Token.
- #is_in_node!(node, idx_in_node, node_token_count) ⇒ Object
- #lcnp ⇒ Object
- #np ⇒ Object
- #raw ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(str, part_of_speech = nil) ⇒ Token
Returns a new instance of Token.
280 281 282 283 |
# File 'lib/excite/crfparser.rb', line 280 def initialize(str, part_of_speech=nil) @str = str @part_of_speech = part_of_speech end |
Instance Attribute Details
#idx_in_node ⇒ Object (readonly)
Returns the value of attribute idx_in_node.
277 278 279 |
# File 'lib/excite/crfparser.rb', line 277 def idx_in_node @idx_in_node end |
#label ⇒ Object
Returns the value of attribute label.
278 279 280 |
# File 'lib/excite/crfparser.rb', line 278 def label @label end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
277 278 279 |
# File 'lib/excite/crfparser.rb', line 277 def node @node end |
#node_token_count ⇒ Object (readonly)
Returns the value of attribute node_token_count.
277 278 279 |
# File 'lib/excite/crfparser.rb', line 277 def node_token_count @node_token_count end |
#part_of_speech ⇒ Object (readonly)
Returns the value of attribute part_of_speech.
277 278 279 |
# File 'lib/excite/crfparser.rb', line 277 def part_of_speech @part_of_speech end |
Instance Method Details
#empty? ⇒ Boolean
303 304 305 |
# File 'lib/excite/crfparser.rb', line 303 def empty? raw.strip.blank? end |
#for_join(prev) ⇒ Object
311 312 313 314 315 316 317 318 319 |
# File 'lib/excite/crfparser.rb', line 311 def for_join(prev) if ['pp','ppc','ppr','pps','rrb', 'pos'].include?(part_of_speech) raw elsif prev && ['ppd','ppl','lrb'].include?(prev.part_of_speech) raw else " "+raw end end |
#is_in_node!(node, idx_in_node, node_token_count) ⇒ Object
285 286 287 288 289 |
# File 'lib/excite/crfparser.rb', line 285 def is_in_node!(node, idx_in_node, node_token_count) @node = node @idx_in_node = idx_in_node @node_token_count = node_token_count end |
#lcnp ⇒ Object
299 300 301 |
# File 'lib/excite/crfparser.rb', line 299 def lcnp @lcnp ||= np == "EMPTY" ? np : np.downcase end |
#np ⇒ Object
295 296 297 |
# File 'lib/excite/crfparser.rb', line 295 def np @np ||= CRFParser.strip_punct(@str) end |
#raw ⇒ Object
291 292 293 |
# File 'lib/excite/crfparser.rb', line 291 def raw @str end |
#to_s ⇒ Object
307 308 309 |
# File 'lib/excite/crfparser.rb', line 307 def to_s "{#{raw}}" end |