赞
踩
给定一段文本,提取其中的货币金额字符串,并将所有的金额做标准化。
JioNLP 中文预处理与解析工具包https://github.com/dongrixinyu/JioNLPhttps://github.com/dongrixinyu/JioNLP货币金额抽取在线版
其中,jio.ner.extract_money 与 jio.parse_money 可以从一段文本中抽取出货币金额,并将结果进行标准化。我们不妨看一个例子:
给定一段文本如:
海航亏损7000万港元出售香港公寓。12月12日,据《香港经济日报》报道,海航集团将持有的部分位于香港铜锣湾Yoo Residence大楼中的物业以2.6亿港元的价格出售,相对于去年入手时3.3亿港元的价格来看,海航此次出售该物业以公司股权转让的模式转售,亏损了7000多万港元。该物业包括一个顶层复式豪华公寓、1个分层物业及5个车位。报道称,两个月前,海航在市场上为该部分物业寻找买家,一度报价达到几千万美元。此外,海航在数月前将去年同时买下的一个地下连1楼的商铺以8650万港元的价格出售,买家为香港一家名为荣企的公司,较去年近1.2亿港元入手的价格亏损了约3350万港元。 以此来看,海航投资Yoo Residence在一年内亏损逾1亿港元。今年以来,海航在香港连续出售其持有的地产类资产。2月份,海航集团把香港启德区6565号地块和6562号地块以159.59亿港元卖给了香港恒基兆业地产(00012.HK),股价为二十三块四毛钱。3月份,海航又把位于九龙启德第1L区1号地盘新九龙内地段第6564号以63.59亿港元的价格卖给了会德丰(00020.HK)。 已在5个月前为其融到了50.47亿港元。除了出售地块之外,海航还卖掉了在香港金钟的一处办公室。3月21日,据香港当地媒体《明报》报道,海航已于今日出售位于香港金钟力宝中心的一处办公室,成交价为4000多万港元,折合单价为28000港元/平方英尺(折合243300元/平方米),较该物业的市场价值38000港元/平方英尺低了近两成。截至目前,海航在香港出售地产类物业已套现至少227亿港元。
- import jionlp as jio
-
- text = "海航..."
-
- results = jio.ner.extract_money(text, with_parsing=True)
- for item in results:
- print(item)
- {'text': '7000万港元', 'offset': [4, 11], 'type': 'money', 'detail': {'num': '70000000.00', 'case': '港元', 'definition': 'accurate'}}
- {'text': '2.6亿港元', 'offset': [83, 89], 'type': 'money', 'detail': {'num': '260000000.00', 'case': '港元', 'definition': 'accurate'}}
- {'text': '3.3亿港元', 'offset': [103, 109], 'type': 'money', 'detail': {'num': '330000000.00', 'case': '港元', 'definition': 'accurate'}}
- {'text': '7000多万港元', 'offset': [149, 157], 'type': 'money', 'detail': {'num': ['70000000.00', '80000000.00'], 'case': '港元', 'definition': 'blur'}}
- {'text': '达到几千万美元', 'offset': [225, 232], 'type': 'money', 'detail': {'num': ['10000000.00', '100000000.00'], 'case': '美元', 'definition': 'blur'}}
- {'text': '8650万港元', 'offset': [270, 277], 'type': 'money', 'detail': {'num': '86500000.00', 'case': '港元', 'definition': 'accurate'}}
- {'text': '近1.2亿港元', 'offset': [301, 308], 'type': 'money', 'detail': {'num': '120000000.00', 'case': '港元', 'definition': 'blur-'}}
- {'text': '约3350万港元', 'offset': [316, 324], 'type': 'money', 'detail': {'num': '33500000.00', 'case': '港元', 'definition': 'blur'}}
- {'text': '逾1亿港元', 'offset': [362, 367], 'type': 'money', 'detail': {'num': '100000000.00', 'case': '港元', 'definition': 'blur+'}}
- {'text': '159.59亿港元', 'offset': [431, 440], 'type': 'money', 'detail': {'num': '15959000000.00', 'case': '港元', 'definition': 'accurate'}}
- {'text': '二十三块四毛钱', 'offset': [465, 472], 'type': 'money', 'detail': {'num': '23.00', 'case': '元', 'definition': 'accurate'}}
- {'text': '63.59亿港元', 'offset': [517, 525], 'type': 'money', 'detail': {'num': '6359000000.00', 'case': '港元', 'definition': 'accurate'}}
- {'text': '50.47亿港元', 'offset': [565, 573], 'type': 'money', 'detail': {'num': '5047000000.00', 'case': '港元', 'definition': 'accurate'}}
- {'text': '4000多万港元', 'offset': [659, 667], 'type': 'money', 'detail': {'num': ['40000000.00', '50000000.00'], 'case': '港元', 'definition': 'blur'}}
- {'text': '28000港元', 'offset': [673, 680], 'type': 'money', 'detail': {'num': '28000.00', 'case': '港元', 'definition': 'accurate'}}
- {'text': '243300元', 'offset': [688, 695], 'type': 'money', 'detail': {'num': '243300.00', 'case': '元', 'definition': 'accurate'}}
- {'text': '38000港元', 'offset': [719, 726], 'type': 'money', 'detail': {'num': '38000.00', 'case': '港元', 'definition': 'accurate'}}
- {'text': '至少227亿港元', 'offset': [757, 765], 'type': 'money', 'detail': {'num': '22700000000.00', 'case': '港元', 'definition': 'blur+'}}

可以看出,该工具可以准确抽取出其中的货币金额,并支持以下特性:
另外,该工具还有非常强力的 时间语义解析能力https://blog.csdn.net/dongrixinyu/article/details/120245280https://blog.csdn.net/dongrixinyu/article/details/120245280货币金额抽取在线版
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。