如何区分扫描文本中的文本和数字?

How to differentiate between text and number in scanned text?

我正在使用 Microsoft Cognitive Services Computer Vision Api 作为 OCR 服务来阅读食物菜单。

我能够成功扫描菜单,但现在我想将菜名部分和价格部分保存在两个不同的数组中。

由于卢比符号、括号、菜单编号等特殊字符,现在扫描后的结果完全被破坏了。

我只想要没有卢比符号的菜名和价格。 有人可以告诉我我怎么能做到这一点? 这是 github link 和一些可以帮助您协助我的代码:

@Override
    protected void onPostExecute(String data) {
        super.onPostExecute(data);
        // Display based on error existence

        if (e != null) {
            mEditText.setText("Error: " + e.getMessage());
            this.e = null;
        } else {
            Gson gson = new Gson();
            OCR r = gson.fromJson(data, OCR.class);

            String result = "";
            for (Region reg : r.regions) {
                for (Line line : reg.lines) {
                    for (Word word : line.words) {
                        result += word.text + " ";
                    }
                    result += "\n";
                }
                result += "\n\n";
            }

            mEditText.setText(result);
        }
        mButtonSelectImage.setEnabled(true);
    }

我想要的是:

1) 我不想在结果中出现任何这些特殊字符。

2) 我想把菜名和价格保存在两个不同的数组中

Here are the screen shots of the output and the menu.

我找到了答案,谢谢你们的帮助!!

我使用这个正则表达式只获得了字符:

resultString = result.replaceAll("\P{L}", " ");

并且仅使用此正则表达式的数字:

resultNumber = result.replaceAll("[^\d.]", "");