LexSubCon: Integrating Knowledge from Lexical Resources into  Contextual Embeddings for Lexical Substitution

a) General info
This is the code that was used in the paper : LexSubCon: Integrating Knowledge from Lexical Resources into  Contextual Embeddings for Lexical Substitution


b)Install the required python packages
i)In the project root directory, run the following to install the required packages.
    pip3 install -r requirements.txt

ii)Code depends on data from NLTK (e.g., stopwords) so you'll have to download them. 
Run the Python interpreter and type the commands:

```python
>>> import nltk
>>> nltk.download()
```


iii)If you start a VM, please run the following command sequentially before install the required python packages.
The following code example is for a vast.ai Virtual Machine.
    sudo apt-get update
    sudo apt install git-all
    sudo apt install python3-pip



c)Download pre-trained contextual model

i)In order to use the pre-trained  GLOSS-BERT model, we need to download the model from https://drive.google.com/u/0/uc?id=1iq_h3zLTflraEU_7tVLnPcVQTeyGDNKE&export=download
and saved it  in checkpoint/gloss_bert
    

ii)In order to use the fine-tuned sentence similarity model, we need to download the model from https://drive.google.com/u/0/uc?id=13OzoeD_pWF4XnUfZYYYitTIV25FUC3Z4&export=download
and saved it in checkpoint/similarity_new_bert  or checkpoint/similarity_new_bert_coinco folder





d)LSO7 task
i) We provide the LS07 dataset in the DATA folder. in order to test the model on this model please place the folder in the dataset folder.
ii)After specifying which features we want to use the argument of the code we can run LexSubCon with :
	python3 main_lexical.py
or the re-implenetation of BERT-based Lexical Substitution[1] with:
	python3 main_lexical_50.py

e) CoInCO task

i)We provide the CoInCO dataset in the DATA folder. in order to test the model on this model please place the folder in the dataset folder.
ii)After specifying which features we want to use the argument of the code we can run LexSubCon with :
	python3 main_lexical_coinco.py
or the re-implenetation of BERT-based Lexical Substitution[1] with:
	python3 main_lexical_50_coinco.py

[1] Zhou, W., Ge, T., Xu, K., Wei, F., & Zhou, M. (2019). BERT-based Lexical Substitution. ACL.

