Class: FileConverterService

FileConverterService()

The File Converter extracts text from various types of files.

Constructor

new FileConverterService()

Source:

Methods

call(user, file, normalizeopt) → {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.
file Blob The byte stream of the file. The file should not exceed 50Mb in size.
normalize number <optional>
0 Whether to perform normalization.
Source:
Returns:
text - string
Raw text extracted from the document.

tagged_elements dictionary list * A list of dictionaries of all the extracted text snippets and their tags. Each dictionary has the following fields:
text: The text of the snippet.
tag: A tag. Detectable elements: paragraph, heading, bullet_list, table_of_contents.
headings: A list of dictionaries representing the headings which this element is under. Each dictionary contains the text and tag fields of each heading. This is useful for sorting and labelling the content.
Other element-specific fields:
bullets: Available only bullet_list elements. Contains all bullets and their sub-bullets in a nested structure.
contents: Available only in table_of_content elements. Contains the headings and sub-headings of the document's table of contents.
heading: Available only in table_of_content elements. It is the heading of the document's table of contents.
normalized_text - string
Resulting text after normalization.
normalized_tagged_elements - dictionary list
Similar to the standard tagged_elements. Detectable elements: paragraph, heading, bullet_list, quote.
Type
Promise.<Object>
Example
// needs React.js or other frontend js library or framework
// assuming you have a file field with id="my_file" and a button with id="sendFileBtn"
import { SoffosServices } from 'soffosai'; // will not work if used directly to html. Please use the soffosai.bundle.js if you need to use soffosai directly to html.
const my_apiKey = 'Token <put your api key here>';

async function sendFile() {
    const theFile = document.getElementById("myFile").files[0];
    let service = new SoffosServices.FileConverterService({apiKey: my_apiKey});
    let response = await service.call("client_id", theFile);
    console.log(SON.stringify(response, null, 2));
}

document.querySelector('#sendFileBtn').addEventListener('click', sendFile);

setInputConfigs(name, file, normalizeopt)

Parameters:
Name Type Attributes Default Description
name string Reference name of this Service. It will be used by the Pipeline to reference this Service.
file Blob | InputConfig The byte stream of the file. The file should not exceed 50Mb in size.
normalize string | InputConfig <optional>
0 Whether to perform normalization.
Source: