Skip to main content

Social Content Analysis

Project description

Social Content Parser

A toolkit to parse and analyze contents from social media.

Intro

Example 1: Parse Weibo text

from social_content import *
# remove topic tags, links and emoji
text="#1000公里续航新能源车能出吗#  中科院院士欧阳明高表示,如果有人告诉你,这个车能跑1000公里,几分钟能充满电,还很安全,成本又很低。以目前的技术来讲,他一定是骗子!中科院院士的这番言论似乎有所指。蔚来ET7前脚宣布1000公里续航,广汽埃安这几天就向外界公布了全新动力电池科技海报。这几天, ​  展开c"
content=get_plain_text(text)
print(content)

Example 2: Evaluate Weibo comment text with emoji

from social_content.weibo import *
'''
    Evaluate sentiment scores based on Weibo user's emoji list
'''
# 1. Chinese comment text
comment="那不也是新能源?如果真想要新能源指标,至于摇号那么久么[中国赞]"
# clean text
comment_cleaned=clean_weibo_text(comment)

# 2. load a list of all possible emojis
happy_emoji,neutral_emoji,sad_emoji=create_emoji_list()

# 3. extract an emoji list in the comment text
list_comment_emoji=extract_emoji(comment)
print("Emoji list:",list_comment_emoji)

# 4. evaluate emoji sentiment based on emoji dictionary and
happy,sad,neutral=sentiment_emoji(happy_emoji,neutral_emoji,sad_emoji,list_comment_emoji)
print(f"Sentiment preference:{happy}\t{sad}\t{neutral}")

# 5. evaluate a combined sentiment, two types of sentiment
avg_sentiment_real,avg_sentiment_grade = get_avg_sentiment_with_all(text=comment_cleaned,list_emoji=list_comment_emoji)
print("Average sentiment by continual value:",avg_sentiment_real)
print("Average sentiment by discrete value: ",avg_sentiment_grade)

Example 3: Clean twitter text

from social_content.twitter import *
text='''
#CatBoy called #SafeCatGirl !
https://t.co/CZgF6SJ2RQ
https://t.co/pay2uVyvxL
https://t.co/WeUom7jtEr
#BSCGems #BSCGem #NFT #NFTs #GameFi #ElonMusk #altcoins #bitcoin  
#crypto #ethereum #btc #altcoin #Binance #ripple 
#ETH #shiba #MXS #BNB #dogecoin #Metaverse #BSC #DeFi https://t.co/CHhdHVBuDe https://t.co/fMhOYH1rlO
'''
text=remove_hashtag_mention(text)
text=remove_urls(text)
print(text.strip())

License

The social-content toolkit is provided by Donghua Chen with MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

social-content-0.0.1a0.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

social_content-0.0.1a0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file social-content-0.0.1a0.tar.gz.

File metadata

  • Download URL: social-content-0.0.1a0.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.11

File hashes

Hashes for social-content-0.0.1a0.tar.gz
Algorithm Hash digest
SHA256 8dbcaa28ad83e4ce0389bf996740b80c5ead9c850fb0d1fa74cb4192d2b380c7
MD5 89d3d45e6ccd43817fecb7c6cae9d40f
BLAKE2b-256 61c0e938286b968dd3b77d68bca221f1c78d4986cd81359d7f9b6d0dc43343d7

See more details on using hashes here.

File details

Details for the file social_content-0.0.1a0-py3-none-any.whl.

File metadata

  • Download URL: social_content-0.0.1a0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.11

File hashes

Hashes for social_content-0.0.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 1790557a711f9b89203f64a411919b0f2d22645dfaca4f119f339b0e2093a49c
MD5 599a8b6f823bc335c1a42b75c6df97e4
BLAKE2b-256 c0f1ce36ef72f6dc46f6dde7654160ee98fe502893cdc1947838e16374b426dc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page