public void runWithRawInputOutput()
        {
            Client    client    = new Client(ALGORITHMIA_API_KEY);
            Algorithm algorithm = client.algo("algo://quality/Python2xEcho");

            byte[]            bytes    = { 0, 1, 2, 3, 4 };
            AlgorithmResponse response = algorithm.pipe <byte[]>(bytes);

            Assert.AreEqual(response.result, bytes);
        }
        public void runWithList()
        {
            Client        client    = new Client(ALGORITHMIA_API_KEY);
            Algorithm     algorithm = client.algo("algo://util/Echo");
            List <String> list      = new List <String> {
                "a", "1"
            };
            AlgorithmResponse response = algorithm.pipe <List <String> >(list);

            Assert.AreEqual(response.result, list);
        }
Exemple #3
0
        public AlgorithmResponse GetAlgorithms()
        {
            var request = new RestRequest("v1/algorithms", Method.GET);

            request.AddHeader("Authorization", string.Format("Bearer {0}", this.AccessToken));
            var response = this.Client.Get(request);
            AlgorithmResponse responseObject = JsonConvert.DeserializeObject <AlgorithmResponse>(response.Content);

            responseObject.httpResponse = response;
            return(responseObject);
        }
        public void runWithStringInputOutput()
        {
            Client            client    = new Client(ALGORITHMIA_API_KEY);
            Algorithm         algorithm = client.algo("algo://util/Echo");
            AlgorithmResponse response1 = algorithm.pipe <String>("hello");

            Assert.AreEqual(response1.result, "hello");

            AlgorithmResponse response2 = algorithm.pipeJson <String>("hello");

            Assert.AreEqual(response2.result, "hello");
        }
Exemple #5
0
        public AlgorithmResponse GetAlgorithms()
        {
            var Request = new RestRequest("v1/algorithms", Method.GET);

            Request.AddHeader("Accept-Language", this.Language);
            Request.AddHeader("Authorization", string.Format("Bearer {0}", this.AccessToken));
            var Response = this.Client.Execute(Request);
            AlgorithmResponse ResponseObject = JsonConvert.DeserializeObject <AlgorithmResponse>(Response.Content);

            ResponseObject.HttpResponse = Response;
            return(ResponseObject);
        }
Exemple #6
0
        public IActionResult GetAlgorithms(
            string getAlgorithms
            )
        {
            AlgorithmResponse response = hacarusVisualInspection.GetAlgorithms();

            ViewData["HttpResponse"]  = "Status code: " + (int)response.httpResponse.StatusCode + " " + response.httpResponse.StatusCode;
            ViewData["StringMessage"] = hacarusVisualInspection.StringMessage;
            ViewBag.BearerAvailable   = !string.IsNullOrEmpty(bearer);
            ViewBag.Active            = "getAlgorithms";

            return(Index());
        }
        public void runWithObject()
        {
            Client            client    = new Client(ALGORITHMIA_API_KEY);
            Algorithm         algorithm = client.algo("algo://quality/Python2xEcho");
            TestObject        input     = new TestObject("a", 1);
            AlgorithmResponse response1 = algorithm.pipe <TestObject>(input);

            Assert.AreEqual(response1.result, input);

            AlgorithmResponse response2 = algorithm.pipeJson <TestObject>("{ \"word\": \"a\", \"number\": 1 }");

            Assert.AreEqual(response2.result, input);
        }
        public IActionResult GetAlgorithms(
            string getAlgorithms
            )
        {
            AlgorithmResponse Result = VisualInspection.GetAlgorithms();

            ViewData["HttpResponse"]  = "Status code: " + (int)Result.HttpResponse.StatusCode + " " + Result.HttpResponse.StatusCode;
            ViewData["StringMessage"] = Result.HttpResponse.Content;
            ViewBag.BearerAvailable   = VisualInspection.IsAuthorized;
            ViewBag.Active            = "getAlgorithms";

            return(Index());
        }
        public void runAsync()
        {
            Client    client    = new Client(ALGORITHMIA_API_KEY);
            Algorithm algorithm = client.algo("algo://testing/Sleep");

            algorithm.setOptions(300, false, AlgorithmOutputType.VOID);
            AlgorithmResponse response = algorithm.pipe <Object>(10);

            Assert.AreEqual(response.async, "void");
            Assert.NotNull(response.request_id);

            Assert.Null(response.result);
            Assert.Null(response.metadata);
            Assert.Null(response.error);
        }
        public void checkTiming()
        {
            Client    client    = new Client(ALGORITHMIA_API_KEY);
            Algorithm algorithm = client.algo("algo://testing/Sleep");

            algorithm.setOptions(options: new Dictionary <string, string>()
            {
                { "timing", "1" }
            });
            AlgorithmResponse response = algorithm.pipe <Object>(1);

            Assert.IsNotNull(response.metadata.timing);
            Assert.True(response.metadata.timing.Keys.Contains("running"));
            Assert.True(response.metadata.timing.Keys.Contains("total"));
            Assert.GreaterOrEqual(response.metadata.timing["running"], 1);
            Assert.GreaterOrEqual(response.metadata.timing["total"], 1);
        }
