The source code for the example application is located in the installer as
custom-application-sources.jar. You do not need to extract the file to run the example application as there is a compiled and packaged version of the code deployed with the Tomcat application server. You only need to access the source code if you want to use it as a template for your own endpoint.
The custom endpoint application includes an example application, matchSentences , which calculates the relevance of documents and sentences against a list of keywords. It combines calls to the
/semantics/vector endpoints with custom code. The custom code uses the cosine similarity function to calculate similarity scores between the sentences and the keywords, as well as comparing the scores to the input threshold value.
The input is a list of keywords, a document or the URL to a document, and a threshold.
The response is the cosine similarity scores and a true/false value indicating if the score is above the threshold for each sentence, and for the entire document.
"document": "Iran was planning attacks on four US embassies
when its top general was killed, President Donald Trump says.
When asked what threat led to last Friday's US drone strike,
he told Fox News: \"I can reveal that I believe it probably
would've been four embassies.\" \"The killing of Gen Qasem Soleimani,
a national hero, came after days of protests at the US embassy in Baghdad.",
curl -s http://localhost:8182/rest/custom/matchSentences -XPOST \
-H 'Content-Type: application/json; charset=utf-8' -d \
@matchSentences.json | jq .
How does the call know where to find the Rosette endpoints?
Look at the
<reverse_proxy_install_directory>/application.yml file. The
zuul section defines the redirects.
Wherever zuul sees the path
/rest/custom/ it replaces it with the url listed in the application file. The curl command calls
http://localhost:8182/rest/custom/matchSentences. It gets routed to