【发布时间】:2016-06-26 15:08:48
【问题描述】:
我使用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,但它不起作用。因为我是这个领域的新手,请帮我解决这个问题。 非常感谢
【问题讨论】:
标签: xml stanford-nlp named-entity-recognition information-extraction