Exemple #11
0
        public void FailedNoAlgorithm()
        {
            Console.WriteLine("FailedNoAlgorithm Start");
            var JsonString = File.ReadAllText("../../../Files/GetAlgorithmsFailedNoAlgorithm.txt");
            var Client     = MockGenerator.MockRestClient <AlgorithmResponse>(HttpStatusCode.NotFound, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);
            AlgorithmResponse       Response         = VisualInspection.GetAlgorithms();

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNotNull(Response.Errors);
            Assert.IsNull(Response.Data);
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.NotFound));
            Assert.IsTrue(Response.Errors.Title.Equals("No algorithms found"));
            Assert.IsTrue(Response.Errors.Source.Pointer.Equals("/api/v1/algorithms"));
            Assert.IsTrue(Response.Errors.Status.Equals((int)HttpStatusCode.NotFound));
            Console.WriteLine("FailedNoAlgorithm End");
        }
        /// <summary>
        /// 2. This API used for mapping LDA topics to documents.
        /// </summary>
        /// <param name="topicsResponse"></param>
        /// <param name="result"></param>
        /// <param name="userRequest"></param>
        /// <param name="topicIndex"></param>
        /// <returns></returns>
        public static StringBuilder GetLDATopicsToDocsAlgorithm(AlgorithmResponse topicsResponse, FileModel result, string userRequest, int?topicIndex = 0)
        {
            StringBuilder searchresult = new StringBuilder();
            var           secondinput  = "{"
                                         + " \"topics\":" + topicsResponse.result + ","
                                         + " \"docsList\":" + result.DocsList
                                         + "}";

            var client1               = new Client(_clientID);
            var algorithm1            = client1.algo(_apiVersion2);
            var response1             = algorithm1.pipeJson <object>(secondinput);
            var data1                 = response1.result.ToString().Replace("{[", "[").Replace("}]", "]");
            var topicDistributionList = JObject.Parse(data1)["topic_distribution"].Children().ToList();

            searchresult.Append(" This " + userRequest + " keyword weightage, distributed among the documents are : \n\n");

            //It will result the search keyword topic index weightage in each document of corpus.
            for (int i = 0; i < topicDistributionList.Count; i++)
            {
                searchresult.Append(result.FileNames[i] + " : " + Math.Round((Convert.ToDecimal(topicDistributionList[i]["freq"][Convert.ToString(topicIndex)]) * 100), 2) + "%" + ", \n");
            }
            return(searchresult);
        }
 public void runNonexistantAlgo()
 {
     Client            client    = new Client(ALGORITHMIA_API_KEY);
     Algorithm         algorithm = client.algo("algo://demo/thisshouldneverexist");
     AlgorithmResponse response  = algorithm.pipe <Object>(null);
 }
 public void runHelloWorldUnauthenticated()
 {
     Client            client    = new Client("");
     Algorithm         algorithm = client.algo("algo://demo/hello");
     AlgorithmResponse response  = algorithm.pipe <Object>(1);
 }
 private void BreakContentIntoSentences(AlgorithmResponse content)
 {
 }
 private void CleanContentReceived(AlgorithmResponse content)
 {
 }