当前位置: 动力学知识库 > 问答 > 编程问答 >

WordNet integrated with ElasticSearch - How to add new synonyms

问题描述:

I work with ElasticSearch version 1.2.3

I've integrated WordNet 3.0 as a Synonym database for ElasticSearch Synonyms Analyzer. (Full WordNet install: configure, make, make install)

I've added the following code to the ElasticSearch index settings (the index name is local_es)

curl -XPUT 'localhost:9200/local_es/_settings' -d '{

"settings" : {

"analysis" : {

"analyzer" : {

"synonym" : {

"tokenizer" : "lowercase",

"filter" : ["synonym"]

}

},

"filter" : {

"synonym" : {

"type" : "synonym",

"format": "wordnet",

"synonyms_path": "analysis/wn_s.pl"

}

}

}

}

}'

I've also have updated the mapping with the following code:

enter code here

curl -XPUT 'localhost:9200/local_es/shadowpage/_mapping' -d '{

"shadowpage" : {

"shadowPageName" : {

"enabled" : true,

"analyzer" : "synonym"

},

"properties" : {

"name" : { "type" : "string", "index" : "analyzed", "analyzer" : "synonym" }

}

}

}'

All is working as expected.

As you can see, ElasticSearch takes its data from the file path of analysis/wn_s.pl

wn_s.pl file is a WordNet prolog file that contains all the database synonyms.

How can I add new synonyms to the database?

Do I add it directly to the WordNet database? Or in wn_s.pl file?

网友答案:

If you are going to be actively modifying your synonym database you should probably just transform the synsets in the wordnet database into the basic comma delimited file in this format

    "british,english",
    "queen,monarch"

Then use and edit this file as your synonym resource.

分享给朋友:
您可能感兴趣的文章:
随机阅读: