POLYGLOT >> ValueError: Package u'pos2.ms' not found in index - python

I learn to use polyglot to give POS tag Indonesian texts.
import polyglot
from polyglot.text import Text, Word
text=Text("Menurut dia, Syahganda, dikenal sebagai penggiat isu-isu pertanahan serta perburuhan.")
print text.pos_tags
But error appeared:
Traceback (most recent call last):
File "polyglot-tagger.py", line 35, in <module>
arrTag=text.pos_tags
File "/usr/local/lib/python2.7/dist-packages/polyglot/decorators.py", line 20, in __get__
value = obj.__dict__[self.func.__name__] = self.func(obj)
File "/usr/local/lib/python2.7/dist-packages/polyglot/text.py", line 147, in pos_tags
for word,t in self.pos_tagger.annotate(self.words):
File "/usr/local/lib/python2.7/dist-packages/polyglot/decorators.py", line 20, in __get__
value = obj.__dict__[self.func.__name__] = self.func(obj)
File "/usr/local/lib/python2.7/dist-packages/polyglot/text.py", line 100, in pos_tagger
return get_pos_tagger(lang=self.language.code)
File "/usr/local/lib/python2.7/dist-packages/polyglot/decorators.py", line 30, in memoizer
cache[key] = obj(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/polyglot/tag/base.py", line 147, in get_pos_tagger
return POSTagger(lang=lang)
File "/usr/local/lib/python2.7/dist-packages/polyglot/tag/base.py", line 126, in __init__
super(POSTagger, self).__init__(lang=lang)
File "/usr/local/lib/python2.7/dist-packages/polyglot/tag/base.py", line 40, in __init__
self.predictor = self._load_network()
File "/usr/local/lib/python2.7/dist-packages/polyglot/tag/base.py", line 134, in _load_network
self.model = load_pos_model(lang=self.lang, version=2)
File "/usr/local/lib/python2.7/dist-packages/polyglot/decorators.py", line 30, in memoizer
cache[key] = obj(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/polyglot/load.py", line 114, in load_pos_model
p = locate_resource(src_dir, lang)
File "/usr/local/lib/python2.7/dist-packages/polyglot/load.py", line 47, in locate_resource
if downloader.status(package_id) != downloader.INSTALLED:
File "/usr/local/lib/python2.7/dist-packages/polyglot/downloader.py", line 737, in status
info = self._info_or_id(info_or_id)
File "/usr/local/lib/python2.7/dist-packages/polyglot/downloader.py", line 507, in _info_or_id
return self.info(info_or_id)
File "/usr/local/lib/python2.7/dist-packages/polyglot/downloader.py", line 933, in info
raise ValueError('Package %r not found in index' % id)
ValueError: Package u'pos2.ms' not found in index
When I tried to download pos2.ms(Part-of-speech Model for Malay), it doesn't exists in model. What should I do?
**I use Ubuntu and python 2.7
Thanks for your help before

Check the language coverage for Malay
http://polyglot.readthedocs.org/en/latest/POS.html#languages-coverage
We are planning to add more languages in the futrue

Related

xlwings recently stopped getting live data from excel via Range

I was running a script to get data from excel for over a year using the Xlwings range command like so...
list=Range('A1:D10').value
Suddenly, it stopper working. I had changed nothing in the code nor the system, other than maybe installing another network card.
This is the error when trying to use the Range assignment now.
Traceback (most recent call last):
File "G:\python32\fetcher.py", line 61, in <module>
listFull = getComData()
File "G:\python32\fetcher.py", line 38, in getComData
listFull=Range('A4:H184').value
File "G:\python32\lib\site-packages\xlwings\main.py", line 1490, in __init__
impl = apps.active.range(cell1).impl
File "G:\python32\lib\site-packages\xlwings\main.py", line 439, in range
return Range(impl=self.impl.range(cell1, cell2))
File "G:\python32\lib\site-packages\xlwings\_xlwindows.py", line 457, in range
xl1 = self.xl.Range(arg1)
File "G:\python32\lib\site-packages\xlwings\_xlwindows.py", line 341, in xl
self._xl = get_xl_app_from_hwnd(self._hwnd)
File "G:\python32\lib\site-packages\xlwings\_xlwindows.py", line 251, in get_xl_app_from_hwnd
disp = COMRetryObjectWrapper(Dispatch(p))
File "G:\python32\lib\site-packages\win32com\client\__init__.py", line 96, in Dispatch
return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, clsctx=clsctx)
File "G:\python32\lib\site-packages\win32com\client\__init__.py", line 37, in __WrapDispatch
klass = gencache.GetClassForCLSID(resultCLSID)
File "G:\python32\lib\site-packages\win32com\client\gencache.py", line 180, in GetClassForCLSID
mod = GetModuleForCLSID(clsid)
File "G:\python32\lib\site-packages\win32com\client\gencache.py", line 223, in GetModuleForCLSID
mod = GetModuleForTypelib(typelibCLSID, lcid, major, minor)
File "G:\python32\lib\site-packages\win32com\client\gencache.py", line 259, in GetModuleForTypelib
mod = _GetModule(modName)
File "G:\python32\lib\site-packages\win32com\client\gencache.py", line 622, in _GetModule
mod = __import__(mod_name)
ValueError: source code string cannot contain null bytes

Very basic Moviepy script failing to run

So, I have this very basic script that concatenates two videos, and adds a background sound.
def intro():
voiceoverIntro = AudioFileClip(audio[3]) #get path for intro.mp3
introVideo = []
temp = p1vid + p2vid + p3vid
for x in temp: # add product videos to introVideo if they are longer than intro.mp3
x = VideoFileClip(x)
if x.duration >= voiceoverIntro.duration:
introVideo.append(x)
if len(introVideo) >= 1:
#Get the video and turn off its volume
introBg = introVideo[0].volumex(0).resize((1280,720))
introBg = introBg.set_audio(voiceoverIntro).set_duration(voiceoverIntro.duration)
introBg.reader.close()
introBg.audio.reader.close_proc()
return introBg
And this function creates the second clip
def productThreeOpener(productName):
opener3 = VideoFileClip("media/number3.mp4").volumex(0).resize((1280,720))
text = TextClip(productName,fontsize=60,color='white', font="Dekar")\
.set_pos(("right", "center"))\
.set_duration(3)\
.set_start(2)\
.crossfadein(1)\
.crossfadeout(1)\
.margin(right=200,opacity=0)
opener3 = CompositeVideoClip([opener3, text])
return opener3
Now we just concatenate the two outputs
final_clip = concatenate_videoclips([intro, productThreeOpener], method="compose")
final_clip.resize((1280, 720)).write_videofile("output/intro.mp4", threads=8, fps=24, progress_bar=False)
Running the code above returns this error;
Traceback (most recent call last):
[MoviePy] >>>> Building video output/intro.mp4
File "C:/Users/Akbulut/PycharmProjects/youtubeVideoEditor/vidEditor/sandbox.py", line 145, in <module>
[MoviePy] Writing audio in introTEMP_MPY_wvf_snd.mp3
final_clip.write_videofile("output/intro.mp4", threads=8, fps=24, progress_bar=False)
File "<decorator-gen-51>", line 2, in write_videofile
File "C:\Program Files\Python36\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "<decorator-gen-50>", line 2, in write_videofile
File "C:\Program Files\Python36\lib\site-packages\moviepy\decorators.py", line 137, in use_clip_fps_by_default
return f(clip, *new_a, **new_kw)
File "<decorator-gen-49>", line 2, in write_videofile
File "C:\Program Files\Python36\lib\site-packages\moviepy\decorators.py", line 22, in convert_masks_to_RGB
return f(clip, *a, **k)
File "C:\Program Files\Python36\lib\site-packages\moviepy\video\VideoClip.py", line 318, in write_videofile
progress_bar=progress_bar)
File "<decorator-gen-73>", line 2, in write_audiofile
File "C:\Program Files\Python36\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "C:\Program Files\Python36\lib\site-packages\moviepy\audio\AudioClip.py", line 213, in write_audiofile
progress_bar=progress_bar)
File "<decorator-gen-70>", line 2, in ffmpeg_audiowrite
File "C:\Program Files\Python36\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "C:\Program Files\Python36\lib\site-packages\moviepy\audio\io\ffmpeg_audiowriter.py", line 165, in ffmpeg_audiowrite
ffmpeg_params=ffmpeg_params)
File "C:\Program Files\Python36\lib\site-packages\moviepy\audio\io\ffmpeg_audiowriter.py", line 71, in __init__
self.proc = sp.Popen(cmd, **popen_params)
File "C:\Program Files\Python36\lib\subprocess.py", line 594, in __init__
_cleanup()
File "C:\Program Files\Python36\lib\subprocess.py", line 205, in _cleanup
res = inst._internal_poll(_deadstate=sys.maxsize)
File "C:\Program Files\Python36\lib\subprocess.py", line 1025, in _internal_poll
if _WaitForSingleObject(self._handle, 0) == _WAIT_OBJECT_0:
OSError: [WinError 6] İşleyici geçersiz
Exception ignored in: <bound method FFMPEG_AudioWriter.__del__ of <moviepy.audio.io.ffmpeg_audiowriter.FFMPEG_AudioWriter object at 0x0000000A885019B0>>
Traceback (most recent call last):
File "C:\Program Files\Python36\lib\site-packages\moviepy\audio\io\ffmpeg_audiowriter.py", line 134, in __del__
self.close()
File "C:\Program Files\Python36\lib\site-packages\moviepy\audio\io\ffmpeg_audiowriter.py", line 122, in close
if self.proc:
AttributeError: 'FFMPEG_AudioWriter' object has no attribute 'proc'
Process finished with exit code 1
I strictly followed MoviePY installation guide, installed it and all of its dependencies about 2 days ago. I work on a 64b Windows machine. Python version 3.6.1
I've been stuck with this error for over a day now, and I don't know what to try.. Any help/advice is highly appreciated.
Thanks.

