简体   繁体   English

如何在Eclipse中将第三方库集成到Android

[英]How to integrate a third party library to Android in Eclipse

I am trying to integrate Stanford POS tagger to my android application by following the tutorial at : http://new.galalaly.me/2011/05/tagging-text-with-stanford-pos-tagger-in-java-applications/ 我正在尝试按照以下教程中的步骤将斯坦福POS标记器集成到我的android应用程序中: http : //new.galalaly.me/2011/05/tagging-text-with-stanford-pos-tagger-in-java-applications/

These are the steps that I followed, 这些是我遵循的步骤,

  1. I created a new folder called taggers and saved .taggers and .props file in there 我创建了一个名为taggers的新文件夹,并将.taggers和.props文件保存在那里

  2. I imported the library to my project by right clicking my project>Configure Build Path>Add External Jars 我通过右键单击项目>配置构建路径>添加外部Jar将库导入到项目中

  3. Then I wrote my code, 然后我写了我的代码,

     package cct.mad.numbers; import edu.stanford.nlp.tagger.maxent.MaxentTagger; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class sum2 extends Activity{ MaxentTagger tagger = new MaxentTagger("taggers/left3words-wsj-0-18.tagger"); private TextView text; String sample = "This is a sample text"; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.text2); text = (TextView)findViewById(R.id.news); // The tagged string String tagged = tagger.tagString(sample); text.setText(tagged); } } 

However, it gives an error on 但是,它在

    MaxentTagger tagger = new MaxentTagger("taggers/left3words-wsj-0-18.tagger");

saying: "Default constructor cannot handle exception type ClassNotFoundException thrown by implicit super constructor. Must define an explicit constructor" 说:“默认构造函数无法处理隐式超级构造函数引发的异常类型ClassNotFoundException。必须定义一个显式构造函数”

Also when I hover over, MaxentTagger in the above code and 另外,当我将鼠标悬停在上面的代码中时,

  import edu.stanford.nlp.tagger.maxent.MaxentTagger;

it says: "Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found" 它说:“注意:该元素既没有附加源,也没有附加Javadoc,因此找不到Javadoc”。

How should I fix this? 我该如何解决?

请先将库项目复制到工作区中,然后再尝试添加外部jar。

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

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