Created
February 16, 2009 00:27
-
-
Save tenderlove/64921 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| x.report('nokogiri:entity-extract') do | |
| N.times do | |
| doc = Nokogiri::XML(xml_content) | |
| entity = doc.at('//evriThing/entity') | |
| name = facets = properties = nil | |
| href = entity['name'] | |
| score = entity['score'].to_f | |
| id = entity['id'].to_i | |
| entity.children.each do |child| | |
| case child.name | |
| when 'facets' | |
| facets = child.children.map do |facet| | |
| { :name => facet.children.first.content } | |
| end | |
| when 'name' | |
| name = child.content | |
| when 'properties' | |
| properties = child.children.map do |property| | |
| { | |
| :provenance => property['provenance'].to_i, | |
| :linkObjectName => property['linkObjectName'], | |
| :linkInOntology => property['linkInOntology'], | |
| :linkHref => property['linkHref'], | |
| :groupNum => property['groupNum'].to_i, | |
| :name => property.children.first.content, | |
| :value => property.children[1].content | |
| } | |
| end | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment