I am trying to use googletrans to translate some Spanish text to English. I am following the examples & below is my code.
from googletrans import Translator
translator = Translator()
txt = translator.translate('tener', src='es', dest='en')
I get the following error though,
AttributeError: 'NoneType' object has no attribute 'group'
What am I missing?
Seems like the issue is with Google, see the following stackoverflow post:
googletrans stopped working with error 'NoneType' object has no attribute 'group'
This solution worked for me (the accepted doesn't work for me):
https://stackoverflow.com/a/65113191/14676920
Related
I need to use spark in transfer learning to train images ,the error is:
"nnot import name 'resnet50' from 'keras.applications' (/usr/local/lib/python3.7/dist-packages/keras/applications/init.py) "
i try to solve this question since one week, this one is coming from sparkdl, if you add to this file (sparkdl/transformers/keras_applications.py)
**
from tensorflow.keras.applications
**, it will be return normal, but this time you will see another error like
AttributeError: module 'tensorflow' has no attribute 'Session'
i tried on different IDE (Pycharm, Vs Code) but i got the same errors. there are different explications on Stackoverflow. but i'm totally confused now
I have found this code and I wanna see what is the object that im printing in the last line. im new in field of nlp so please help me fix this code, because it gives AttributeError: 'Field' object has no attribute 'vocab'error. by the way I have found out that torchtext has been changed and the error is probably related to these changes, and the code probably was working before.
import spacy
from torchtext.legacy.data import Field
spacy_eng = spacy.load("en")
def tokenize_eng(text):
return [tok.text for tok in spacy_eng.tokenizer(text)]
english = Field(
tokenize=tokenize_eng, lower=True, init_token="<sos>", eos_token="<eos>"
)
print([english.vocab.stoi["<sos>"]])
You have to build the vocabulary for the english Field before you try to access it. You will need a dataset to build the vocabulary, which will be the dataset you are looking to build a model for. You can use english.build_vocab(...). Here are the docs for build_vocab.
Also, if you would like to learn how to migrate what you are doing to the new version of torchtext, here is a good resource.
I extremely new to python and practicing Loading a dataset from a url.
When running the following code:
In [1]: myUrl = "http://aima.cs.berkeley.edu/data/iris.csv"
In [2]: urlRequest = urllib.request.Request(myUrl)
I get this error:
File "", line 1, in
urlRequest = urllib.request.Request(myUrl)
AttributeError: 'module' object has no attribute 'request'
1) I tried researching this error and attempted to use import urllib3 again and it imported fine. However when attempting the request I get that error...
2) I attempted to get "help" help("urllib3") in python 3.6.0 and got:
No Python documentation found for 'urllib3'. Use help() to get the
interactive help utility. Use help(str) for help on the str class.
3) I searched Stackoverflow and saw a similar question; tried the suggestions and was not able to move past that line of code...
Am I doing something wrong here?
Thanks in advance for your time
From what I see "request" is not a package, meaning that you can't directly import classes from it.
try :
from urllib.request import Request
myUrl = "http://aima.cs.berkeley.edu/data/iris.csv"
urlRequest = Request(myUrl)
So, as a replacement for mechanize because Visual Studio "needs" python 3.4, and mechanize isn't compatible with 3.4, I found "robobrowser" as a replacement, but I'm having trouble trying to figure out why browser.open returns "AttributeError: 'module' object has no attribute 'open'"
import re
from robobrowser import browser
import time
br = browser
br.open("Website")
br.select_form(name="game-pin-input")
print ("Enter the game pin")
response = br.submit()
time.sleep(3)
Any suggestions, or replacements?
Edit: The Documentation can be found here, and "open" is valid.
https://robobrowser.readthedocs.org/en/latest/api.html#module-robobrowser.browser
I'm guessing browser is a module; according to the docs, you wanted RoboBrowser, and you need to construct an instance before open-ing anything. To roughly match your code:
from robobrowser import RoboBrowser
# Browse to Genius
br = RoboBrowser(history=True) # No idea if history matters
br.open("Website")
I'm guessing robobrowser.browser is some implementation internal module that is importable, but not at all what you wanted.
Update: According to your own docs link, robobrowser.browser is just a module, and RoboBrowser is the class you needed, confirming my earlier statement (RoboBrowser is probably exposed on robobrowser itself for convenience).
I'm playing with examples from Natural Language Processing with Python and this line:
lp = nltk.LogicParser()
produces
AttributeError: 'module' object has no attribute 'LogicParser'
error message. I imported several nltk modules and I can't figure out what is missing. Any clues?
It sounds like you've spotted the problem, but just in case: You are reading the first edition of the NLTK book, but evidently you have installed NLTK 3, which has many changes. Look at the current version of chapter 10 for the correct usage.