Skip to main content

Functions for calculation of the lexicon overlap score

Project description

Lexicon overlap score

The lexicon overlap score is a similarity measure for sentiment lexicons as they are used in Sentiment Classification.

Installation

Install via pip install lexicon_overlap_score

Usage

Import via import lexicon_overlap_score as los

Your lexicons should be a pandas dataframe with the columns word and so (semantic orientation). Then the following three functions can be used.

los.simple(lex1, lex2)
los.binary(lex1, lex2)
los.score(lex1, lex2)

simple and binary return a value between 0 and 1, while score returns values between -1 and 1. The functions expect positive words to have a positive value and negative words to have a negative value.

If your lexicon is a python dictionary mapping words to values, convert it to a pandas dataframe.

import pandas as pd
df_lex = pd.DataFrame().from_dict(dict_lex, orient="index").reset_index().rename(columns={"index": "word", 0: "so"})

Example

import pandas as pd
import lexicon_overlap_score as los
df1 = pd.DataFrame([("test",   1), ("free",    1), ("other", 1), ("check", 0.5)], columns=["word", "so"])
df2 = pd.DataFrame([("test", 0.5), ("free",    1)],                               columns=["word", "so"])
los.simple(df1, df2), los.binary(df1, df2), los.score(df1, df2)

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

lexicon_overlap_score-0.0.1.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lexicon_overlap_score-0.0.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file lexicon_overlap_score-0.0.1.tar.gz.

File metadata

  • Download URL: lexicon_overlap_score-0.0.1.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for lexicon_overlap_score-0.0.1.tar.gz
Algorithm Hash digest
SHA256 3b681b532f1dcbe58314562bac9a2ea1408dac9cd63c4141122fc0dd4a0f9168
MD5 c7daba91c0e736cd68c0e77d589d2d94
BLAKE2b-256 378a7ed33a5877afa3b6fd8949f6ee00216e8513b42e9519ee0ccb2eb947e0e5

See more details on using hashes here.

File details

Details for the file lexicon_overlap_score-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: lexicon_overlap_score-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for lexicon_overlap_score-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 543ecb2572df3ddea57ceaa0d16572b5b422a586173e9eebbbf1e7e5446dd37d
MD5 7f6eaaef9710d832d1e9219b82f681b4
BLAKE2b-256 2fa66e1e021f65057ef8e91e5443f4a5c9c4bf8f1ca4546a65ef2ddcd66ae00d

See more details on using hashes here.

Supported by

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