Skip to content

Instantly share code, notes, and snippets.

@langsdlc
Forked from CliffordAnderson/entities-ead.xqy
Last active August 18, 2017 16:10
Show Gist options
  • Save langsdlc/0835ce08f2f2fd5e7dffef860049cf36 to your computer and use it in GitHub Desktop.
Save langsdlc/0835ce08f2f2fd5e7dffef860049cf36 to your computer and use it in GitHub Desktop.
Entity Extraction with Rosette
xquery version "3.1";
declare namespace ead = "urn:isbn:1-931666-22-9";
declare namespace http = "http://expath.org/ns/http-client";
let $texts := fn:doc("https://raw.githubusercontent.com/HeardLibrary/finding-aids/master/rosenzweig.xml")//ead:item/text()
for $text in $texts
let $json := map {
"content" : fn:normalize-space($text),
"genre" : "social-media"
} => json:serialize()
let $url := "https://api.rosette.com/rest/v1/entities"
let $request :=
<http:request href="{$url}" method="post">
<http:header name="X-RosetteAPI-Key" value="[]"/>
<http:header name="Content-Type" value="application/json"/>
<http:header name="Cache-Control" value="no-cache"/>
<http:body media-type='application/json'>{$json}</http:body>
</http:request>
let $response := http:send-request($request)[2]
where $response/json/entities/_
return $response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment