-
Notifications
You must be signed in to change notification settings - Fork 12
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
I'm working with s-expressions from an NLP parser, and I'm having difficulty parsing items as a string into symbols without raising float errors.
For the following s-expression string:
(ROOT (NP (FRAG (CC And) (-LRB- -LRB-) (NP (NNP Gen.) (CD 32) (. .) (CD 1.)) (-RRB- -RRB-) (PP (IN in) (NP (NP (DT a) (NNP Vision)) (PP (IN of) (NP (NNPS Angels)))))) (: :) (CC And) (PP (IN to) (NP (NP (NNP Moses)) (-LRB- -LRB-) (NP (NP (NN Exod.)) (NP (CD 3.2.))) (-RRB- -RRB-))) (PP (IN in) (NP (NP (DT the) (NN apparition)) (PP (IN of) (NP (DT a) (NN flame)))))))
The SXP parser errors with:
ArgumentError: invalid value for Float(): "1."
To reproduce
Steps to reproduce the behavior:
- copy this code:
s_expression = "(ROOT (NP (FRAG (CC And) (LRB -LRB-) (NP (NNP Gen.) (CD 32) (PUNCTUATION .) (CD 1.)) (RRB -RRB-) (PP (IN in) (NP (NP (DT a) (NNP Vision)) (PP (IN of) (NP (NNPS Angels)))))) (: :) (CC And) (PP (IN to) (NP (NP (NNP Moses)) (LRB -LRB-) (NP (NP (NN Exod.)) (NP (CD 3.2.))) (RRB -RRB-))) (PP (IN in) (NP (NP (DT the) (NN apparition)) (PP (IN of) (NP (DT a) (NN flame)))))))"
SXP.read(s_expression)
- See error
Expected behavior
SXP parses the nodes as strings rather than as numericals. I want characters like periods to be seen as strings.
Desktop (please complete the following information):
- OS: [Mac OS Monteray]
Additional context
It appears a possible fix for our problem is monkey patching the gem to remove numerical parsing altogether:
module SXP
class Reader
class Basic < Reader
## Monkey patch, we don't need numerics
# @return [Object]
def read_atom
case buffer = read_literal
when '.' then buffer.to_sym
else buffer.to_sym
end
end
end
end
end
I would like your advice on if that's correct and insight into if there is a way to fix this within the gem, perhaps as a form of configuration.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working