Skip to content

Commit

Permalink
Added injection of profile data to profile page. Added textSentimentA…
Browse files Browse the repository at this point in the history
…nalyzer function to tweetSentiment
  • Loading branch information
TheJacobSales committed Nov 24, 2021
1 parent 2e4910e commit f337713
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 8 deletions.
39 changes: 34 additions & 5 deletions application.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,29 @@ def register():

if existing_user is None:
hashpass = bcrypt.hashpw(request.form['password'].encode('utf-8'), bcrypt.gensalt())
users.insert_one({'date': str(date.today()),'name': request.form['username'], 'password':hashpass, 'email': request.form['email'], 'phonenumber': request.form['phonenumber'], 'labor':request.form['keywords']})
profile = {
"displayName": request.form['username'],
"labors": request.form['keywords'],
"location": "Fresno",
"imgLink": "",
"userBio": "Default Bio"
}
projects = [{
"projectName": "Estate Garden",
"projectDescription": " gabba gabbe",
"photoLink1": "../static/Images/testDataImages/projectImg1.jpg",
"photoLink2": "../static/Images/testDataImages/projectImg2.jpg",
"photoLink3": "../static/Images/testDataImages/projectImg3.jpg",
"photoLink4": "../static/Images/testDataImages/projectImg4.jpg"
}]
reviews = [{
"reviewerName": "Angry Guy",
"reviewScore": "4",
"reviewText": "yaddayadda",
"??sentimentAnalysis": "Positive Review"
}]

users.insert_one({'date': str(date.today()),'name': request.form['username'], 'password':hashpass, 'email': request.form['email'], 'phonenumber': request.form['phonenumber'], 'labor':request.form['keywords'], 'profile':profile, 'projects':projects, 'reviews':reviews})
#session['username'] = request.form['username']
return redirect(url_for('landingPage'))

Expand Down Expand Up @@ -84,7 +106,6 @@ def login():
user_pass = login_user['password']
login_pass = request.form.get('password')


# Method 1
if bcrypt.checkpw(login_pass.encode('utf-8'), user_pass):
login_email = login_user['email']
Expand Down Expand Up @@ -121,9 +142,17 @@ def user(usr):
def profile():
if not g.user:
return redirect(url_for('login'))
return render_template("profile.html")

return render_template("profile.html", profileResult=profileResult )
else:
existing_user = g.user
profile = existing_user.get('profile', 'User labors is Empty.')
projects = existing_user.get('projects', 'User projects is Empty.')
reviews = existing_user.get('reviews', 'User reviews is Empty.')
profileResult = {
"profile": profile,
"projects": projects,
"reviews": reviews
}
return render_template("profile.html", profileResult=profileResult )

@application.route("/profileEdit/", methods = ["POST", "GET"])
def profileEdit():
Expand Down
41 changes: 41 additions & 0 deletions defaultProfile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"profile": {
"displayName": "Joe Swanson ",
"labors": ["Gardener"],
"location": "Fresno",
"imgLink": "",
"userBio": "blah blah i work hard"

},
"projects": [{
"projectName": "Estate Garden",
"projectDescription": " gabba gabbe",
"photoLink1": "../static/Images/testDataImages/projectImg1.jpg",
"photoLink2": "../static/Images/testDataImages/projectImg2.jpg",
"photoLink3": "../static/Images/testDataImages/projectImg3.jpg",
"photoLink4": "../static/Images/testDataImages/projectImg4.jpg"
},
{
"projectName": "Estate Garden",
"projectDescription": " gabba gabbe",
"photoLink1": "../static/Images/testDataImages/projectImg1.jpg",
"photoLink2": "../static/Images/testDataImages/projectImg2.jpg",
"photoLink3": "../static/Images/testDataImages/projectImg3.jpg",
"photoLink4": "../static/Images/testDataImages/projectImg4.jpg"
},
{
"projectName": "Estate Garden",
"projectDescription": " gabba gabbe",
"photoLink1": "../static/Images/testDataImages/projectImg1.jpg",
"photoLink2": "../static/Images/testDataImages/projectImg2.jpg",
"photoLink3": "../static/Images/testDataImages/projectImg3.jpg",
"photoLink4": "../static/Images/testDataImages/projectImg4.jpg"
}
],
"reviews": [{
"reviewerName": "Angry Guy",
"reviewScore": "4",
"reviewText": "yaddayadda",
"sentimentAnalysis": "Positive Review"
}]
}
Binary file added static/profilePic/cowboy_bebop_ein_corgi.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/projectPic/cowboy_bebop_ein_corgi.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions templates/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ <h3></h3>
<img src = "" alt = "photo1" class = "projectPhoto">
<img src = "" alt = "photo2" class = "projectPhoto">
<div id = "projectDescription">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolor repellendus accusamus atque blanditiis voluptate rerum illo.
Ratione at veritatis ab animi? Sunt consequuntur provident, ea tempore nesciunt fugiat esse deserunt?</p>
<p>{{profileResult['profile']['displayName']}}</p>
</div>
</div>
</article>
Expand Down
38 changes: 37 additions & 1 deletion tweetSentiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,40 @@ def tweetSentimentAnalyzer(userName, totalTweets):
negativeTweetsTot = predictionList.count('0')
print(f"Number of Positive tweets: {possitiveTweetsTot}")
print(f"Number of Negative tweets: {negativeTweetsTot}")
return {"tweet_postive": possitiveTweetsTot, "tweet_negative": negativeTweetsTot}, scrapeSuccess
return {"tweet_postive": possitiveTweetsTot, "tweet_negative": negativeTweetsTot}, scrapeSuccess

def textSentimentAnalyzer(text):
with open("vectorizer.pickle", "rb") as pickle_in:
processedVector = pickle.load(pickle_in)

with open("LogisticRegClass.pickle", "rb") as pickle_in:
logicRegClass = pickle.load(pickle_in)

sentence = text
testProcessed = []
# Remove all the special characters
processed_feature = re.sub(r'\W', ' ', sentence)

# remove all single characters
processed_feature= re.sub(r'\s+[a-zA-Z]\s+', ' ', processed_feature)

# Remove single characters from the start
processed_feature = re.sub(r'\^[a-zA-Z]\s+', ' ', processed_feature)

# Substituting multiple spaces with single space
processed_feature = re.sub(r'\s+', ' ', processed_feature, flags=re.I)

# Removing prefixed 'b'
processed_feature = re.sub(r'^b\s+', '', processed_feature)

# Converting to Lowercase
processed_feature = processed_feature.lower()

testProcessed.append(processed_feature)
processed_features = processedVector.transform(testProcessed).toarray()
prediction = logicRegClass.predict(processed_features)
if prediction[0] == '4':
isPositive = True
else:
isPositive = False
return isPositive

0 comments on commit f337713

Please sign in to comment.