简体   繁体   English

尝试从URL读取标记文件时出现斯坦福POS标记错误

[英]Stanford POS tagger error when trying to read the tagger file from URL

I am using POS tagger for a project and it works successfully when it reads the tagger file from my computer (project's folder). 我正在为项目使用POS标记器,当它从我的计算机(项目的文件夹)读取标记器文件时,它可以成功运行。 But I need to upload the tagger file first and read the tagger file from a URL. 但是我需要先上传标记文件,然后从URL读取标记文件。 To do so, I have uploaded the POS tagger file and I am trying to read the tagger file by giving the URL to the constructor of the MaxentTagger method: (my code is in C# and I have overridden the MaxentTagger class so it's constructor looks like this: 为此,我上载了POS标记文件,并尝试通过将URL提供给MaxentTagger方法的构造函数来读取标记文件:(我的代码在C#中,并且我重写了MaxentTagger类,因此它的构造函数看起来像这个:

public Tagger () { 公共Tagger(){

java.io.ByteArrayInputStream inputStream = new java.io.ByteArrayInputStream(System.IO.File.ReadAllBytes(@"C:\\models\\english-left3words-distsim.tagger")); java.io.ByteArrayInputStream inputStream =新的java.io.ByteArrayInputStream(System.IO.File.ReadAllBytes(@“ C:\\ models \\ english-left3words-distsim.tagger”));

base.readModelAndInit(null, new java.io.DataInputStream(inputStream), false); base.readModelAndInit(null,新的java.io.DataInputStream(inputStream),false); } }

However I get this error when I run my code: 但是,当我运行代码时出现此错误:

"An unhandled exception of type 'java.lang.RuntimeException' occurred in stanford-postagger.dll “ stanford-postagger.dll中发生了'java.lang.RuntimeException类型的未处理的异常。

Additional information: java.io.FileNotFoundException: Could not find a part of the path 'C:\\u\\nlp\\data\\pos_tags_are_useless\\egw4-reut.512.clusters'." 其他信息:java.io.FileNotFoundException:找不到路径'C:\\ u \\ nlp \\ data \\ pos_tags_are_useless \\ egw4-reut.512.clusters'的一部分。”

Does anybody know why this happens and how I can resolve this? 有人知道为什么会发生这种情况以及如何解决吗? I appreciate any sort of help very much! 我非常感谢任何帮助!

This error comes from the program trying to load a file which gives the distributional similarity mapping from words to clusters. 此错误来自程序尝试加载文件的程序,该文件给出了从单词到聚类的分布相似性映射。 It's trying to get it from the location that is specified in the training properties file (and you naturally don't have a file at that location). 它试图从训练属性文件中指定的位置获取它(并且您自然没有该位置的文件)。 This happened because you don't have a properly initialized TaggerConfig object at the time readModelAndInit() is called. 发生这种情况是因为在调用readModelAndInit()时没有正确初始化的TaggerConfig对象。 The way it gets initialized is unintuitive (was badly architected), but you're only encountering this because you're trying to use a non-public API. 它的初始化方式是不直观的(在设计上很差),但是您仅遇到这种情况,因为您正尝试使用非公共API。

Why can't you just use the public API as follows? 为什么不能仅按​​以下方式使用公共API?

MaxentTagger base = new MaxentTagger("http://my.url.com/models/english-left3words-distsim.tagger");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM