Example #1
0
        public static FullLexicalModel[] Words(APIConstraints apiFlags, ExternalConstraints relFlags, ExtraLexicalKnowledge lexFlags, params string[] paramValues)
        {
            List <Parameter> parameters = new List <Parameter>();

            if (apiFlags != APIConstraints.None)
            {
                parameters.AddRange(GetAPIParameters(apiFlags, paramValues.GetEnumerator()));
            }
            if (relFlags != ExternalConstraints.None)
            {
                parameters.Add(GetRelParam(relFlags, paramValues.Last()));
            }
            if (lexFlags != ExtraLexicalKnowledge.None)
            {
                parameters.Add(GetLexicalParam(lexFlags));
            }

            var response = CLIENT.Execute(
                new RestRequest(
                    "words",
                    Method.GET
                    ).AddOrUpdateParameters(parameters)
                );

            return(JSON.Deserialize <FullLexicalModel[]>(response.Content));
        }
Example #2
0
        public static Parameter[] GetAPIParameters(APIConstraints apiFlags, IEnumerator paramsEnumerator)
        {
            List <Parameter> parameters = new List <Parameter>();
            int flagsNum = (int)apiFlags;

            for (int i = 5; i >= 0; --i)
            {
                int num = Convert.ToInt32(Math.Pow(2, i));
                if (flagsNum >= num)
                {
                    flagsNum -= num;
                    paramsEnumerator.MoveNext();
                    parameters.Add(
                        new Parameter()
                    {
                        Name  = API_FLAGS[i],
                        Value = paramsEnumerator.Current,
                        Type  = ParameterType.GetOrPost
                    }
                        );
                }
            }
            return(parameters.ToArray());
        }