Generator raised StopIteration in find_job_titles package - python

I am trying to run this code:
from find_job_titles import FinderAcora
finder=FinderAcora()
finder.findall('IT Audit & Governance')
But it gives me this error everytime:
---------------------------------------------------------------------------
StopIteration Traceback (most recent call last)
/usr/local/lib/python3.8/dist-packages/find_job_titles/__init__.py in longest_match(matches)
48 """
---> 49 longest = next(matches)
50
StopIteration:
The above exception was the direct cause of the following exception:
RuntimeError Traceback (most recent call last)
1 frames
<ipython-input-31-5b965ac3d7be> in <module>
----> 1 finder.findall('IT Audit & Governance')
/usr/local/lib/python3.8/dist-packages/find_job_titles/__init__.py in findall(self, string, use_longest)
82 else return all overlapping matches
83 :returns: list of matches of type `Match`
---> 84 """
85 return list(self.finditer(string, use_longest=use_longest))
86
RuntimeError: generator raised StopIteration
I tried using the suggestions from this Stack Overflow post but it didn't work.

Related

AttributeError: 'LpVariable' object has no attribute 'log'

I had this problem when trying to solve a optimization problem using pulp.
The code:
import pulp
import numpy as np
import math
prob = pulp.LpProblem("example", pulp.LpMaximize)
# Variable represent number of times device i is used
d = pulp.LpVariable("d", cat=pulp.LpContinuous,lowBound=0,upBound=np.inf)
var = pulp.LpVariable("var", cat=pulp.LpContinuous,lowBound=0,upBound=np.inf)
# The objective function that we want to maximize
n = len(y_arfima)
prob += -(n/2) * np.log(var) - np.sum([np.log((math.gamma(t)*math.gamma(t-2*d))/(math.gamma(t-d)**2)) for t in range(1,n+1)])/2 - 1/2
# Actually solve the problem, this calls GLPK so you need it installed
pulp.GLPK().solve(prob)
# Print out the results
for v in prob.variables():
print (v.name, "=", v.varValue)
The error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
AttributeError: 'LpVariable' object has no attribute 'log'
The above exception was the direct cause of the following exception:
TypeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_12336/3027528854.py in <module>
11 # The objective function that we want to maximize
12 n = len(y_arfima)
---> 13 prob += -(n/2) * np.log(var) - np.sum([np.log((math.gamma(t)*math.gamma(t-2*d))/(math.gamma(t-d)**2)) for t in range(1,n+1)])/2 - 1/2
14
15 # Actually solve the problem, this calls GLPK so you need it installed
TypeError: loop of ufunc does not support argument 0 of type LpVariable which has no callable log method
AttributeError Traceback (most recent call last)
AttributeError: 'LpVariable' object has no attribute 'log'
The above exception was the direct cause of the following exception:
TypeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_12336/3027528854.py in
11 # The objective function that we want to maximize
12 n = len(y_arfima)
---> 13 prob += -(n/2) * np.log(var) - np.sum([np.log((math.gamma(t)math.gamma(t-2d))/(math.gamma(t-d)**2)) for t in range(1,n+1)])/2 - 1/2
14
15 # Actually solve the problem, this calls GLPK so you need it installed
TypeError: loop of ufunc does not support argument 0 of type LpVariable which has no callable log method
Can you help me?
Thanks!

Issue creating data for training and testing using 3 folders containing images

