chbrown / liwc-python

Linguistic Inquiry and Word Count (LIWC) analyzer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No update code in PyPI

mengyingzhou opened this issue · comments

Hi

Thank you for your continued commitment to this project! But it seems to be no 'really' update in PyPI.

I downloaded the source code from this URL: https://files.pythonhosted.org/packages/4a/b3/d46aec19508d29e8f2c71c8d87d3878a2249abf01cb6d727e442e67b2d74/liwc-0.4.2.tar.gz

And found that the read_dic function does not consist of the Github repo code.

The code in the downloaded file is the following:

def read_dic(filepath):
    """
    Reads a LIWC lexicon from a file in the .dic format, returning a tuple of
    (lexicon, category_names), where:
    * `lexicon` is a dict mapping string patterns to lists of category names
    * `categories` is a list of category names (as strings)

    """
    # category_mapping is a mapping from integer string to category name
    category_mapping = {}
    # category_names is equivalent to category_mapping.values() but retains original ordering
    category_names = []
    lexicon = {}
    # the mode is incremented by each '%' line in the file
    mode = 0
    for line in open(filepath):
        tsv = line.strip()
        if tsv:
            parts = tsv.split()
            if parts[0] == "%":
                mode += 1
            elif mode == 1:
                # definining categories
                category_names.append(parts[1])
                category_mapping[parts[0]] = parts[1]
            elif mode == 2:
                lexicon[parts[0]] = [
                    category_mapping[category_id] for category_id in parts[1:]
                ]
    return lexicon, category_names

thank you! Best Regards!

mengying

Yeah those recent changes are still kinda WIP. Can you see how/if things work after installing from source? E.g.:

pip install git+https://github.com/chbrown/liwc-python.git

Also w.r.t. the 2015 dic mentioned in #6

Great!

I think it works! ;)

thank you very much!!!