如何从standfordner分类器生成xml输出?

时间:2016-06-26 15:08:49

标签: xml stanford-nlp named-entity-recognition information-extraction

我使用了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,但它不起作用。因为我是这个领域的新手,请帮我解决这个问题。 非常感谢

1 个答案:

答案 0 :(得分:1)

此示例代码应该有用:

tar jxf arm-system-2011-08.tar.bz2.