Skip to content

SentiWS

The module SentiWS contains objects to work with the SentiWS dataset for sentiment analysis1.

A short example of its usage:

    sentiment = Sentiment("SentiWS_v1.8c_Positive.txt", "SentiWS_v1.8c_Negative.txt")
    print("Size positive:", len(sentiment.positiv))
    print("Size negativ:", len(sentiment.negativ))

    word = " "
    while word != "":
        word = input("Enter a word: ")
        if word in sentiment.positiv:
            print("Positiv: ", sentiment.positiv[word].toString())
        elif word in sentiment.negativ:
            print("Negativ: ", sentiment.negativ[word].toString())
        else:
            print("Word not found.")
        print("--------------------------")

    print("Good bye.")

Sentiment

Methods:

  • init: gets two parameter, the first one is the path to the positive annotated words (for example, "SentiWS_v1.8c_Positive.txt"), the second one is the path to the negative annotated ones ("SentiWS_v1.8c_Negative.txt")
  • readFile: private method to read the files from above
  • df: returns the senmtiment datas as Panda datframe

Properties:

  • positiv: a dictionary with all positive words and its value
  • negativ: a dictionary with all negative words and its value

Word

Methods:

  • toString: String representation of the word

Properties:

  • lemma: the lemma of a word
  • pos: the part of speech tagging of the word
  • value: the sentiment value of the word
  • variants: are there variants of the word

  1. R. Remus, U. Quasthoff & G. Heyer: SentiWS - a Publicly Available German-language Resource for Sentiment Analysis. In: Proceedings of the 7th International Language Resources and Evaluation (LREC'10), pp. 1168-1171, 2010