use polyglot package for Named Entity Recognition in hebrew

I am trying to use the polyglot package for Named Entity Recognition in hebrew.
this is my code:
# -*- coding: utf8 -*-
import polyglot
from polyglot.text import Text, Word
from polyglot.downloader import downloader
downloader.download("embeddings2.iw")
text = Text(u"in france and in germany")
print(type(text))
text2 = Text(u"נסעתי מירושלים לתל אביב")
print(type(text2))
print(text.entities)
print(text2.entities)
this is the output:
<class 'polyglot.text.Text'>
<class 'polyglot.text.Text'>
[I-LOC([u'france']), I-LOC([u'germany'])]
Traceback (most recent call last):
File "C:/Python27/Lib/site-packages/IPython/core/pyglot.py", line 15, in <module>
print(text2.entities)
File "C:\Python27\lib\site-packages\polyglot\decorators.py", line 20, in __get__
value = obj.__dict__[self.func.__name__] = self.func(obj)
File "C:\Python27\lib\site-packages\polyglot\text.py", line 132, in entities
for i, (w, tag) in enumerate(self.ne_chunker.annotate(self.words)):
File "C:\Python27\lib\site-packages\polyglot\decorators.py", line 20, in __get__
value = obj.__dict__[self.func.__name__] = self.func(obj)
File "C:\Python27\lib\site-packages\polyglot\text.py", line 100, in ne_chunker
return get_ner_tagger(lang=self.language.code)
File "C:\Python27\lib\site-packages\polyglot\decorators.py", line 30, in memoizer
cache[key] = obj(*args, **kwargs)
File "C:\Python27\lib\site-packages\polyglot\tag\base.py", line 191, in get_ner_tagger
return NEChunker(lang=lang)
File "C:\Python27\lib\site-packages\polyglot\tag\base.py", line 104, in __init__
super(NEChunker, self).__init__(lang=lang)
File "C:\Python27\lib\site-packages\polyglot\tag\base.py", line 40, in __init__
self.predictor = self._load_network()
File "C:\Python27\lib\site-packages\polyglot\tag\base.py", line 109, in _load_network
self.embeddings = load_embeddings(self.lang, type='cw', normalize=True)
File "C:\Python27\lib\site-packages\polyglot\decorators.py", line 30, in memoizer
cache[key] = obj(*args, **kwargs)
File "C:\Python27\lib\site-packages\polyglot\load.py", line 61, in load_embeddings
p = locate_resource(src_dir, lang)
File "C:\Python27\lib\site-packages\polyglot\load.py", line 43, in locate_resource
if downloader.status(package_id) != downloader.INSTALLED:
File "C:\Python27\lib\site-packages\polyglot\downloader.py", line 738, in status
info = self._info_or_id(info_or_id)
File "C:\Python27\lib\site-packages\polyglot\downloader.py", line 508, in _info_or_id
return self.info(info_or_id)
File "C:\Python27\lib\site-packages\polyglot\downloader.py", line 934, in info
raise ValueError('Package %r not found in index' % id)
ValueError: Package u'embeddings2.iw' not found in index
The english worked but not the hebrew.
Whether I try to download the package u'embeddings2.iw' or not I get:
ValueError: Package u'embeddings2.iw' not found in index
I got it!
It seems like a bug to me.
The language detection defined the language as 'iw' which is the The former ISO 639 language code for Hebrew, and was changed to 'he'.
The text.entities did not recognize the iw code, so i changes it like so:
text2.hint_language_code = 'he'

