Adding parameters to the POST Analyze method - microsoft-cognitive

https://westus2.dev.cognitive.microsoft.com/docs/services/form-recognizer-api/operations/AnalyzeWithCustomModel
In the above documentation there is the following URL which implies you ought to be able to analyze a form for a specific Key value
https://{endpoint}/formrecognizer/v1.0-preview/custom/models/{id}/analyze[?keys]
I have trained a model of my own and when I use the Get Keys method this is what gets returned...
{"clusters":{"0":["House Name","Mobile Number","Name","Phone Number","Postcode","Street","Sumame","Town Name","e-Mail Address (required)"]}}
It seems to me that I ought to be able to execute that post against any one of those key values. So....
https://{endpoint}/formrecognizer/v1.0-preview/custom/models/{id}/analyze?keys=Name
Should pull back whatever the value is associated with the Name key (and there is a value) but instead I get a 200 success and no workable information.
"status": "success",
"pages": [
{
"number": 1,
"height": 756,
"width": 471,
"clusterId": null,
"keyValuePairs": [],
"tables": []
}
],
"errors": []
}
I think I am misunderstanding how to do this properly

Are you able to see the key and an associated value when you try the /analyze call without the query param "keys"?

Related

Firestore Pagination : how to set Cursor for startAt using Rest Api

I'm using firebase firestore using Rest API to get data limited by 5 documents only, ordered by a field called LikesCount.
When I want to fetch the next 5 documents I have to use startAt and pass the LikesCount value of the last document from the first 5 documents.
But in this way, it will fetch wrong data when there is another document with the same LikesCount value So I tried and searched a lot about how to pass the last Document id in addition to the LikesCount value But all of them did not work In addition, I tested the pagination using the Web SDK and it was working correctly because you can pass the document snapshot easily, but what does the document snapshot object include? So that we can understand the structure of the Cursor and apply it to the REST API.
I tried to use this method to pass the Document ID as referenceValue
{
"structuredQuery": {
"from": [{
"collectionId": "Users"
}],
"where": {
"compositeFilter": {
"op": "AND",
"filters": []
}
},
"orderBy": [{
"field": {
"fieldPath": "LikesCount"
},
"direction": "DESCENDING"
}],
"startAt":
{ "values": [
{
"integerValue": "6"
},
{
"referenceValue": "projects/myprojectid/databases/(default)/documents/Posts/xEvmJ1LLHwTKVREQfXtX"
}
],
"before": false
},
"limit":5
}
}
But an error will occur : Cursor has too many values.
also, I tried to pass only the referenceValue and it still did not return the correct 5 documents.
Thanks in advance :)
Your orderBy() has 1 field (LikesCount) but your startAt() has 2 fields. I suspect that is the reason for the error message?
Passing the integerValue won't work. If there are 13 results with the value 6, then each time you make the above call you'd get the same first 5 results.
When you say:
I tried only passing the referenceValue and still did not get the correct 5 documents
what documents are you getting? What documents were you expecting to get?

Find and delete Discord webhook message

I'm using a Discord webhook to send information which may later be invalidated, so I want to be able to delete it. To do this i use these endpoints:
First i make a post request to send a message:
POST /webhooks/{webhook.id}/{webhook.token}
And then i want to do a delete request to remove the message again:
DELETE /webhooks/{webhook.id}/{webhook.token}/messages/{message.id}
However I don't have the ID of the message i want to delete, since no response is given to the first POST request which is always an empty 204 response. Is it possible to get the message id?
Any help would be appreciated.
Per this reddit post:
If you need to reference a message ID of a webhook message you sent, you can add ?wait=true to the end of the URL which will give you the message data (including the ID) instead of a 204 (No Content) when you don't include the query parameter.
So if you send your normal POST request to your url like this: POST /webhooks/{webhook.id}/{webhook.token}, add ?wait=true to the end of that. Then you will get back data like this:
{
"id": "MESSAGEID",
"type": 0,
"content": "This is a test",
"channel_id": "CHANNELID",
"author": {
"bot": true,
"id": "AUTHORID",
"username": "USERNAME",
"avatar": "AVATARID",
"discriminator": "0000"
},
"attachments": [],
"embeds": [],
"mentions": [],
"mention_roles": [],
"pinned": false,
"mention_everyone": false,
"tts": false,
"timestamp": "2021-11-13T18:10:24.412000+00:00",
"edited_timestamp": null,
"flags": 0,
"components": [],
"webhook_id": "WEBHOOKID"
}

