joknopp / text2ldac Goto Github PK
View Code? Open in Web Editor NEWpython command line tool that takes a directory containing .txt files as input and generates three output files that can be used by the ldac or hlda implementations by David Blei
python command line tool that takes a directory containing .txt files as input and generates three output files that can be used by the ldac or hlda implementations by David Blei
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.