Text Analysis with LingPipe 4

Text Analysis with LingPipe 4
复制标题

使用 LingPipe 4 进行文本分析

DOI:
--
复制
发表时间:
2011
期刊:
影响因子:
--
通讯作者:
Breck Baldwin
Breck Baldwin
中科院分区:
--
文献类型:
--
作者:
Bob Carpenter;Breck Baldwin

文献摘要

被引文献

相似文献

Externalized.compileTo(分类器,文件); @SuppressWarnings("未选中") ConditionalClassifier<CharSequence> CompiledClassifier = (ConditionalClassifier<CharSequence>) AbstractExternalizable.readObject(file);文件.删除(); Java 类 AbstractExternalized 类(位于 util 包中)的静态实用方法compileTo() 用于进行编写。这也可以通过 LingPipe 的 Compilable 接口直接使用传统的朴素贝叶斯类的方法compileTo(ObjectOut)来完成。我们使用另一个实用程序方法 readObject() 进行反序列化,该方法从文件中读取并返回序列化对象(还有一些实用程序方法可以从类路径中读取已编译或序列化的模型作为资源)。通常,一个程序会写入编译后的文件,而另一个程序(可能在另一台机器上或不同的站点上)会读取它。这里,我们把这两个操作放在一起,供参考。请注意,读回时未经检查的强制转换警告已被抑制;如果提供读回的文件具有不同类型的对象或者根本不是序列化对象,则在运行时仍然可能会因转换而导致错误。请注意,读回时,它被分配给 JointClassifier<CharSequence>;尝试转换为 TradNaiveBayesClassifier 将失败,因为编译版本不是该类的实例。我们对序列化执行相同的操作,使用不同的实用方法进行序列化,但使用相同的 readObject() 方法进行反序列化。 AbstractExternalized.serializeTo(分类器,文件);Externalizable.serializeTo(分类器,文件); @SuppressWarnings("未选中") TradNaiveBayesClassifier deserializedClassifier = (TradNaiveBayesClassifier) AbstractExternalizable.readObject(file);文件.删除(); 10.10。使用语料库进行训练和测试 187 在这里,我们能够将反序列化的对象转换回原始类 TradNaiveBayesClassifier。由于反序列化会产生传统的朴素贝叶斯分类器,因此我们可以提供更多的训练数据。使用不同的变量重复序列化和反序列化,我们可以继续训练。 String s = "哈迪哈哈"; Classified<CharSequence> trainInstance = new Classified<CharSequence>(s,hisCl); deserializedClassifierTrain.handle(trainInstance);
Externalizable.compileTo(classifier,file); @SuppressWarnings("unchecked") ConditionalClassifier<CharSequence> compiledClassifier = (ConditionalClassifier<CharSequence>) AbstractExternalizable.readObject(file); file.delete(); The static utility method compileTo() from Java’s class AbstractExternalizable class (in the util package) is used to do the writing. This could also be done through LingPipe’s Compilable interface directly using the traditional naive Bayes class’s method compileTo(ObjectOut). We deserialized using another utility method, readObject(), which reads and returns serialized objects from files (there are also utility methods to read compiled or serialized models from the class path as resources). Usually, one program would write the compiled file and another program, perhaps on another machine or at a different site, would read it. Here, we have put the two operations together for reference. Note that the unchecked cast warning on reading back in is suppressed; an error may still result at runtime from the cast if the file supplied to read back in has an object of a different type or isn’t a serialized object at all. Note that when read back in, it is assigned to a JointClassifier<CharSequence>; attempting to cast to a TradNaiveBayesClassifier would fail, as the compiled version is not an instance of that class. We do the same thing for serialization, using a different utility method to serialize, but the same readObject() method to deserialize. AbstractExternalizable.serializeTo(classifier,file);Externalizable.serializeTo(classifier,file); @SuppressWarnings("unchecked") TradNaiveBayesClassifier deserializedClassifier = (TradNaiveBayesClassifier) AbstractExternalizable.readObject(file); file.delete(); 10.10. TRAINING AND TESTING WITH A CORPUS 187 Here, we are able to cast the deserialized object back to the original class, TradNaiveBayesClassifier. Because deserialization results in a traditional naive Bayes classifier, we may provide more training data. Repeating the serialization and deserialization with a different variable, we can go on to train. String s = "hardy har har"; Classified<CharSequence> trainInstance = new Classified<CharSequence>(s,hisCl); deserializedClassifierTrain.handle(trainInstance);