Giter VIP home page Giter VIP logo

text2ldac's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

text2ldac's Issues

Small problems about re-indexing word_index after remove stopword or infrequent words from word_id_dict

Nice code, only a small problem. After remove stopword or infrequent words from word_id_dict, the code didn't re-index the index for words so that the max index of the word matches/reflects the total number of unique words in word dict. I updated the following corresponding code in function:
generate_dat_lines_and_word_ids(fnames, config)

to fix the problem.

    remove_word_min_index = len( word_id_dict )  # record the min index of the remove word in order to change the corresponding index for word in word_id_dict      
    for word in remove_list:
        freq_dict.pop(word)
        #if they are new also remove them from word_id_dict
        if word in new_words:

            word_index = word_id_dict[ word ]
            if word_index < remove_word_min_index:
                remove_word_min_index = word_index

            word_id_dict.pop(word)

    num_word_shifts = 0
    for word in word_id_dict: # re-index the word_id for word_id pairs to guarantee that the max index of the word matches/reflects #words in word dict
        cur_index = word_id_dict[word]

        if cur_index > remove_word_min_index:                
            word_id_dict[word] = remove_word_min_index + num_word_shifts
            num_word_shifts += 1

Hope this helpful for future users who use the software to generate a matrix of word frequencies in the ldac format for dtm (dynamic topic model) software from this Link:
http://www.jgoodwin.net/?p=1043

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.