简体   繁体   中英

Resolve Class file for java.util.function.Function not found

I want to use the Stanford POS-tagger in my android project.

I added the pos-tagger .jar files to my android project in Android Studio:

  • slf4j-api.jar
  • slf4j-simple.jar
  • stanford-postagger-3.6.0.jar

I can import the library correctly:

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

But an error occurs when I use the function tagString:

MaxentTagger tagger = new MaxentTagger("model/english-left3words-distsim.tagger");
String tagged = tagger.tagString("Hello World");//--->>ERROR
Log.i("tags",tagged);

When compiling, I am getting the error:

Error:(34, 31) error: cannot access Function class file for java.util.function.Function not found Error:Execution failed for task

':app:compileDebugJavaWithJavac'. Compilation failed; see the compiler error output for details.

How can I use the stanford pos-tagger in my Android project correctly?

Are you compiling with Java 8? Recent versions of CoreNLP require Java 8; the error you're seeing is likely from the compiler not finding the newly introduced Function class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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