I am trying to learn sentiment analysis using vaderSentiment. For some reason, the when I create a query, I am getting the above error. I've checked the documentation, and there is no mention of a Utc attribute being required. Here is the basic code I am using:
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
import twint
analyzer = SentimentIntensityAnalyzer()
c = twint.Config()
c.Search = "Tesla"
c.Store_object = True
c.Since = "2023-01-20"
twint.run.Search(c)
for tweet in twint.output.tweets_list:
print(tweet.tweet)
scores = analyzer.polarity_scores(tweet.tweet)
print(scores)
I've had a great deal of issues trying to get twint to work with my system, so it's highly probable I've not installed it correctly.
Related
import pandas as pd
from ast import literal_eval
from cdqa.utils.filters import filter_paragraphs
from cdqa.utils.download import download_model, download_bnpp_data
from cdqa.pipeline.cdqa_sklearn import QAPipeline
# Download data and models
download_bnpp_data(dir='./data/bnpp_newsroom_v1.1/')
download_model(model='bert-squad_1.1', dir='./models')
# Loading data and filtering / preprocessing the documents
df = pd.read_csv('data/bnpp_newsroom_v1.1/bnpp_newsroom-v1.1.csv', converters={'paragraphs': literal_eval})
df = filter_paragraphs(df)
# Loading QAPipeline with CPU version of BERT Reader pretrained on SQuAD 1.1
cdqa_pipeline = QAPipeline(reader='C:/models/bert_qa.joblib')
# Fitting the retriever to the list of documents in the dataframe
cdqa_pipeline.fit_retriever(X=df)
I was trying to load model but the cdqa_pipeline = QAPipeline(reader='C:/models/bert_qa.joblib') line throws an error saying AttributeError: module 'transformers.modeling_bert' has no attribute 'gelu'
I was using transformers version 3.5
from transformers.activations import gelu
I ended up using a different version. Issue was I had a requirement for this version so I changed other parts of my program too.
I am scraping news feed from a twitter user timeline. I would like to get only the feeds posted in the last 24hours. I am using TwitterSearch library and specifically using TwitterUserOrder to have access to a user timeline. However, I cannot use 'set_until' and get ALL the tweets of the timeline.
'set_until' works for TwitterSearchOrder, and not 'TwitterUserOrder' which is weird.
I get this error :
AttributeError: 'TwitterUserOrder' object has no attribute 'set_until'
Anyone has the same issue ?
import datetime as DT
from TwitterSearch import TwitterUserOrder
today = DT.date.today()
days_ago = today - DT.timedelta(days=1)
tuo = TwitterUserOrder('SnowflakeDB')
tuo.set_include_entities(False)
tuo.set_until(days_ago)
tuo.arguments.update({'tweet_mode':'extended'})
tuo.arguments.update({'truncated': 'False' })`
Beginner in python, pyRevit, and Revit API so my apologies if I'm phrasing my question poorly. Today I used pyRevit to develop a simple pushbutton tool that worked, and then after a few minutes stopped working without anything being changed (that I'm aware of)
My tool adds all groups with excluded elements to the selection. It worked perfectly for a time, then started throwing this error, which I can't make heads or tails of:
Exception: The input argument "document" of function `anonymous-namespace'::FilteredElementCollector_constructor or one item in the collection is null at line 326 of file d:\ship\2018_px64\source\revit\revitdbapi\APIFilteredElementCollectorProxy.cpp. Parameter name: document
The path in the error message isn't one I recognize on my computer. Here's the relevant code (the traceback goes to line 24, which is "groups = FilteredElementCollector...":
from pyrevit import script
from pyrevit.framework import List
from pyrevit.framework import clr
from pyrevit import revit, DB
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
groups = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_IOSModelGroups).WhereElementIsNotElementType().ToElements()
selection = revit.get_selection()
SelectionIds = []
for group in groups:
name = group.Name
if "(members excluded)" in name:
SelectionIds.append(group.Id)
selection.set_to(SelectionIds)
Thanks a lot for any solutions, or even help deciphering the error message.
Im having troubles running the following code:
from google.cloud import bigquery
client = bigquery.Client.from_service_account_json(BQJSONKEY,project = BQPROJECT)
dataset = client.dataset(BQDATASET)
assert not dataset.exists()
The following error pop up:
'DatasetReference' object has no attribute 'exists'
Similarly when i do:
table = dataset.table(BQTABLE)
i get: 'TableReference' object has no attribute 'exists'
However, according to the docs it should work:
https://googlecloudplatform.github.io/google-cloud-python/stable/bigquery/usage.html#datasets
here is my pip freeze (the part with google-cloud):
gapic-google-cloud-datastore-v1==0.15.3
gapic-google-cloud-error-reporting-v1beta1==0.15.3
gapic-google-cloud-logging-v2==0.91.3
gevent==1.2.2
glob2==0.5
gmpy2==2.0.8
google-api-core==0.1.1
google-auth==1.2.1
google-cloud==0.30.0
google-cloud-bigquery==0.28.0
google-cloud-bigtable==0.28.1
google-cloud-core==0.28.0
google-cloud-datastore==1.4.0
google-cloud-dns==0.28.0
google-cloud-error-reporting==0.28.0
google-cloud-firestore==0.28.0
google-cloud-language==1.0.0
google-cloud-logging==1.4.0
google-cloud-monitoring==0.28.0
google-cloud-pubsub==0.29.1
google-cloud-resource-manager==0.28.0
google-cloud-runtimeconfig==0.28.0
google-cloud-spanner==0.29.0
google-cloud-speech==0.30.0
google-cloud-storage==1.6.0
google-cloud-trace==0.16.0
google-cloud-translate==1.3.0
google-cloud-videointelligence==0.28.0
google-cloud-vision==0.28.0
google-gax==0.15.16
google-resumable-media==0.3.1
googleapis-common-protos==1.5.3
I wonder how can i fix it and make it work?
Not sure how you got to this docs but you should be using these as reference:
https://googlecloudplatform.github.io/google-cloud-python/latest/bigquery/usage.html#datasets
Code for 0.28 would be something like:
dataset_refence = client.dataset(BQDATASET)
dataset = client.get_dataset(dataset_reference)
assert dataset.created is not None
I think you forgot to create the dataset before calling exists()
dataset = client.dataset(BQDATASET)
dataset.create()
assert not dataset.exists()
I am trying to use the Python wrapper for TreeTagger, a Part-of-Speech Tagger. The code I use for importing and invoking the wrapper is:
import TreeTaggerWrapper
tagger = TreeTaggerWrapper.TreeTagger(TAGLANG='en',TAGDIR='D:/Programme/TreeTagger')
tags = tagger.TagText("This is a very short text to tag.")
print tags
the error is: 'AttributeError: 'module' object has no attribute 'TreeTagger''
The init.py exists in the TreeTaggerWrapper directory and is empty.
How would I go about systematically resolving the issue?
Try this wrapper:
http://cental.fltr.ucl.ac.be/team/~panchenko/def/treetaggerwrapper.py
There is documentation inside the file.
Update
Copy the file treetaggerwrapper.py to python/Lib.
Try this:
import treetaggerwrapper
tagger = treetaggerwrapper.TreeTagger(TAGLANG='en',TAGDIR='D:/Programme/TreeTagger')
tags = tagger.TagText("This is a very short text to tag.")
print tags
Update 2
If you have Lib/site-packages/TreeTaggerWrapper/treetaggerwrapper.py, then you should do this:
from TreeTaggerWrapper import treetaggerwrapper
tagger = treetaggerwrapper.TreeTagger(TAGLANG='en',TAGDIR='D:/Programme/TreeTagger')
tags = tagger.TagText("This is a very short text to tag.")
print tags