Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 718
raven99 Avatar asked Aug 17 '14 10:08

raven99


1 Answers

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.

like image 125
Vlad Avatar answered Nov 10 '22 09:11

Vlad