固定div元素后,与我们联系的形式会缩小15像素,而我无法弄清楚问题所在以及如何解决。 <div class="container"> <section class="property-details-section"> <div class="c ...
提示:本站收集StackOverFlow近2千万问答,支持中英文搜索,鼠标放在语句上弹窗显示对应的参考中文或英文, 本站还提供 中文繁体 英文版本 中英对照 版本,有任何建议请联系yoyou2525@163.com。
package com.example.dell.apacheopennlp;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import java.io.IOException;
import java.io.InputStream;
import opennlp.tools.namefind.NameFinderME;
import opennlp.tools.namefind.TokenNameFinderModel;
import opennlp.tools.tokenize.TokenizerME;
import opennlp.tools.tokenize.TokenizerModel;
import opennlp.tools.util.Span;
public class apacheOpenNLP extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_apache_open_nlp);
final TextView txt = (TextView) findViewById (R.id.txtView);
InputStream inputStream = null;
TokenizerModel tokenModel =null;
try{
inputStream = getAssets().open("en-token.bin");
tokenModel = new TokenizerModel (inputStream);
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
txt.setText (e.toString ()+" inside catch of token");
}
if(tokenModel!=null) {
TokenizerME tokenizer = new TokenizerME (tokenModel);
String paragraph = "Tutorialspoint is located in Hyderabad";
String tokens[] = tokenizer.tokenize (paragraph);
InputStream locationInputStream=null;
TokenNameFinderModel locationModel = null;
try {
locationInputStream = getAssets ( ).open ("en-ner-location.bin");
locationModel = new TokenNameFinderModel (locationInputStream);
} catch (IOException e) {
e.printStackTrace ( );
txt.setText (e.toString ()+" inside catch of location");
}
if (locationModel != null) {
NameFinderME nameFinder = new NameFinderME (locationModel);
Span nameSpans[] = nameFinder.find (tokens);
String result = null;
for (Span s : nameSpans)
//result= s.toString()+" "+tokens[s.getStart()];
result += s.toString ( );
txt.setText (result);
}
else{
// txt.setText ("Location model is empty");
}
}
}
}
我正在使用Apache OpenNLP提取句子中的位置。 我调试了代码,发现在NameFinderME nameFinder = new NameFinderME(locationModel)之后; android应用程序崩溃,显示一条消息“该应用程序已停止工作”如何解决此问题?
您可以尝试将nameFinder更改为声明为TokenNameFinder接口类型吗?
只是尝试更换
NameFinderME nameFinder = null
同
TokenNameFinder nameFinder = null
休息都应该一样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.