Open gihanpanapitiya opened 3 years ago
All you have to do is tweak the xpath you use to access the result from the name
element. Element results are returned as a tree with whatever you assign to root
as the root and all the elements that form a part of root
as child nodes, and so on.
So you would write name = first(result.xpath('./prefix/name/text()'))
, since name
is a child of prefix
All you have to do is tweak the xpath you use to access the result from the
name
element. Element results are returned as a tree with whatever you assign toroot
as the root and all the elements that form a part ofroot
as child nodes, and so on.So you would write
name = first(result.xpath('./prefix/name/text()'))
, sincename
is a child ofprefix
I tried that, but I am still getting the same output as before.
might be the .add_action(join)
then. Seems like that merges all of the tokens and puts them in the same node. It may not be the best solution, but the first thing that comes to my mind is to capture boiling and point as separate elements and then join them within interpret()
. I'm actually curious so I'm about to do my own tests
Thanks for the suggestion! I haven't worked with interpret()
. I am going to start experimenting with it.
Does anyone knows how to write a custom parser to extract a named entity inside an entity.
For example from the following sentence I want to extract 'boiling' which will be inside the prefix entity.
d = Sentence('Synthesis of 2,4,6-trinitrotoluene (3a).The procedure was followed to yield a pale yellow solid (boiling point 240 °C)')
This is my attempt to write the parser:
However what d.records.serialize() produces is,
[{'boiling_points': [{'value': '240', 'units': '°C', 'prefix': 'boiling point'}]}]