我有點困惑如何確定英文字母標註。在這種情況下,我假定英語中的一個單詞有一種類型,例如單詞「book」被識別爲NOUN,而不是VERB。我想根據時態來識別英語句子。例如,「我發送了這本書」被認爲是過去式。根據數據庫文件確定英文字母標註
說明:
我有一些數據庫(* .txt)文件:NounList.txt,verbList.txt,adjectiveList.txt,adverbList.txt,conjunctionList.txt,prepositionList.txt,articleList.txt 。如果輸入的單詞在數據庫中可用,我假定可以結束這些單詞的類型。但是,如何開始在數據庫中查找?例如,「我發送了這本書」:如何開始在數據庫中搜索每個單詞,「I」作爲名詞,「發送」爲動詞,「the」作爲文章,「book」作爲名詞?比搜索每個數據庫中的每個單詞都更好的方法嗎?我懷疑每個數據庫都有獨特的元素。
我附上我的觀點。
private List<string> ParseInput(String allInput)
{
List<string> listSentence = new List<string>();
char[] delimiter = ".?!;".ToCharArray();
var sentences = allInput.Split(delimiter, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim());
foreach (var s in sentences)
listSentence.Add(s);
return listSentence;
}
private void tenseReviewMenu_Click(object sender, EventArgs e)
{
string allInput = rtbInput.Text;
List<string> listWord = new List<string>();
List<string> listSentence = new List<string>();
HashSet<string> nounList = new HashSet<string>(getDBList("nounList.txt"));
HashSet<string> verbList = new HashSet<string>(getDBList("verbList.txt"));
HashSet<string> adjectiveList = new HashSet<string>(getDBList("adjectiveList.txt"));
HashSet<string> adverbList = new HashSet<string>(getDBList("adverbList.txt"));
char[] separator = new char[] { ' ', '\t', '\n', ',' etc... };
listSentence = ParseInput(allInput);
foreach (string sentence in listSentence)
{
foreach (string word in sentence.Split(separator))
if (word.Trim() != "")
listWord.Add(word);
}
string testPOS = "";
foreach (string word in listWord)
{
if (nounList.Contains(word.ToLowerInvariant()))
testPOS += "noun ";
else if (verbList.Contains(word.ToLowerInvariant()))
testPOS += "verb ";
else if (adjectiveList.Contains(word.ToLowerInvariant()))
testPOS += "adj ";
else if (adverbList.Contains(word.ToLowerInvariant()))
testPOS += "adv ";
}
tbTest.Text = testPOS;
}
POS標記是我在作業中的次要解釋。所以我使用一種簡單的方法來確定基於數據庫的POS標籤。但是,如果有一個更簡單的方法:易於使用,易於理解,易於獲得僞代碼,易於設計...來確定POS標籤,請讓我知道。
我不明白這個問題。顯然,許多單詞可能不僅僅是POS(例如,「書」可能是一個動詞,因爲我想預訂一個旅館房間_)。問題是如何處理的?什麼是緊張與這一切有關? 「基於時態來識別句子」是什麼意思?或者你只是在尋找一個POS標記的介紹(在這種情況下,Stackoverflow不會去的地方)? – jogojapan 2013-03-30 08:49:32