Exemplo n.º 1
0
        /// <summary>
        /// Loads a finetune collection into memory for useage.
        /// </summary>
        /// <param name="collectionName">Name of the custom collection to load</param>
        /// <returns>An object describing the custom collection</returns>
        public async Task <FinetuneCollection> Load(string collectionName)
        {
            // If the collection is already ready, don't re-load.
            FinetuneCollection collectionInfo = await this.Info(collectionName);

            if (collectionInfo.LoadStatus == "ready")
            {
                return(collectionInfo);
            }

            // Kick off load job
            string jobID = await StartModelLoad(collectionName);

            while (true)
            {
                await Task.Delay(pollDelay);

                AsyncJobStatus jobStatus = await GetStatus(jobID);

                if (jobStatus == AsyncJobStatus.Success)
                {
                    break;
                }
                else if (jobStatus == AsyncJobStatus.Failure || jobStatus == AsyncJobStatus.Revoked)
                {
                    throw new IndicoAPIException("Load Failed");
                }
            }

            return(await GetResults <FinetuneCollection>(jobID));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Batch annotation predictions for a set of data.
        /// </summary>
        /// <param name="collectionName">Name of the custom collection to predict with</param>
        /// <param name="examples">Array of strings to get predictions for</param>
        /// <returns></returns>
        public async Task <List <List <FinetuneExtraction> > > PredictAnnotation(string collectionName, string[] examples)
        {
            string jobID = await StartPrediction(collectionName, examples);

            while (true)
            {
                await Task.Delay(pollDelay);

                AsyncJobStatus jobStatus = await GetStatus(jobID);

                if (jobStatus == AsyncJobStatus.Success)
                {
                    break;
                }
                else if (jobStatus == AsyncJobStatus.Failure || jobStatus == AsyncJobStatus.Revoked)
                {
                    throw new IndicoAPIException("Prediction Failed");
                }
            }

            return(await GetResults <List <List <FinetuneExtraction> > >(jobID));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Calls the indico api to extract a pdf via the jobs system
        /// </summary>
        /// <param name="inputValue">Base64 Encoded PDF File</param>
        /// <param name="ocrFlag">True to Perform OCR Extraction</param>
        /// <param name="textFlag">Return extracted page Text</param>
        /// <param name="metadataFlag">Return extracted document metata</param>
        /// <param name="tablesFlag">Return extracted tables</param>
        /// <param name="singleColumnFlag">True to treat the document as a single column of text.</param>
        /// <returns>Extracted PDF Object</returns>
        public async Task <ExtractedPDF> ExtractPDF(string inputValue, bool ocrFlag = false, bool textFlag = true, bool metadataFlag = false,
                                                    bool tablesFlag = false, bool singleColumnFlag         = true)
        {
            string jobID = await StartExtraction(inputValue, ocrFlag, textFlag, metadataFlag, tablesFlag, singleColumnFlag);

            while (true)
            {
                await Task.Delay(pollDelay);

                AsyncJobStatus jobStatus = await GetStatus(jobID);

                if (jobStatus == AsyncJobStatus.Success)
                {
                    break;
                }
                else if (jobStatus == AsyncJobStatus.Failure || jobStatus == AsyncJobStatus.Revoked)
                {
                    throw new IndicoAPIException("Prediction Failed");
                }
            }

            return(await GetResults <ExtractedPDF>(jobID));
        }
Exemplo n.º 4
0
 public JobStatusResponse(AsyncJobStatus results)
 {
     Results = results;
 }