Closed yu285509945 closed 1 year ago
代码比较简单,在很多数据中检索姓名
ltp = LTP() # 默认加载 Small 模型,下载的路径是:~/.cache/torch/ltp
cws分词 pos词性
words = ltp.pipeline([sentences], tasks=["cws", "pos"], return_dict=True) name = '' for i in range(len(words.cws)): for j in range(len(words.cws[i])): if words.pos[i][j] == 'nh': # nh代表姓名 name = words.cws[i][j] self.resume.isName = True # 找到人名以后,不需要再文档中重新查找人名 break
版本4.2.13 在使用过程中,会有如下提示
'HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /LTP/small/resolve/main/config.json (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x00000203832C0700>, 'Connection to huggingface.co timed out. (connect timeout=10)'))' thrown while requesting HEAD https://huggingface.co/LTP/small/resolve/main/config.json 'HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /LTP/small/resolve/main/pytorch_model.bin (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x00000203832A3940>, 'Connection to huggingface.co timed out. (connect timeout=10)'))' thrown while requesting HEAD https://huggingface.co/LTP/small/resolve/main/pytorch_model.bin 'HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /LTP/small/resolve/main/tokenizer_config.json (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x00000203D7C6CF40>, 'Connection to huggingface.co timed out. (connect timeout=10)'))' thrown while requesting HEAD https://huggingface.co/LTP/small/resolve/main/tokenizer_config.json 'HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /LTP/small/resolve/main/config.json (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x00000203846CA280>, 'Connection to huggingface.co timed out. (connect timeout=10)'))' thrown while requesting HEAD https://huggingface.co/LTP/small/resolve/main/config.json 'HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /LTP/small/resolve/main/pytorch_model.bin (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x00000203846CF6D0>, 'Connection to huggingface.co timed out. (connect timeout=10)'))' thrown while requesting HEAD https://huggingface.co/LTP/small/resolve/main/pytorch_model.bin 'HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /LTP/small/resolve/main/tokenizer_config.json (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x00000203846CFEE0>, 'Connection to huggingface.co timed out. (connect timeout=10)'))' thrown while requesting HEAD https://huggingface.co/LTP/small/resolve/main/tokenizer_config.json 'HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /LTP/small/resolve/main/config.json (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x00000203D8FB4220>, 'Connection to huggingface.co timed out. (connect timeout=10)'))' thrown while requesting HEAD https://huggingface.co/LTP/small/resolve/main/config.json 'HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /LTP/small/resolve/main/pytorch_model.bin (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x00000203DFD077C0>, 'Connection to huggingface.co timed out. (connect timeout=10)'))' thrown while requesting HEAD https://huggingface.co/LTP/small/resolve/main/pytorch_model.bin 'HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /LTP/small/resolve/main/tokenizer_config.json (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x00000203DFD07FD0>, 'Connection to huggingface.co timed out. (connect timeout=10)'))' thrown while requesting HEAD https://huggingface.co/LTP/small/resolve/main/tokenizer_config.json 'HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /LTP/small/resolve/main/config.json (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x00000203DFD2D280>, 'Connection to huggingface.co timed out. (connect timeout=10)'))' thrown while requesting HEAD https://huggingface.co/LTP/small/resolve/main/config.json 'HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /LTP/small/resolve/main/pytorch_model.bin (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x00000203E4240850>, 'Connection to huggingface.co timed out. (connect timeout=10)'))' thrown while requesting HEAD https://huggingface.co/LTP/small/resolve/main/pytorch_model.bin 'HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /LTP/small/resolve/main/tokenizer_config.json (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x00000203E424A0A0>, 'Connection to huggingface.co timed out. (connect timeout=10)'))' thrown while requesting HEAD https://huggingface.co/LTP/small/resolve/main/tokenizer_config.json 'HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /LTP/small/resolve/main/config.json (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x00000203E4268280>, 'Connection to huggingface.co timed out. (connect timeout=10)'))' thrown while requesting HEAD https://huggingface.co/LTP/small/resolve/main/config.json 'HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /LTP/small/resolve/main/pytorch_model.bin (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x00000203D7C63250>, 'Connection to huggingface.co timed out. (connect timeout=10)'))' thrown while requesting HEAD https://huggingface.co/LTP/small/resolve/main/pytorch_model.bin 'HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /LTP/small/resolve/main/tokenizer_config.json (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x00000203DFD0E100>, 'Connection to huggingface.co timed out. (connect timeout=10)'))' thrown while requesting HEAD https://huggingface.co/LTP/small/resolve/main/tokenizer_config.json
大概是去huggingface.co下载模型失败? 这个会导致识别时间特别长。