Workfront API: Human readable status for Issues and Projects

https://support.workfront.com/hc/en-us/articles/115003574147-API-Basics
https://support.workfront.com/hc/en-us/categories/202718477
Querying objects (i.e.: GET /attask/api/v9.0/project/4c78821c0000d6fa8d5e52f07a1d54d0) returns a response similar to the following:
..
"status": "INP",
...
How do you get human readable statuses form these responses? Do you hard-code all possible values, or, can it be achieved using queries?
i.e.: "INP" > "In Progress"
You can pull these values from the Custom Enumeration tables (CSTEM). For example, this will return all the task descriptions:
https://subdomain.my.workfront.com/attask/api/v9.0/CSTEM/search?apiKey={{apiKey}}&fields=*&enumClass=STATUS_TASK&enumClass_Mod=in
You will get something like this:
{
"color": "FF3939",
"equatesWith": "CPL",
"groupID": "5419c94f00004a056282a15eed58e47f",
"label": "Complete",
"objCode": "CSTEM",
"value": "CPL",
"ID": "57ed3a2000477cfb7368beb5d995bf88",
"customerID": "540f5a3f0019b...",
"description": "Task is fully completed",
"enumClass": "STATUS_TASK",
"extRefID": null,
"isPrimary": true,
"valueAsInt": null,
"valueAsString": "CPL"
},
For issues use "STATUS_OPTASK".
I created a dictionary and translating the statuses while reading the short version (INP > In Progress)

How to get notifications that have Edge date property greater than last visited date in Titan using Gremlin?

I'm having user vertices which have incoming Notification edges as follows:
code am using to get notifications
g.v(17929472).outE('Notification')
Response I'm getting :
{
"success": true,
"results": [
{
"Type": "UserReaction",
"PostedDate": "2016-04-15T09:03:42.8391677Z",
"NotificationInitiatedByVertexId": "2304",
"_id": "c7bb4-aoagw-sgl-aoao0",
"_type": "edge",
"_outV": 17929472,
"_inV": 17929728,
"_label": "Notification"
}
],
"version": "2.5.0",
"queryTime": 15.310751
}
Whenever user view the notification i'm saving the last seen date and want to use that date to get all notification that is present after that date.
I've tried :
g.v((5124096).outE).outE.has('PostedDate',T.gte, 2016-04-15T07:52:31.6979843Z).inV
but it is giving error.
PostedDate appears to be returned as a String. Consider defining PostedDate in your schema definition as a Long instead, and then do the T.gte comparison with a Long value.

"Reverse formatting" Riak search results

Let's say I have an object in the test bucket in my Riak installation with the following structure:
{
"animals": {
"dog": "woof",
"cat: "miaow",
"cow": "moo"
}
}
When performing a search request for this object, the structure of the search results is as follows:
{
"responseHeader": {
"status": 0,
"QTime": 3,
"params": {
"q": "animals_cow:moo",
"q.op": "or",
"filter":"",
"wt": "json"
}
},
"response": {
"numFound": 1,
"start": 0,
"maxScore": "0.353553",
"docs": [
{
"id": "test",
"index": "test",
"fields": {
"animals_cat": "miaow",
"animals_cow": "moo",
"animals_dog": "woof"
},
"props": {}
}
]
}
}
As you can see, the way the object is stored, the cat, cow and dog keys are nested within animals. However, when the search results come back, none of the keys are nested, and are simply separated by _.
My question is this: Is there any way provided by Riak to "reverse format" the search, and return the fields of the object in the correct (nested) format? This becomes a problem when storing and returning user data that might possibly contain _.
I do see that the latest version of Riak (beta release) provides a search schema, but I can't seem to see whether my question would be answered by this.
What you receive back in the search result is what the object looked like after passing through the json analyzer. If you need the data formatted differently, you can use a custom analyzer. However, this will only affect newly put data.
For existing data, you can use the id field and issue a get request for the original object, or use the solr query as input to a MapReduce job.

Resources