From 598cdb0b379b2f9db34a1450932b45b8eff5704b Mon Sep 17 00:00:00 2001 From: Bhargav Narapareddy <47373022+narbhar@users.noreply.github.com> Date: Wed, 24 Apr 2019 16:45:05 -0400 Subject: [PATCH] Update utils.py To fix the error Python int too large to convert to C long --- src/utils.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/utils.py b/src/utils.py index 20c14ea..5946659 100644 --- a/src/utils.py +++ b/src/utils.py @@ -4,7 +4,17 @@ import torch import sys import csv -csv.field_size_limit(sys.maxsize) +maxInt = sys.maxsize + +while True: + # decrease the maxInt value by factor 10 + # as long as the OverflowError occurs. + + try: + csv.field_size_limit(maxInt) + break + except OverflowError: + maxInt = int(maxInt/10) from nltk.tokenize import sent_tokenize, word_tokenize from sklearn import metrics import numpy as np