현재 사용자 입력을 번역하기 위해 사전에 Google 번역에 액세스하는 자연어 처리 프로그램을 작성 중입니다.
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;
}
}
어셈블리에서이 프로그램을 컴파일 할 때 실제로 Unity를 사용하고 있지만 어셈블리로 컴파일하면 리턴 오류가 발생합니다.
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?
나는 HtmlDocument를위한 적절한 네임 스페이스를 온라인에서 찾기 시작했고 다음과 같이 작성해야한다는 것을 알기 시작했다.
using HtmlAgilityPack;
이것을 내 프로그램에 넣은 후에 나는 오류를 받았다.
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?
나는 좀 더 구체적이고 사용해야하는 온라인을 읽었다 :
using HtmlAgilityPack.HtmlDocument;
이제 내가 그걸 넣었으니, 나는 아직도 오류를 계속 받는다 :
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?
HtmlDocument에 사용할 네임 스페이스를 알고 싶습니다. 이 문제에 대한 도움을 주시면 대단히 감사하겠습니다!
HtmlAgilityPack dll을 다운로드하고 참조 했습니까? 프로젝트 / 솔루션 어디서나 참조하지 않고 (타사) 라이브러리를 사용하려는 것 같습니다.
Nu-Get을 사용하여 라이브러리를 설치할 수 있습니다.
Install-Package HtmlAgilityPack