Ejemplo n.º 1
0
        /// <summary>
        /// Example code to call Rosette API to get concepts and key phrases in a piece of text.
        /// Requires Nuget Package:
        /// rosette_api
        /// </summary>
        static void Main(string[] args)
        {
            //To use the C# API, you must provide an API key
            string apikey = "Your API key";
            string alturl = string.Empty;

            //You may set the API key via command line argument:
            //tokens yourapikeyhere
            if (args.Length != 0)
            {
                apikey = args[0];
                alturl = args.Length > 1 ? args[1] : string.Empty;
            }
            try
            {
                CAPI   api         = string.IsNullOrEmpty(alturl) ? new CAPI(apikey) : new CAPI(apikey, alturl);
                string topics_data = @"Lily Collins is in talks to join Nicholas Hoult in Chernin Entertainment and Fox Searchlight's J.R.R. Tolkien biopic Tolkien. Anthony Boyle, known for playing Scorpius Malfoy in the British play Harry Potter and the Cursed Child, also has signed on for the film centered on the famed author. In Tolkien, Hoult will play the author of the Hobbit and Lord of the Rings book series that were later adapted into two Hollywood trilogies from Peter Jackson. Dome Karukoski is directing the project.";
                //The results of the API call will come back in the form of a Dictionary
                TopicsResponse response = api.Topics(content: topics_data);
                foreach (KeyValuePair <string, string> h in response.Headers)
                {
                    Console.WriteLine(string.Format("{0}:{1}", h.Key, h.Value));
                }
                Console.WriteLine(response.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
Ejemplo n.º 2
0
 /// <summary> Setter constructor. </summary>
 public Topics(TopicsRequest request)
 {
     Request  = request;
     Response = new TopicsResponse();
 }
Ejemplo n.º 3
0
 /// <summary> Empty constructor. </summary>
 public Topics()
 {
     Request  = TopicsRequest.Singleton;
     Response = new TopicsResponse();
 }