I am currently working on a natural language processing program in which I turn to Google Translate for my dictionary to translate user tabs.
using UnityEngine; using System.Collections; using System.Text; using System.Net; public class GoogleTranslate : MonoBehaviour { public static string Translate(string input, string languagePair, Encoding encoding) { string url = String.Format("http://www.google.com/translate_t?hl=en&ie=UTF8&text= {0}&langpair={1}", input, languagePair); string result = String.Empty; using (WebClient webClient = new WebClient()) { webClient.E ncoding = encoding; result = webClient.DownloadString(url); } HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(result); return doc.DocumentNode.SelectSingleNode("//textarea[@name='utrans']").InnerText; } }
When I compile this program in Assembly, I actually use Unity, but it compiles with Assembly, I get a return error:
Assets/GoogleTranslate.cs(17,13): error CS0246: The type or namespace name `HtmlDocument' could not be found. Are you missing a using directive or an assembly reference?
I started looking for an online namespace for HtmlDocument and read what I should write:
using HtmlAgilityPack;
After I put this into my program, I got an error:
Assets/GoogleTranslate.cs(5,7): error CS0246: The type or namespace name `HtmlAgilityPack' could not be found. Are you missing a using directive or an assembly reference?
I read online what was to be more specific and use:
using HtmlAgilityPack.HtmlDocument;
Now that I have entered this, I still keep getting the error:
Assets/GoogleTranslate.cs(5,7): error CS0246: The type or namespace name `HtmlAgilityPack' could not be found. Are you missing a using directive or an assembly reference?
I would like to know what namespace to use for HtmlDocument. Any help on this would be greatly appreciated!