How to use Apche Tika Server for NER - named-entity-recognition

I am checking out Tika for an NER task and running the NER example. I can get my file meta data by hitting the documented meta endpoint:
curl -T test.txt http://localhost:9998/meta --header "Accept: application/json" | jq
How do I do NER?

Related

Unable to add a group member using microsoft graph api in a bash script

If I run below http script from the graph.microsoft.com docs, it works fine.
POST https://graph.microsoft.com/v1.0/groups/9746dce-f530182/members/$ref
Content-type: application/json
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJub25jZSI6Il9Y-pCiTwLhttVX5wg
{
"#odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/e7cb-2f96bba6"
}
where:
9746dce-f530182 = group-id,
e7cb-2f96bba6 = user-id and
eyJ0eXAiOiJKV1QiLCJub25jZSI6Il9Y-pCiTwLhttVX5wg = auth-token
I would like to run this as a bash script, so that I can automate the token generation and the POST call. My script looks like so.
CLIENT_ID='283f4d25-87bde0ef'
TENANT_ID='2d987312-a4ff5ea0'
CLIENT_SECRET='XSY8Q~4Ls-ahi'
GROUP_ID="9746dc-00182"
USER_ID='e7cb46-bbbba6'
AT_URL="https://login.microsoftonline.com/${TENANT_ID}/oauth2/token"
auth_response=$(curl -X POST -d 'grant_type=client_credentials&client_id='${CLIENT_ID}'&client_secret='$CLIENT_SECRET'&resource=https://graph.microsoft.com' $AT_URL | jq .)
token="$(echo $auth_response | jq -r .token_type) $(echo $auth_response | jq -r .access_token)"
curl -H "Authorization: $token" -H "Content-type: application/json" -d '{"#odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/'$USER_ID'"}' "https://graph.microsoft.com/v1.0/groups/$GROUP_ID/members/$ref"
But this fails with the below error. What am I missing?
{"error":{"code":"Request_BadRequest","message":"Unsupported resource type 'DirectoryObject' for operation 'Create'.","innerError":{"date":"2022-05-25T11:24:21","request-id":"e189dc-063e","client-request-id":"e189d-2e42063e"}}}
I managed to fis the issue by changing the last line of the script to the following. The problem was that the $ref at the end of the URL was treated as a bash variable.
curl -H "Authorization: $token" -H "Content-Type: application/json" -d '{"#odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/'${USER_ID}'"}' 'https://graph.microsoft.com/v1.0/groups/'$GROUP_ID'/members/$ref'
Hope this helps someone else.
The final script looks like below
CLIENT_ID='283f4d25-87bde0ef'
TENANT_ID='2d987312-a4ff5ea0'
CLIENT_SECRET='XSY8Q~4Ls-ahi'
GROUP_ID="9746dc-00182"
USER_ID='e7cb46-bbbba6'
AT_URL="https://login.microsoftonline.com/${TENANT_ID}/oauth2/token"
auth_response=$(curl -X POST -d 'grant_type=client_credentials&client_id='${CLIENT_ID}'&client_secret='$CLIENT_SECRET'&resource=https://graph.microsoft.com' $AT_URL | jq .)
token="$(echo $auth_response | jq -r .token_type) $(echo $auth_response | jq -r .access_token)"
curl -H "Authorization: $token" -H "Content-Type: application/json" -d '{"#odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/'${USER_ID}'"}' 'https://graph.microsoft.com/v1.0/groups/'$GROUP_ID'/members/$ref'

Spring cloud skipper Cannot upload a package via REST API

I am following a doc to upload a package into Skipper Server at https://docs.spring.io/spring-cloud-skipper/docs/current-SNAPSHOT/reference/htmlsingle/#resources-package
Here is a package: Helloworld
This is curl command as
$ curl 'http://localhost:7577/api/package/upload' -i -X POST \
-H 'Content-Type: application/json;charset=UTF-8' \
-H 'Accept: application/json' \
-F 'data=/home/user1/helloworld-1.0.0.zip'
But still cannot upload a package. Please help me what's correct to upload a package to Skipper via REST API.
P.s: By using a POSTMAN but It's also impossible.
I found it how to do on old doc from spring team.
Post here if someone is needed.
https://docs.spring.io/spring-cloud-skipper/docs/1.0.0.BUILD-SNAPSHOT/reference/html/api-guide-resources.html#resources-package

