louismullie / treat

Natural language processing framework for Ruby.
Other
1.36k stars 128 forks source link

XML Serialize ":" punctuation bug #43

Closed zkt closed 11 years ago

zkt commented 11 years ago

Colon punctuation in XML file like this <punctuation id='2157138080' tag=':' >;</punctuation>

Throws this error /Users/zkt/.rvm/gems/ruby-1.9.3-p327/gems/treat-2.0.4/lib/treat/core/dsl.rb:17:in method_missing': undefined methodto_i' for :"":Symbol (NoMethodError) from /Users/zkt/.rvm/gems/ruby-1.9.3-p327/gems/treat-2.0.4/lib/treat/workers/formatters/unserializers/xml.rb:68:in block in unserialize' from /Users/zkt/.rvm/gems/ruby-1.9.3-p327/gems/treat-2.0.4/lib/treat/workers/formatters/unserializers/xml.rb:40:ineach_pair' from /Users/zkt/.rvm/gems/ruby-1.9.3-p327/gems/treat-2.0.4/lib/treat/workers/formatters/unserializers/xml.rb:40:in unserialize' from /Users/zkt/.rvm/gems/ruby-1.9.3-p327/gems/treat-2.0.4/lib/treat/entities/entity/delegatable.rb:66:incall_worker' from /Users/zkt/.rvm/gems/ruby-1.9.3-p327/gems/treat-2.0.4/lib/treat/entities/entity/delegatable.rb:40:in block (2 levels) in add_workers' from /Users/zkt/.rvm/gems/ruby-1.9.3-p327/gems/treat-2.0.4/lib/treat/entities/entity/buildable.rb:264:infrom_serialized_file' from /Users/zkt/.rvm/gems/ruby-1.9.3-p327/gems/treat-2.0.4/lib/treat/entities/entity/buildable.rb:213:in from_file' from /Users/zkt/.rvm/gems/ruby-1.9.3-p327/gems/treat-2.0.4/lib/treat/entities/entity/buildable.rb:55:inbuild' from /Users/zkt/.rvm/gems/ruby-1.9.3-p327/gems/treat-2.0.4/lib/treat/core/dsl.rb:12:in method_missing' from lib/pre_test.rb:208:inblock in

' from lib/pre_test.rb:205:in each' from lib/pre_test.rb:205:in

In the workers/formaters/unserializers/xml.rb file is the following code (lines 67 and 68) which causes the error it produces an empty symbol when the colon is processed which then matches the to_i regex

 67     v = v[1..-1].intern if v[0] == ':'
 68      v = v.to_i if v =~ /^[0-9]*$/
zkt commented 11 years ago

This hack "fixes" the error

workers/formaters/unserializers/xml.rb

67           v = v[1..-1].intern if v[0] == ':'  
68            if v== ''.intern
69                v=":".intern
70            end
louismullie commented 11 years ago

Fixed in next release