grammarly / gector

Official implementation of the papers "GECToR – Grammatical Error Correction: Tag, Not Rewrite" (BEA-20) and "Text Simplification by Tagging" (BEA-21)
Apache License 2.0
900 stars 214 forks source link

How to make the code work on Python 3.8 #139

Closed oqusous closed 2 years ago

oqusous commented 2 years ago

Is there a way to get the code running on python 3.8? Why is it necessary to have it on 3.7?

I get errors related to scikit-learn, numpy and allennlp.

skurzhanskyi commented 2 years ago

I guess there's no necessity for Python 3.7. We just tested the code with Python 3.7 and we cannot guarantee that it'll work with other versions.

oqusous commented 2 years ago

It does not work,

Traceback (most recent call last):
File "predict_gector.py", line 5, in <module>  
from gector.gec_model import GecBERTModel       
File "/home/omarq/gector/gector/gec_model.py", line 8, in <module> 
from allennlp.data.dataset import Batch 
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/allennlp/data/__init__.py", line 1, in <module>  
from allennlp.data.dataset_readers.dataset_reader import DatasetReader      
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/allennlp/data/dataset_readers/__init__.py", line 10, in <module>        
from allennlp.data.dataset_readers.ccgbank import CcgBankDatasetReader      
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/allennlp/data/dataset_readers/ccgbank.py", line 9, in <module>  
from allennlp.data.dataset_readers.dataset_reader import DatasetReader                 
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/allennlp/data/dataset_readers/dataset_reader.py", line 8, in <module>       
from allennlp.data.instance import Instance                              
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/allennlp/data/instance.py", line 3, in <module>             
from allennlp.data.fields.field import DataArray, Field                     
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/allennlp/data/fields/__init__.py", line 10, in <module>  
from allennlp.data.fields.knowledge_graph_field import KnowledgeGraphField          
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/allennlp/data/fields/knowledge_graph_field.py", line 14, in <module>                 
from allennlp.data.token_indexers.token_indexer import TokenIndexer, TokenType                        
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/allennlp/data/token_indexers/__init__.py", line 5, in <module>            
from allennlp.data.token_indexers.dep_label_indexer import DepLabelIndexer                                      
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/allennlp/data/token_indexers/dep_label_indexer.py", line 8, in <module>                
from allennlp.data.tokenizers.token import Token                                                 
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/allennlp/data/tokenizers/__init__.py", line 7, in <module>             
from allennlp.data.tokenizers.word_tokenizer import WordTokenizer                                    
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/allennlp/data/tokenizers/word_tokenizer.py", line 9, in <module>                      
from allennlp.data.tokenizers.word_stemmer import WordStemmer, PassThroughWordStemmer         
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/allennlp/data/tokenizers/word_stemmer.py", line 1, in <module>            
from nltk.stem import PorterStemmer as NltkPorterStemmer                                      
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/nltk/__init__.py", line 146, in <module>     
from nltk.chunk import *                                                                      
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/nltk/chunk/__init__.py", line 155, in <module>          
from nltk.chunk.api import ChunkParserI                                           
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/nltk/chunk/api.py", line 13, in <module>  
from nltk.chunk.util import ChunkScore                   
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/nltk/chunk/util.py", line 12, in <module>       
from nltk.tag.mapping import map_tag                  
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/nltk/tag/__init__.py", line 70, in <module> 
from nltk.tag.sequential import 
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/nltk/tag/sequential.py", line 26, in <module>       
from nltk.classify import NaiveBayesClassifier                              
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/nltk/classify/__init__.py", line 97, in <module>        
from nltk.classify.scikitlearn import SklearnClassifier                                         
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/nltk/classify/scikitlearn.py", line 38, in <module>                   
from sklearn.feature_extraction import DictVectorizer                   
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/sklearn/__init__.py", line 64, in <module>     
from .base import clone                                                                          
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/sklearn/base.py", line 13, in <module>     
from .utils.fixes import signature                                                   
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/sklearn/utils/__init__.py", line 13, in <module>    
from .validation import (as_float_array, 
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/sklearn/utils/validation.py", line 27, in <module>     
from ..utils._joblib import Memory                                         
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/sklearn/utils/_joblib.py", line 18, in <module>  
from ..externals.joblib import __all__   # noqa             
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/sklearn/externals/joblib/__init__.py", line 119, in <module>        
from .parallel import Parallel                                           
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/sklearn/externals/joblib/parallel.py", line 32, in <module>   
from .externals.cloudpickle import dumps, loads                               
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/sklearn/externals/joblib/externals/cloudpickle/__init__.py", line 3, in <module>    
from .cloudpickle import *                                                               
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/sklearn/externals/joblib/externals/cloudpickle/cloudpickle.py", line 151, in <module>  
_cell_set_template_code = _make_cell_set_template_code()                       
File "/home/omarq/gector/gec_venv/lib/python3.8/site-packages/sklearn/externals/joblib/externals/cloudpickle/cloudpickle.py", line 132, in _make_cell_set_template_code  
return types.CodeType(                                                                  
TypeError: an integer is required (got type bytes) 
skurzhanskyi commented 2 years ago

This looks similar to #132

oqusous commented 2 years ago

Yes. I look up at that error, it asks to upgrade scikit-learn- when I do, allennlp imports stop working. Are you planning to try out python3.8 and resolve any dependency issues in the future?

skurzhanskyi commented 2 years ago

Unfortunately, we're not

oqusous commented 2 years ago

Worth asking! Thank you very much for the amazing tool. It works flawlessly on 3.7.

skurzhanskyi commented 2 years ago

Thanks. Happy to hear that :)