Methods
call(user, document_name, textopt, tagged_elementsopt, metaopt) → {Promise.<Object>}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
user |
string | The ID of the user accessing the Soffos API. Soffos assumes that the owner of the api is an application (app) and that app has users. Soffos API will accept any string. | ||
document_name |
string | The name of the document. | ||
text |
string |
<optional> |
null | Required when tagged_elements is not provided. Only one of text and tagged_elements can be provided. The text content of the document. |
tagged_elements |
object |
<optional> |
null | Required when text is not provided. Only one of text and tagged_elements can be provided. A list of dictionaries representing tagged spans of text extracted from a document file. This field accepts the value of the tagged_elements or normalized_tagged_elements field from the output of the File Converter module. Therefore, it requires each element to contain the text and tag fields and any non-heading element to contain a headings field which is also a list of dictionaries where each dictionary should contain the fields text and tag. |
meta |
object |
<optional> |
null | A dictionary containing metadata fields for tagging the document. The keys should be string and the values can be any type, such as string, integer, boolean etc. This allows document filtering based on the meta fields. Due to name being a mandatory field provided independently, if a name field is included in meta it will be ignored. |
- Source:
Returns:
document_id - string
The unique id of the ingested document. It's crucial to store the document_id in order to be able to reference this document later on when calling other modules.
The unique id of the ingested document. It's crucial to store the document_id in order to be able to reference this document later on when calling other modules.
- Type
- Promise.<Object>
Example
import { SoffosServices } from "soffosai";
const my_apiKey = "Token <put your api key here>";
const service = new SoffosServices.DocumentsIngestService({apiKey:my_apiKey});
let response = await service.call(
"client 987654321",
'dogs',
"Genetic evidence suggests that dogs descended directly from wolves (Canis) and \
that the now-extinct wolf lineages that produced dogs branched off from the line \
that produced modern living wolves sometime between 27,000 and 40,000 years ago. \
The timing and location of dog domestication is a matter of debate. \
There is strong genetic evidence, however, that the first domestication events occurred \
somewhere in northern Eurasia between 14,000 and 29,000 years ago.",
);
console.log(JSON.stringify(response, null, 2));
// returns
// {
// "document_id": "0d059b3bf66b4ecfa124c175a6d3cd45",
// "success": true,
// "filtered": {
// "passages": [],
// "reason": "Unable to process due to bad structure."
// },
// "cost": {
// "api_call_cost": 0.005,
// "character_volume_cost": 0.02415,
// "total_cost": 0.02915
// },
// "charged_character_count": 483,
// "unit_price": "0.000050"
// }
setInputConfigs(name, document_name, textopt, tagged_elementsopt, metaopt)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name |
string | Reference name of this Service. It will be used by the Pipeline to reference this Service. | ||
document_name |
string | InputConfig | The name of the document. | ||
text |
string | InputConfig |
<optional> |
null | Required when tagged_elements is not provided. Only one of text and tagged_elements can be provided. The text content of the document. |
tagged_elements |
object | InputConfig |
<optional> |
null | Required when text is not provided. Only one of text and tagged_elements can be provided. A list of dictionaries representing tagged spans of text extracted from a document file. This field accepts the value of the tagged_elements or normalized_tagged_elements field from the output of the File Converter module. Therefore, it requires each element to contain the text and tag fields and any non-heading element to contain a headings field which is also a list of dictionaries where each dictionary should contain the fields text and tag. |
meta |
object | InputConfig |
<optional> |
null | A dictionary containing metadata fields for tagging the document. The keys should be string and the values can be any type, such as string, integer, boolean etc. This allows document filtering based on the meta fields. Due to name being a mandatory field provided independently, if a name field is included in meta it will be ignored. |
- Source: