/
Finding sentences by attribute value

Finding sentences by attribute value

Let's assume we want find a sentence based on its Module-ID. The endpoint to be used is <host>/Congree/api/AuthoringMemory/v1/Sentence

This endpoint has two optional parameters:

ParameterDescription
skipAmount of the matched sentences to be skipped
countAmount of the matched sentences to be requested

The body of the request contains the query as JSON object.

{
  "Attributes": [
    {
      "Name": "string",
      "Values": [
        "string"
      ]
    }
  ]
}
PropertyDescription
AttributesAn array of attributes used as the search criteria
NameThe name of the attribute
ValuesAn array of strings containing the values of the attribute

If we want to search for a sentence who's Module-ID is 3333 the JSON object looks like this:

{
  "Attributes": [
    {
      "Name": "Module-ID",
      "Values": [
        "3333"
      ]
    }
  ]
}

A method to integrate everything looks like this:

public string FindSentencesByAttributes(string host, string token, string json){
	var client = new RestClient(host + "/Congree/api/AuthoringMemory/v1/Sentences");
	client.Timeout = -1;
	var request = new RestRequest(Method.GET);
	request.AddHeader("Authorization", "Bearer " + token);
	request.AddHeader("Content-Type", "application/json");
	var body = json;
	request.AddParameter("application/json", body,  ParameterType.RequestBody);
	IRestResponse response = client.Execute(request);
	return response.Content;
}

The reponse is a JSON object containing an array like this:

[
    {
        "Id": 699534,
        "Xml": "My sentence.",
        "Attributes": [
            {
                "Name": "Module-ID",
                "Values": [
                    "3333"
                ]
            }
        ]
    }
]
PropertyDescription
IdThe Id of the sentence in the Authoring Memory
XmlThe sentence that was found
AttributesAn array of all attributes belonging to the sentence.
NameThe name of the attribute
ValuesAn array of strings, i.e. attribute values, assigned to the attribute

Related content

Finding sentences by attribute value
Finding sentences by attribute value
More like this
Adding attributes to a sentence
Adding attributes to a sentence
More like this
Adding attributes to a sentence
Adding attributes to a sentence
More like this
AuthoringMemory
AuthoringMemory
More like this
AuthoringMemory
AuthoringMemory
More like this
Defining Attributes
Defining Attributes
More like this