如何使用我自己的实体创建自定义模型

How to create a custom model with my own entities

我一直在尝试寻找一些关于如何使用我自己的实体创建自定义模型的参考 material,比如如果我想从 text.How 中识别运动的名称,我会这样做吗?

stanford 的工具通常可以很好地完成多项 NLP 任务,但根据我的经验,在 opennlp 中训练自己的模型要容易得多。如果这是你的选择(你标记了你的问题 "stanford-nlp",但也许你不限于只使用它),你可以在这里找到一些非常好的文档:https://opennlp.apache.org/documentation/1.5.3/manual/opennlp.html#tools.namefind.training.tool

    try {
        propFile = new File(System.getProperty("user.dir") + "/src/edu/stanford/nlp/ie/crf/propfile.prop");
        properties = new Properties();
        properties.load(new FileInputStream(propFile));

        String to = properties.getProperty("serializeTo");

        properties.setProperty("serializeTo", "ner-customModel.ser.gz");
        properties.setProperty("trainFile",System.getProperty("user.dir") + "/src/edu/stanford/nlp/ie/crf/outputTokenized.tsv");
        CRFClassifier crf = new CRFClassifier(properties);
        crf.train();
        String s2 = "apples are apples";

        System.out.println(crf.classifyToString(s2));

        crf.serializeClassifier(System.getProperty("user.dir") + "/src/edu/stanford/nlp/ie/crf/ner-customModel.ser.gz");

    } catch (IOException e) {
        e.printStackTrace();
    }

并在属性文件中声明训练文件和其他属性。 这对我有用:)