使用命名实体识别的问题

if (valid) {
    speechFinalResult = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION).get(0);
    InputStream inputStream = null;
    TokenizerModel tokenmodel = null;

    try {
        inputStream = getassets().open("en-token.bin");
        tokenmodel = new TokenizerModel(inputStream);
        inputStream.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

    if (tokenmodel != null) {
        TokenizerME tokenizer = new TokenizerME(tokenmodel);
        String paragraph = speechFinalResult;
        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();
        }

        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();
            textView1.setText(result);

            setRecognitionProgressMsg(speechFinalResult);

            try {
                Uri uri = null;
                uri = Uri.parse("google.navigation:q=" + result + "&mode=l");

                Intent intent = new Intent(Intent.actION_VIEW,uri);

                intent.setPackage("com.google.android.apps.maps");

                intent.setflags(Intent.flaG_actIVITY_NEW_TASK);
                startactivity(intent);
            } catch (activityNotFoundException e) {
                Uri uri = Uri.parse("https://play.google.com/store/apps/details?id=com.google.android.apps.maps");

                Intent intent = new Intent(Intent.actION_VIEW,uri);
                intent.setflags(Intent.flaG_actIVITY_NEW_TASK);
                startactivity(intent);
            }
        }
    }
}

在这里,我将语音识别器与命名实体识别一起使用,例如:如果我说“我想去金奈” 我的代码必须从给定的句子中识别位置名称,然后导航到该位置。 根据我的代码,我将标记该句子并标识位置名称并将其分配给结果。 并传递该结果进行导航,但是我的代码始终在Google Maps Destination框中显示为null。 请帮助我提供您的见解。

asddsa_asddsa 回答:使用命名实体识别的问题

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/1413412.html

大家都在问