相关疑难解决方法(0)

从 Python 3 中的给定字符串解析测量值(多维)

我知道这篇文章这个库,但他们没有帮助我解决下面的这些具体案例。我如何解析如下测量值:

我有如下字符串;

"Square 10 x 3 x 5 mm"
"Round 23/22; 24,9 x 12,2 x 12,3"
"Square 10x2"
"Straight 10x2mm"
Run Code Online (Sandbox Code Playgroud)

我正在寻找一个 Python 包或某种方式来获得如下结果;

>>> a = amazing_parser.parse("Square 10 x 3 x 5 mm")
>>> print(a)
10 x 3 x 5 mm
Run Code Online (Sandbox Code Playgroud)

同样地;

>>> a = amazing_parser.parse("Round 23/22; 24,9x12,2")
>>> print(a)
24,9 x 12,2
Run Code Online (Sandbox Code Playgroud)

我还尝试使用“ner_ontonotes_bert_mult”模型使用“命名实体识别”。但结果如下:

>>> from deeppavlov import configs, build_model
>>> ner_model = build_model(configs.ner.ner_ontonotes_bert_mult, download=True)
>>> print(ner_model(["Round 23/22; 24,9 x 12,2 x 12,3"]))
<class …
Run Code Online (Sandbox Code Playgroud)

regex parsing units-of-measurement python-3.x ner

2
推荐指数
1
解决办法
455
查看次数

标签 统计

ner ×1

parsing ×1

python-3.x ×1

regex ×1

units-of-measurement ×1