How to Get All Tags from Docker Hub (Private Repositories) as Shell Script

I have one shell script when i execute it showing only 64 tags from 300 tags docker hub.
Here is the below command which i'm executing in shell script through curl.
IMAGE_TAGS=$(curl -s -H "Authorization: JWT ${HUB_TOKEN} https://hub.docker.com/v2/repositories/$username/issues/tags/?page_size=300" | jq --raw-output '.results[] | .name')
Even after giving page_size also it is not showing my all tags
Note :- Tags using for Private Repositories
Please help me how can i solve it
Try API version 1 which help me to get all the tags
https://registry.hub.docker.com/v1/repositories/mysql/tags open in browser and you can modify it as per your need
Or have a look to Github https://gist.github.com/robv8r/fa66f5e0fdf001f425fe9facf2db6d49 This is exactly what you want
UPDATE
Add this in a shell script file
#!/usr/bin/env bash
docker-tags() {
arr=("$#")
for item in "${arr[#]}";
do
tokenUri="https://auth.docker.io/token"
data=("service=registry.docker.io" "scope=repository:$item:pull")
token="$(curl --silent --get --data-urlencode ${data[0]} --data-urlencode ${data[1]} $tokenUri | jq --raw-output '.token')"
listUri="https://registry-1.docker.io/v2/$item/tags/list"
authz="Authorization: Bearer $token"
result="$(curl --silent --get -H "Accept: application/json" -H "Authorization: Bearer $token" $listUri | jq --raw-output '.')"
echo $result
done
}
docker-tags "<YOUR_DOCKER_IMAGE_NAME>"
Replace <YOUR_DOCKER_IMAGE_NAME> with your docker image.
have a look to this for more info Listing the tags of a Docker image on a Docker hub through the HTTP API

Bash CLI with HTTParty and rails to handle multiple headers one of which includes a slash

The following connects to the API's server
httparty -a post -H Content-Type:application/json "https://test.co.uk/interface/search"
and returns an error message (which is by design).
However, if another header is added:
httparty -a post -H Content-Type:application/json -H Accept-Encoding:gzip,deflate "https://test.co.uk/interface/search"
an error occurs in the ruby JSON parser
.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/json-2.1.0/lib/json/common.rb:156:in
`parse': 765: unexpected token at '' (JSON::ParserError)
No amount of escaping with quotes changes the situation.
httparty -a post -H 'Content-Type:application/json' -H Accept-Encoding:gzip,deflate "https://test.co.uk/interface/search"
same error...
On the other hand, if one excludes the 'application/json' header, multiple headers can be submitted, obtaining a server response (same error message from API server).
httparty -a post -H Accept-Encoding:gzip,deflate -H Content-Length:578 -H Host:test.co.uk -H Connection:Keep-Alive "https://test.co.uk/interface/search"
How can multiple headers be submitted, with the 'application/json' string pass ruby's JSON parsing filter?
Personally I use HTTPie, try to curl like this way.
curl -H "Accept-Encoding:gzip,deflate" \
-H "Content-Length:578" \
-H "Host:test.co.uk" \
-H "Connection:Keep-Alive" \
-X POST \
"https://test.co.uk/interface/search"

multipart POST with nested params cUrl

I'm trying to test making a post request with cURL passing a file into nested params, but having a hard time getting the flags/ordering correct:
curl -i -H "Authorization: <access_str>" -H "Accept: application/json"
-H "Content-Type: application/json" -X POST -d '{"data": {"photo":
"#/Users/colin/Desktop/mastiff.jpg"} }' localhost:3000/api/v1/blah/blah
I feel like I either need a --data-binary or -F or both maybe? The server is just getting the nested params as a string and not as a multipart file
{"data"=>{"photo"=>"#/Users/colin/Desktop/mastiff.jpg"}
curl -i -H "Authorization: <access_str>" -X POST -F
'data[photo]=#/Users/colin/Desktop/mastiff.jpg'
localhost:3000/api/v1/data/data/data
Don't even need to specify that it's JSON. Next step is trying to pass two photos in the same field. The problem now is that passing a second file results in a massive binary string.

Resources