google-api-python-client broken by OAuth2?

I am trying to check whether a certain dataset exists in BigQuery and I get this very strange error I've never had untill yesterday:
ERROR:dsUtils.bq_utils:Could not check if dataset tmp exists.
Traceback (most recent call last):
File "C:\Users\paco\Anaconda3\envs\visitForecastEnv\lib\site-packages\dsUtils\bq_utils.py", line 113, in _get
resp = bq_service.datasets().get(projectId=self.project_id, datasetId=self.id).execute(num_retries=2)
File "C:\Users\paco\Anaconda3\envs\visitForecastEnv\lib\site-packages\oauth2client\util.py", line 137, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\Users\paco\Anaconda3\envs\visitForecastEnv\lib\site-packages\googleapiclient\http.py", line 755, in execute
method=str(self.method), body=self.body, headers=self.headers)
File "C:\Users\paco\Anaconda3\envs\visitForecastEnv\lib\site-packages\googleapiclient\http.py", line 93, in _retry_request
resp, content = http.request(uri, method, *args, **kwargs)
File "C:\Users\paco\Anaconda3\envs\visitForecastEnv\lib\site-packages\oauth2client\client.py", line 598, in new_request
self._refresh(request_orig)
File "C:\Users\paco\Anaconda3\envs\visitForecastEnv\lib\site-packages\oauth2client\client.py", line 864, in _refresh
self._do_refresh_request(http_request)
File "C:\Users\paco\Anaconda3\envs\visitForecastEnv\lib\site-packages\oauth2client\client.py", line 891, in _do_refresh_request
body = self._generate_refresh_request_body()
File "C:\Users\paco\Anaconda3\envs\visitForecastEnv\lib\site-packages\oauth2client\client.py", line 1597, in _generate_refresh_request_body
assertion = self._generate_assertion()
File "C:\Users\paco\Anaconda3\envs\visitForecastEnv\lib\site-packages\oauth2client\service_account.py", line 318, in _generate_assertion
key_id=self._private_key_id)
File "C:\Users\paco\Anaconda3\envs\visitForecastEnv\lib\site-packages\oauth2client\crypt.py", line 97, in make_signed_jwt
signature = signer.sign(signing_input)
File "C:\Users\paco\Anaconda3\envs\visitForecastEnv\lib\site-packages\oauth2client\_pycrypto_crypt.py", line 101, in sign
return PKCS1_v1_5.new(self._key).sign(SHA256.new(message))
File "C:\Users\paco\Anaconda3\envs\visitForecastEnv\lib\site-packages\Crypto\Signature\PKCS1_v1_5.py", line 112, in sign
m = self._key.decrypt(em)
File "C:\Users\paco\Anaconda3\envs\visitForecastEnv\lib\site-packages\Crypto\PublicKey\RSA.py", line 174, in decrypt
return pubkey.pubkey.decrypt(self, ciphertext)
File "C:\Users\paco\Anaconda3\envs\visitForecastEnv\lib\site-packages\Crypto\PublicKey\pubkey.py", line 93, in decrypt
plaintext=self._decrypt(ciphertext)
File "C:\Users\paco\Anaconda3\envs\visitForecastEnv\lib\site-packages\Crypto\PublicKey\RSA.py", line 235, in _decrypt
r = getRandomRange(1, self.key.n-1, randfunc=self._randfunc)
File "C:\Users\paco\Anaconda3\envs\visitForecastEnv\lib\site-packages\Crypto\PublicKey\RSA.py", line 126, in __getattr__
raise AttributeError("%s object has no %r attribute" % (self.__class__.__name__, attrname,))
AttributeError: _RSAobj object has no '_randfunc' attribute
Has anyone an idea of why I get these errors suddenly?

