我使用了standfordNER分类器来分类文本。 这是代码。
string docText = fileContent;
string txt = "";
var classified = Classifier.classifyToCharacterOffsets(docText).toArray();
for (int i = 0; i < classified.Length; i++)
{
Triple triple = (Triple)classified[i];
int second = Convert.ToInt32(triple.second().ToString());
int third = Convert.ToInt32(triple.third().ToString());
txt = txt + ('\t' + triple.first().ToString() + '\t' + docText.Substring(second, third - second));
string s = Classifier.classifyWithInlineXML(txt);
string s1 = Classifier.classifyToString(s, "xml", true);
Panel1.GroupingText = s1;
}
Panel1.Visible = true;
这就是输出:
LOCATION Lanka LOCATION colombo ORGANIZATION microsoft
但我需要像这样的xml格式输出
<LOCATION> Lanka </LOCATION> <LOCATION>colombo</LOCATION> <ORGANIZATION> microsoft</ORGANIZATION>
在我用过的代码中,
string s = Classifier.classifyWithInlineXML(txt);
string s1 = Classifier.classifyToString(s, "xml", true);
获取xml,但它不起作用。因为我是这个领域的新手,请帮我解决这个问题。 非常感谢
答案 0 :(得分:1)
此示例代码应该有用:
tar jxf arm-system-2011-08.tar.bz2.