Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Created February 16, 2009 00:27
Show Gist options
  • Select an option

  • Save tenderlove/64921 to your computer and use it in GitHub Desktop.

Select an option

Save tenderlove/64921 to your computer and use it in GitHub Desktop.
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