Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自定义英文分词不行额,不知道怎么设置呀,头大 #144

Open
chunpat opened this issue May 18, 2023 · 2 comments
Open

自定义英文分词不行额,不知道怎么设置呀,头大 #144

chunpat opened this issue May 18, 2023 · 2 comments

Comments

@chunpat
Copy link

chunpat commented May 18, 2023

自定义词库

vim plugins/analysis-hanlp/data/dictionary/custom/CustomDictionary1.txt

OPPO nx 1
VIVO nx 1
IPHONE nx 1

新建index

curl -XPUT http://localhost:9200/test1 -H 'Content-Type:application/json' -d'
{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_hanlp_analyzer": {
          "tokenizer": "my_hanlp"
        }
      },
      "tokenizer": {
        "my_hanlp": {
          "type": "hanlp",
          "enable_stop_dictionary": true,
          "enable_custom_config": true,
		  "enable_custom_dictionary":true,
		  "enable_number_quantifier_recognize":false
        }
      }
    }
  }
}'

_analyze

curl -XGET "http://localhost:9200/test1/_analyze" -H 'Content-Type: application/json;charset=utf-8' -d'
{
"text": "IPHONEOPPOVIVO",
"analyzer": "my_hanlp_analyzer"
}'

{"tokens":[{"token":"IPHONEOPPOVIVO","start_offset":0,"end_offset":14,"type":"nx","position":0}]}
@nyzhyxydsh
Copy link

将CustomDictionary1.txt文件目录追加到hanlp.properties配置文件的CustomDictionaryPath自定义词典路径下试试,注意格式(有无空格解析逻辑是不一样的)。

@chunpat
Copy link
Author

chunpat commented Jul 25, 2023

将CustomDictionary1.txt文件目录追加到hanlp.properties配置文件的CustomDictionaryPath自定义词典路径下试试,注意格式(有无空格解析逻辑是不一样的)。

我那个案例是追加了的,跳过了这部分。后面看了有英文的案例,用全角英文处理。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants