Beispiel #1
0
        /*
         * To actually run this example, you'll need to train a sequence
         * model on the Indico IPA Platform with the labeled-swaps-200.csv
         * file contained with this repo. Be aware that training will likely
         * take a couple hours. Once training is complete, you can run the
         * example by passing in the directory of the two sample PDF files in
         * the repo (Confirmation letter and Confirmation of Interest Rate Swap).
         *
         * Before running, replace the Model Group ID (mgId) with the
         * ID for your trained model. You can find it on the model's Review page.
         */
        async static Task Main(string[] args)
        {
            // Replace this with your Model Group ID
            int mgId = 4352;

            List <string> targetFiles = GetTargetFiles(args[0]);

            if (targetFiles.Count == 0)
            {
                Console.WriteLine("No files to process");
                Environment.Exit(0);
            }

            IndicoClient client = new IndicoClient();

            JObject extractConfig = new JObject()
            {
                { "preset_config", "legacy" }
            };

            List <string>      texts    = new List <string>();
            DocumentExtraction ocrQuery = client.DocumentExtraction(extractConfig);

            foreach (string path in targetFiles)
            {
                Console.WriteLine(path);
                Job ocrJob = await ocrQuery.Exec(path);

                JObject result = await ocrJob.Result();

                string resUrl = (string)result.GetValue("url");
                Blob   blob   = await client.RetrieveBlob(resUrl).Exec();

                JObject obj = blob.AsJSONObject();
                texts.Add((string)obj.GetValue("text"));
            }

            ModelGroup mg = await client.ModelGroupQuery(mgId).Exec();

            string status = await client.ModelGroupLoad(mg).Exec();

            Console.WriteLine($"Model status = {status}");

            Job job = await client.ModelGroupPredict(mg).Data(texts).Exec();

            JArray jobResult = await job.Results();

            Console.WriteLine(jobResult);
        }
        /*
         * To actually run this example, you need to train a classifier in
         * the Indico IPA Platform using the reviews.csv file included in
         * this repo. After the model is trained, just pass its model group
         * ID into this sample as a command line arg. You can find the model
         * group ID on your trained model's Review page.
         */
        private static async Task Main(string[] args)
        {
            int mgId = -1;

            if (args.Length != 1)
            {
                Console.WriteLine("Please provide model group and selected model IDs");
                System.Environment.Exit(0);
            }
            else
            {
                mgId = Int32.Parse(args[0]);
            }

            var config = new IndicoConfig(
                host: "app.indico.io"
                );

            var client = new IndicoClient(config);

            var mg = await client.ModelGroupQuery(mgId).Exec();

            // Load Model
            string status = await client.ModelGroupLoad(mg).Exec();

            var reviews = new List <string>()
            {
                "This was the best food of our trip. Fantastic experience!",
                "The service was rude and the food was awful. Don\'t waste your time!"
            };

            var job = await client.ModelGroupPredict(mg).Data(reviews).Exec();

            var jobResult = await job.Results();

            Console.WriteLine(jobResult);
        }