-
-
Save langsdlc/0835ce08f2f2fd5e7dffef860049cf36 to your computer and use it in GitHub Desktop.
Entity Extraction with Rosette
This file contains 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
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