Invalid tag name - django tastypie

I keep getting the following error:
Traceback (most recent call last):
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 114, in get_response
response = wrapped_callback(request, callback_args, *callback_kwargs)
File "/app/.heroku/python/lib/python2.7/site-packages/newrelic-2.6.0.5/newrelic/hooks/framework_django.py", line 485, in wrapper
return wrapped(args, *kwargs)
File "/app/.heroku/python/lib/python2.7/site-packages/newrelic-2.6.0.5/newrelic/hooks/component_tastypie.py", line 49, in inner_fn_wrapper
return inner_fn(args, *kwargs)
File "/app/.heroku/src/django-tastypie-master/tastypie/api.py", line 78, in wrapper
return getattr(self, view)(request, args, *kwargs)
File "/app/.heroku/src/django-tastypie-master/tastypie/api.py", line 155, in top_level
serialized = self.serializer.serialize(available_resources, desired_format, options)
File "/app/.heroku/src/django-tastypie-master/tastypie/serializers.py", line 203, in serialize
serialized = getattr(self, "to_%s" % desired_format)(bundle, options)
File "/app/.heroku/src/django-tastypie-master/tastypie/serializers.py", line 410, in to_xml
return tostring(self.to_etree(data, options), xml_declaration=True, encoding='utf-8')
File "/app/.heroku/src/django-tastypie-master/tastypie/serializers.py", line 294, in to_etree
element.append(self.to_etree(value, options, name=key, depth=depth+1))
File "/app/.heroku/src/django-tastypie-master/tastypie/serializers.py", line 291, in to_etree
element = Element(name or 'object')
File "lxml.etree.pyx", line 2841, in lxml.etree.Element (src/lxml/lxml.etree.c:66367)
File "apihelpers.pxi", line 110, in lxml.etree._makeElement (src/lxml/lxml.etree.c:14784)
File "apihelpers.pxi", line 1573, in lxml.etree._tagValidOrRaise (src/lxml/lxml.etree.c:28777)
ValueError: Invalid tag name u'user/photos'
The error comes from serializers.py:
if lxml is None:
raise ImproperlyConfigured("Usage of the XML aspects requires lxml and defusedxml.")
return tostring(self.to_etree(data, options), xml_declaration=True, encoding='utf-8')
Does anyone have a clue how to solve this?

Categories