I am running:
path = Path('/content/drive/MyDrive/X-Ray_Image_DataSet')
np.random.seed(41)
data = ImageDataBunch.from_folder(dta, train="Train", valid ="Valid", ds_tfms=get_transforms(),size=(256,256), bs=32, num_workers=4).normalize()
And I am getting this error:
/usr/local/lib/python3.7/dist-packages/fastai/data_block.py:458: UserWarning: Your training set is empty. If this is by design, pass `ignore_empty=True` to remove this warning.
warn("Your training set is empty. If this is by design, pass `ignore_empty=True` to remove this warning.")
/usr/local/lib/python3.7/dist-packages/fastai/data_block.py:461: UserWarning: Your validation set is empty. If this is by design, use `split_none()`
or pass `ignore_empty=True` when labelling to remove this warning.
or pass `ignore_empty=True` when labelling to remove this warning.""")
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/fastai/data_block.py in get_label_cls(self, labels, label_cls, label_delim, **kwargs)
264 if label_delim is not None: return MultiCategoryList
--> 265 try: it = index_row(labels,0)
266 except: raise Exception("""Can't infer the type of your targets.
7 frames
IndexError: index 0 is out of bounds for axis 0 with size 0
During handling of the above exception, another exception occurred:
Exception Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/fastai/data_block.py in get_label_cls(self, labels, label_cls, label_delim, **kwargs)
265 try: it = index_row(labels,0)
266 except: raise Exception("""Can't infer the type of your targets.
--> 267 It's either because your data source is empty or because your labelling function raised an error.""")
268 if isinstance(it, (float, np.float32)): return FloatList
269 if isinstance(try_int(it), (str, Integral)): return CategoryList
Exception: Can't infer the type of your targets.
It's either because your data source is empty or because your labelling function raised an error.
np.random.seed(41)
data = ImageDataBunch.from_folder(path, train = '.', valid_pct=0.2,
ds_tfms=get_transforms(), size=(256,256), bs=32, num_workers=4).normalize()
you can use this instead of that

TypeError While loading the files

train_dir = os.path.join(X_train,y_train)
test_dir = os.path.join(X_test, y_test)
if not os.path.exists(train_dir):
os.makedirs(train_dir)
if not os.path.exists(test_dir):
os.makedirs(test_dir)
This is my piece of code to load the files the of train and test, but got the error of type;
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-39-144de685caf8> in <module>
----> 1 train_dir = os.path.join(X_train,y_train)
2 test_dir = os.path.join(X_test, y_test)
3
4 if not os.path.exists(train_dir):
5 os.makedirs(train_dir)
~/anaconda3/lib/python3.7/posixpath.py in join(a, *p)
78 will be discarded. An empty last part will result in a path that
79 ends with a separator."""
---> 80 a = os.fspath(a)
81 sep = _get_sep(a)
82 path = a
TypeError: expected str, bytes or os.PathLike object, not list
I do all the things which can do this to correct, please help me out.

gensim lemmatize error generator raised StopIteration

I'm trying to execute simple code to lemmatize string, but there's an error about iteration.
I have found some solutions which are about reinstalling web.py, but this not worked for me.
python code
from gensim.utils import lemmatize
lemmatize("gone")
error is
---------------------------------------------------------------------------
StopIteration Traceback (most recent call last)
I:\Anaconda\lib\site-packages\pattern\text\__init__.py in _read(path, encoding, comment)
608 yield line
--> 609 raise StopIteration
610
StopIteration:
The above exception was the direct cause of the following exception:
RuntimeError Traceback (most recent call last)
<ipython-input-4-9daceee1900f> in <module>
1 from gensim.utils import lemmatize
----> 2 lemmatize("gone")
-------------------------------------------------------------------------------------
I:\Anaconda\lib\site-packages\pattern\text\__init__.py in <genexpr>(.0)
623 def load(self):
624 # Arnold NNP x
--> 625 dict.update(self, (x.split(" ")[:2] for x in _read(self._path) if len(x.split(" ")) > 1))
626
627 #--- FREQUENCY -------------------------------------------------------------------------------------
RuntimeError: generator raised StopIteration
The error message is misleading – it occurs when there's nothing to properly lemmatize.
By default, lemmatize() only accepts word tags NN|VB|JJ|RB. Pass in a regexp that matches any string to change this:
>>> import re
>>> lemmatize("gone", allowed_tags=re.compile('.*'))
[b'go/VB']

My freq-dist function keeps coming up undefined (python nltk) 3.4

I'm doing NLP with Python 3.4, and my frequency distribution function keeps returning as undefined, even after I call on "import nltk..." I appreciate any help. I am not having any other issues. I have Windows 7, 64 bit
Here is the code:
from nltk.book import *
text1
Out[39]: <Text: Moby Dick by Herman Melville 1851>
fdist1 = FreqDist(text1)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-40-a9ccb6c27929> in <module>()
----> 1 fdist1 = FreqDist(text1)
NameError: name 'FreqDist' is not defined
fdist1
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-41-f986ce66c258> in <module>()
----> 1 fdist1
NameError: name 'fdist1' is not defined
import nltk
text1 = nltk.book.text1
fdist1 = nltk.FreqDist(text1)
print(fdist1)
Result:
<FreqDist with 19317 samples and 260819 outcomes>

Categories