I run:
from nltk.corpus import framenet as fn
fn.frames()
And get the following error:
Traceback (most recent call last):
File "/Users/me/anaconda3/envs/nlp/lib/python3.6/site-packages/nltk/corpus/reader/framenet.py", line 1308, in frame_by_name
elt = XMLCorpusView(locpath, 'frame')[0]
File "/Users/me/anaconda3/envs/nlp/lib/python3.6/site-packages/nltk/corpus/reader/xmldocs.py", line 155, in __init__
encoding = self._detect_encoding(fileid)
File "/Users/me/anaconda3/envs/nlp/lib/python3.6/site-packages/nltk/corpus/reader/xmldocs.py", line 166, in _detect_encoding
with open(fileid, 'rb') as infile:
NotADirectoryError: [Errno 20] Not a directory: '/Users/me/nltk_data/corpora/framenet_v17.zip/framenet_v17/frame/Abandonment.xml'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/me/anaconda3/envs/nlp/lib/python3.6/site-packages/nltk/corpus/reader/framenet.py", line 876, in __repr__
for elt in self:
File "/Users/me/anaconda3/envs/nlp/lib/python3.6/site-packages/nltk/collections.py", line 406, in iterate_from
try: yield self._func(self._lists[0][index])
File "/Users/me/anaconda3/envs/nlp/lib/python3.6/site-packages/nltk/corpus/reader/framenet.py", line 1407, in frame
f = self.frame_by_id(fn_fid_or_fname, ignorekeys)
File "/Users/me/anaconda3/envs/nlp/lib/python3.6/site-packages/nltk/corpus/reader/framenet.py", line 1268, in frame_by_id
return self.frame_by_name(name, ignorekeys, check_cache=False)
File "/Users/me/anaconda3/envs/nlp/lib/python3.6/site-packages/nltk/corpus/reader/framenet.py", line 1310, in frame_by_name
raise FramenetError('Unknown frame: {0}'.format(fn_fname))
nltk.corpus.reader.framenet.FramenetError: Unknown frame: Abandonment
Both the Framenet 1.5 and 1.7 corpora are installed, according to nltk.download()
Related
I am trying to control the value of a UpDown spinner element with pywinauto.
this is my element i want to control:
UpDown - 'Spinner' (L384, T624, R400, B642)
| | | | | ['Spinner', 'SpinnerUpDown', 'UpDown']
| | | | | child_window(title="Spinner", auto_id="68226", control_type="Spinner")
I am not sure how to get it's value and set it's value through pywinauto.
i have succeded doing it with button element, but the spinner element is not working while doing the examples and help i found on the internet.
my code goes like this:
from pywinauto.application import Application
app = Application(backend="uia").start('smcg2gui.exe')
# app.PololuSimpleMotorControlCenterG2.print_control_identifiers()
stop_motor = app.PololuSimpleMotorControlCenterG2.child_window(title="Stop motor", auto_id="stopMotorButton", control_type="Button")
speed_controller = app.PololuSimpleMotorControlCenterG2.child_window(title="Spinner", auto_id="7995854", control_type="Spinner")
speed_controller.get_value()
stop_motor.click()
print("done")
and i am getting this error:
Traceback (most recent call last):
File "C:\Users\owner\AppData\Local\Programs\Python\Python39\lib\site-packages\pywinauto\application.py", line 250, in __resolve_control
ctrl = wait_until_passes(
File "C:\Users\owner\AppData\Local\Programs\Python\Python39\lib\site-packages\pywinauto\timings.py", line 458, in wait_until_passes
raise err
pywinauto.timings.TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\owner\Desktop\try.py", line 12, in <module>
speed_controller.get_value()
File "C:\Users\owner\AppData\Local\Programs\Python\Python39\lib\site-packages\pywinauto\application.py", line 379, in __getattribute__
ctrls = self.__resolve_control(self.criteria)
File "C:\Users\owner\AppData\Local\Programs\Python\Python39\lib\site-packages\pywinauto\application.py", line 261, in __resolve_control
raise e.original_exception
File "C:\Users\owner\AppData\Local\Programs\Python\Python39\lib\site-packages\pywinauto\timings.py", line 436, in wait_until_passes
func_val = func(*args, **kwargs)
File "C:\Users\owner\AppData\Local\Programs\Python\Python39\lib\site-packages\pywinauto\application.py", line 222, in __get_ctrl
ctrl = self.backend.generic_wrapper_class(findwindows.find_element(**ctrl_criteria))
File "C:\Users\owner\AppData\Local\Programs\Python\Python39\lib\site-packages\pywinauto\findwindows.py", line 87, in find_element
raise ElementNotFoundError(kwargs)
pywinauto.findwindows.ElementNotFoundError: {'title': 'Spinner', 'auto_id': '7995854', 'control_type': 'Spinner', 'top_level_only': False, 'parent': <uia_element_info.UIAElementInfo - 'Pololu Simple Motor Control Center G2', WindowsForms10.Window.8.app.0.33c0d9d, 1835472>, 'backend': 'uia'}
so i tried doing it with wrapper_object:
from pywinauto.application import Application
app = Application(backend="uia").start('smcg2gui.exe')
# app.PololuSimpleMotorControlCenterG2.print_control_identifiers()
stop_motor = app.PololuSimpleMotorControlCenterG2.child_window(title="Stop motor", auto_id="stopMotorButton", control_type="Button")control_type="Button")
speed_controller = app.PololuSimpleMotorControlCenterG2.UpDown.wrapper_object()
print(speed_controller.iface_value.CurrentValue)
stop_motor.click()
print("done")
and got this:
Traceback (most recent call last):
File "C:\Users\owner\AppData\Local\Programs\Python\Python39\lib\site-packages\pywinauto\uia_defines.py", line 234, in get_elem_interface
iface = cur_ptrn.QueryInterface(cls_name)
File "C:\Users\owner\AppData\Local\Programs\Python\Python39\lib\site-packages\comtypes\__init__.py", line 1197, in QueryInterface
self.__com_QueryInterface(byref(iid), byref(p))
ValueError: NULL COM pointer access
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\owner\Desktop\try.py", line 12, in <module>
print(speed_controller.iface_value.CurrentValue)
File "C:\Users\owner\AppData\Local\Programs\Python\Python39\lib\site-packages\pywinauto\controls\uiawrapper.py", line 132, in __get__
value = self.fget(obj)
File "C:\Users\owner\AppData\Local\Programs\Python\Python39\lib\site-packages\pywinauto\controls\uiawrapper.py", line 252, in iface_value
return uia_defs.get_elem_interface(elem, "Value")
File "C:\Users\owner\AppData\Local\Programs\Python\Python39\lib\site-packages\pywinauto\uia_defines.py", line 236, in get_elem_interface
raise NoPatternInterfaceError()
pywinauto.uia_defines.NoPatternInterfaceError
i am a bit lost.
Thank you very much
I am trying to import a tsv file of amazon customer reviews (size 1.2 gb) into pandas.
This is what I have tried:
import pandas as pd
tsv_books = pd.read_csv('/Users/hs/Downloads/amazon_reviews_us_Books_v1_02.tsv', sep='\t')
print(tsv_books)
I am getting these error messages:
Traceback (most recent call last):
File "/Users/hs/opt/anaconda3/envs/python39/lib/python3.9/site-packages/pandas/io/parsers/python_parser.py", line 760, in _next_iter_line
line = next(self.data)
_csv.Error: ' ' expected after '"'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/hs/PycharmProjects/Thesis Analysis/main.py", line 4, in <module>
tsv_books = pd.read_csv('/Users/hs/Downloads/amazon_reviews_us_Books_v1_02.tsv', delimiter='\t', engine="python")
File "/Users/hs/opt/anaconda3/envs/python39/lib/python3.9/site-packages/pandas/util/_decorators.py", line 311, in wrapper
return func(*args, **kwargs)
File "/Users/hs/opt/anaconda3/envs/python39/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 680, in read_csv
return _read(filepath_or_buffer, kwds)
File "/Users/hs/opt/anaconda3/envs/python39/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 581, in _read
return parser.read(nrows)
File "/Users/hs/opt/anaconda3/envs/python39/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 1250, in read
index, columns, col_dict = self._engine.read(nrows)
File "/Users/hs/opt/anaconda3/envs/python39/lib/python3.9/site-packages/pandas/io/parsers/python_parser.py", line 238, in read
content = self._get_lines(rows)
File "/Users/hs/opt/anaconda3/envs/python39/lib/python3.9/site-packages/pandas/io/parsers/python_parser.py", line 1091, in _get_lines
new_row = self._next_iter_line(row_num=self.pos + rows + 1)
File "/Users/hs/opt/anaconda3/envs/python39/lib/python3.9/site-packages/pandas/io/parsers/python_parser.py", line 789, in _next_iter_line
self._alert_malformed(msg, row_num)
File "/Users/hs/opt/anaconda3/envs/python39/lib/python3.9/site-packages/pandas/io/parsers/python_parser.py", line 739, in _alert_malformed
raise ParserError(msg)
pandas.errors.ParserError: ' ' expected after '"'
This seems to be a rookie mistake, sorry guys. Nonetheless I would appreciate any help!
My code runs fine in normal mode but when i try to run it in debug mode it throws exception, I am trying to create a TF-IDF matrix of genre column in spotify_df. Why is this happening.
P.S - genre column of spotify_df contains 1-D list of strings and none of them is empty.
Code:
tracks_df = pd.read_csv('tracks_with_genres_v3.csv')
def create_tf_idf(spotify_df):
tfidf = TfidfVectorizer()
tfidf_matrix = tfidf.fit_transform(spotify_df['genres'].apply(lambda x: " ".join(x)))
genre_df = pd.DataFrame(tfidf_matrix.toarray())
genre_df.columns = ['genre' + "|" + i for i in tfidf.get_feature_names_out()]
genre_df.reset_index(drop=True, inplace=True)
return genre_df
def create_feature_set(spotify_df):
genre_tf_idf = create_tf_idf(spotify_df)
complete_feature_set = create_feature_set(tracks_df)
Exception:
Traceback (most recent call last):
File "D:\PyCharm\Music_Recommendation_v2\venv\lib\site-packages\numpy\core\getlimits.py", line 516, in __init__
self.dtype = numeric.dtype(int_type)
TypeError: 'NoneType' object is not callable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 2022.1.1\plugins\python\helpers\pydev\pydevd.py", line 1491, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm 2022.1.1\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "D:/PyCharm/Music_Recommendation_v2/main.py", line 220, in <module>
begin("Heartless", "Weeknd")
File "D:/PyCharm/Music_Recommendation_v2/main.py", line 179, in begin
complete_feature_set = create_feature_set(tracks_df)
File "D:/PyCharm/Music_Recommendation_v2/main.py", line 115, in create_feature_set
genre_tf_idf = create_tf_idf(spotify_df)
File "D:/PyCharm/Music_Recommendation_v2/main.py", line 95, in create_tf_idf
tfidf_matrix = tfidf.fit_transform(spotify_df['genres'].apply(lambda x: " ".join(x)))
File "D:\PyCharm\Music_Recommendation_v2\venv\lib\site-
packages\sklearn\feature_extraction\text.py", line 2068, in fit_transform
X = super().fit_transform(raw_documents)
File "D:\PyCharm\Music_Recommendation_v2\venv\lib\site-
packages\sklearn\feature_extraction\text.py", line 1328, in fit_transform
vocabulary, X = self._count_vocab(raw_documents, self.fixed_vocabulary_)
File "D:\PyCharm\Music_Recommendation_v2\venv\lib\site-
packages\sklearn\feature_extraction\text.py", line 1222, in _count_vocab
if indptr[-1] > np.iinfo(np.int32).max: # = 2**31 - 1
File "D:\PyCharm\Music_Recommendation_v2\venv\lib\site-packages\numpy\core\getlimits.py",
line 518, in __init__
self.dtype = numeric.dtype(type(int_type))
TypeError: 'NoneType' object is not callable
I'm getting configparser.NoSectionError: No section: 'creds
Config.cfg file
[creds]
token = telegram_bot_token
code.py file
class telegram_bot() :
def __init__(self,config):
self.token=self.read("config.cfg")
self.base="https://api.telegram.org/bot{}/".format(self.token)
def read(self,config):
self.parser=cfg.RawConfigParser()
self.parser.read(config)
return self.parser.get('creds','token')
Error
Traceback (most recent call last):
File "MAINSERVER.PY", line 5, in <module>
bots=telegram_bot("config.cfg")
File "G:\BOT\TBOT\bs4\qrcode\main.py", line 6, in __init__
self.token=self.read("config.cfg")
File "G:\BOT\TBOT\bs4\qrcode\main.py", line 24, in read
return self.parser.get('creds','token')
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38-32\lib\configparser.py", line 781, in get
d = self._unify_values(section, vars)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38-32\lib\configparser.py", line 1149, in _unify_values
raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'creds'
Anybody know what could be the issue ?
Unique index constraint in mongoengine throws this exception when I'm trying to save an object with the same id:
|2018-06-28 14:23:28.084| [DEBUG] (rec.exchange.base|26): Processing exchange data
Traceback (most recent call last):
File "/home/nst/virtualenvs/myenv/lib/python3.6/site-packages/mongoengine/document.py", line 372, in save
object_id = self._save_create(doc, force_insert, write_concern)
File "/home/nst/virtualenvs/myenv/lib/python3.6/site-packages/mongoengine/document.py", line 428, in _save_create
object_id = collection.save(doc, **write_concern)
File "/home/nst/virtualenvs/myenv/lib/python3.6/site-packages/pymongo/collection.py", line 2917, in save
to_save, True, check_keys, manipulate, write_concern)
File "/home/nst/virtualenvs/myenv/lib/python3.6/site-packages/pymongo/collection.py", line 599, in _insert
bypass_doc_val, session)
File "/home/nst/virtualenvs/myenv/lib/python3.6/site-packages/pymongo/collection.py", line 580, in _insert_one
_check_write_command_response(result)
File "/home/nst/virtualenvs/myenv/lib/python3.6/site-packages/pymongo/helpers.py", line 207, in _check_write_command_response
_raise_last_write_error(write_errors)
File "/home/nst/virtualenvs/myenv/lib/python3.6/site-packages/pymongo/helpers.py", line 188, in _raise_last_write_error
raise DuplicateKeyError(error.get("errmsg"), 11000, error)
pymongo.errors.DuplicateKeyError: E11000 duplicate key error collection: TRX.exchanges index: exchange_1_order.id_1 dup key: { : "BFNX", : "1234" }
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "run.py", line 5, in <module>
application.run()
File "/home/nst/Dev/rec/rec/trx_app.py", line 118, in run
self.run_scheduler_app()
File "/home/nst/Dev/rec/rec/trx_app.py", line 106, in run_scheduler_app
self.run_jobs_hook_without_scheduler()
File "/home/nst/Dev/rec/rec/trx_app.py", line 92, in run_jobs_hook_without_scheduler
get_exchange_job(order)
File "/home/nst/Dev/rec/rec/scheduler/job_hooks.py", line 39, in get_exchange_job
ExchangeJob(job_cfg).run()
File "/home/nst/Dev/rec/rec/exchange/job.py", line 22, in run
exchange_data = self.data_source.get_exchange_data()
File "/home/nst/Dev/rec/rec/exchange/base.py", line 15, in get_exchange_data
return self._map_data(self._read_data())
File "/home/nst/Dev/rec/rec/exchange/base.py", line 31, in _read_data
parser = self._build_data_parser()
File "/home/nst/Dev/rec/rec/exchange/impl/bitfinex.py", line 113, in _build_data_parser
ed1.save()
File "/home/nst/virtualenvs/myenv/lib/python3.6/site-packages/mongoengine/document.py", line 395, in save
raise NotUniqueError(message % six.text_type(err))
mongoengine.errors.NotUniqueError: Tried to save duplicate unique keys (E11000 duplicate key error collection: TRX.exchanges index: exchange_1_order.id_1 dup key: { : "BFNX", : "1234" })
I'm trying to write a unit test for this case:
from mongoengine.errors import NotUniqueError
def test_duplicate_exchange_data(self):
order1 = ExchangeOrder(id='1234', currency_pair='tBTGUSD',
datetime=datetime.datetime.today(),
amount=1500, price=57)
exchange_data1 = ExchangeData(exchange='BFNX', order=order1)
exchange_data1.save()
order2 = ExchangeOrder(id='1234', currency_pair='tBTCUSD',
datetime=datetime.datetime.today(),
amount=500, price=57.5)
exchange_data2 = ExchangeData(exchange='BFNX', order=order2)
self.assertRaises(NotUniqueError, exchange_data2.save)
but assertRaises() is not working because of the second exception. How can I handle this in test?