Skip to content

Commit

Permalink
fix(data-computer): add seed for lda. fixed stopwords and parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
leogail committed Nov 29, 2024
1 parent 94ce96d commit 05b5f5e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
2 changes: 1 addition & 1 deletion services/data-computer/v1/lda.ini
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ logger = logger.cfg
# command should be executable !
command = ./v1/lda.py
args = fix('-p')
args = env('nbTopic',15)
args = env('nbTopic',6)

# Step 2.2 (générique): Enregister le résulat et signaler que le traitment est fini
[fork/delegate]
Expand Down
25 changes: 8 additions & 17 deletions services/data-computer/v1/lda.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
job_name='lda'


# Get the index of "p" param (given by the user) and assign it to "nbTopic". 15 if not found
nbTopic = sys.argv[sys.argv.index('-p') + 1] if '-p' in sys.argv else 15
# Get the index of "p" param (given by the user) and assign it to "nbTopic". 6 if not found
nbTopic = sys.argv[sys.argv.index('-p') + 1] if '-p' in sys.argv else 6

nlp = spacy.load('en_core_web_sm', disable = ['parser','ner'])

Expand Down Expand Up @@ -84,9 +84,7 @@ def max_topic(dico):
# following parameters depends of the size of the corpus : num_topics and num_iterations
len_data = len(all_data)
num_iterations= 500
if len_data < 500:
num_iterations = 200
minimum_probabilty = 1/nbTopic
minimum_probabilty = 1/float(nbTopic)
# training LDA
texts = []
index_without_value = []
Expand All @@ -112,13 +110,15 @@ def max_topic(dico):
lda_model = models.LdaModel(corpus,
num_topics=nbTopic,
id2word=dictionary,
alpha="asymetric",
eta = "auto",
alpha="auto",
eta="auto",
minimum_probability=minimum_probabilty,
passes=10,
iterations=num_iterations)
iterations=num_iterations,
random_state=42)

except Exception as e :
sys.stderr.write(str(e))
index_without_value = [i for i in range(len_data)]


Expand Down Expand Up @@ -157,12 +157,3 @@ def max_topic(dico):
line["value"]["best_topic"]="n/a"
sys.stdout.write(json.dumps(line))
sys.stdout.write("\n")


# #To see topics (to test it with a jsonl file)
# sys.stdout.write(json.dumps(lda_model.print_topics()))

# #Get coherence
# cm = models.coherencemodel.CoherenceModel(model=lda_model, texts=texts, coherence='c_v')
# cm.get_coherence()
# exit()
2 changes: 1 addition & 1 deletion services/data-computer/v1/stopwords/en.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["able", "about", "above", "abroad", "abstract", "according", "accordingly", "across", "actually", "adj", "after", "afterwards", "again", "against", "ago", "ahead", "ain", "all", "allow", "allows", "almost", "alone", "along", "alongside", "already", "also", "although", "always", "amid", "amidst", "among", "amongst", "and", "another", "any", "anybody", "anyhow", "anyone", "anything", "anyway", "anyways", "anywhere", "apart", "appear", "appreciate", "appropriate", "are", "aren", "around", "aside", "ask", "asking", "associated", "available", "away", "awfully", "back", "backward", "backwards", "became", "because", "become", "becomes", "becoming", "been", "before", "beforehand", "begin", "behind", "being", "believe", "below", "beside", "besides", "best", "better", "between", "beyond", "both", "brief", "but", "came", "can", "cannot", "cant", "caption", "cause", "causes", "certain", "certainly", "changes", "clearly", "co", "com", "come", "comes", "concerning", "consequently", "consider", "considering", "contain", "containing", "contains", "corresponding", "could", "couldn", "course", "currently", "dare", "daren", "definitely", "described", "despite", "did", "didn", "different", "directly", "does", "doesn", "doing", "done", "don", "down", "downwards", "during", "each", "edu", "eight", "eighty", "either", "else", "elsewhere", "end", "ending", "enough", "entirely", "especially", "etc", "even", "ever", "evermore", "every", "everybody", "everyone", "everything", "everywhere", "exactly", "example", "except", "fairly", "far", "farther", "few", "fewer", "fifth", "first", "five", "followed", "following", "follows", "for", "forever", "former", "formerly", "forth", "forward", "found", "four", "from", "further", "furthermore", "get", "gets", "getting", "given", "gives", "goes", "going", "gone", "got", "gotten", "greetings", "had", "hadn", "half", "happens", "hardly", "has", "hasn", "have", "haven", "having", "hello", "help", "hence", "her", "here", "hereafter", "hereby", "herein", "hereupon", "hers", "herself", "him", "himself", "his", "hither", "hopefully", "how", "howbeit", "however", "hundred", "ignored", "immediate", "inasmuch", "inc", "inc", "indeed", "indicate", "indicated", "indicates", "inner", "inside", "insofar", "instead", "into", "inward", "isn", "its", "itself", "just", "keep", "keeps", "kept", "know", "known", "knows", "last", "lately", "later", "latter", "latterly", "least", "less", "lest", "let", "like", "liked", "likely", "likewise", "little", "look", "looking", "looks", "low", "lower", "ltd", "made", "mainly", "make", "makes", "many", "may", "maybe", "mayn", "mean", "meantime", "meanwhile", "merely", "might", "mightn", "mine", "minus", "miss", "more", "moreover", "most", "mostly", "mrs", "much", "must", "mustn", "myself", "name", "namely", "near", "nearly", "necessary", "need", "needn", "needs", "neither", "never", "neverf", "neverless", "nevertheless", "new", "next", "nine", "ninety", "nobody", "non", "none", "nonetheless", "noone", "noone", "nor", "normally", "not", "nothing", "notwithstanding", "novel", "now", "nowhere", "obviously", "off", "often", "okay", "old", "once", "one", "ones", "only", "onto", "opposite", "other", "others", "otherwise", "ought", "oughtn", "our", "ours", "ourselves", "out", "outside", "over", "overall", "own", "particular", "particularly", "past", "per", "perhaps", "placed", "please", "plus", "possible", "presumably", "probably", "provided", "provides", "que", "quite", "rather", "really", "reasonably", "recent", "recently", "regarding", "regardless", "regards", "relatively", "respectively", "right", "round", "said", "same", "saw", "say", "saying", "says", "second", "secondly", "see", "seeing", "seem", "seemed", "seeming", "seems", "seen", "self", "selves", "sensible", "sent", "serious", "seriously", "seven", "several", "shall", "shan", "she", "should", "shouldn", "since", "six", "some", "somebody", "someday", "somehow", "someone", "something", "sometime", "sometimes", "somewhat", "somewhere", "soon", "sorry", "specified", "specify", "specifying", "still", "sub", "such", "sup", "sure", "take", "taken", "taking", "tell", "tends", "than", "thank", "thanks", "thanx", "that", "thats", "the", "their", "theirs", "them", "themselves", "then", "thence", "there", "thereafter", "thereby", "therefore", "therein", "theres", "thereupon", "these", "they", "thing", "things", "think", "third", "thirty", "this", "thorough", "thoroughly", "those", "though", "three", "through", "throughout", "thru", "thus", "till", "together", "too", "took", "toward", "towards", "tried", "tries", "truly", "try", "trying", "twice", "two", "under", "underneath", "undoing", "unfortunately", "unless", "unlike", "unlikely", "until", "unto", "upon", "upwards", "use", "used", "useful", "uses", "using", "usually", "value", "various", "versus", "very", "via", "viz", "want", "wants", "was", "wasn", "way", "welcome", "well", "went", "were", "weren", "what", "whatever", "when", "whence", "whenever", "where", "whereafter", "whereas", "whereby", "wherein", "whereupon", "wherever", "whether", "which", "whichever", "while", "whilst", "whither", "who", "whoever", "whole", "whom", "whomever", "whose", "why", "will", "willing", "wish", "with", "within", "without", "wonder", "won", "would", "wouldn", "yes", "yet", "you", "your", "yours", "yourself", "yourselves", "zero", "uucp", "www", "amount", "bill", "bottom", "call", "computer", "con", "couldnt", "cry", "describe", "detail", "due", "eleven", "empty", "fifteen", "fifty", "fill", "find", "fire", "forty", "front", "full", "give", "hasnt", "herse", "himse", "interest", "itse\u201d", "mill", "move", "myse\u201d", "part", "put", "show", "side", "sincere", "sixty", "system", "ten", "thick", "thin", "top", "twelve", "twenty", "abst", "accordance", "act", "added", "adopted", "affected", "affecting", "affects", "announce", "anymore", "apparently", "approximately", "arent", "arise", "auth", "beginning", "beginnings", "begins", "biol", "briefly", "date", "effect", "etal", "fix", "gave", "giving", "heres", "hes", "hid", "home", "immediately", "importance", "important", "index", "information", "itd", "keys", "largely", "lets", "line", "means", "million", "mug", "nay", "necessarily", "nos", "noted", "obtain", "obtained", "omitted", "ord", "owing", "page", "pages", "poorly", "possibly", "potentially", "predominantly", "present", "previously", "primarily", "promptly", "proud", "quickly", "ran", "readily", "ref", "refs", "related", "research", "resulted", "resulting", "results", "run", "sec", "section", "shed", "shes", "showed", "shown", "showns", "shows", "significant", "significantly", "similar", "similarly", "slightly", "somethan", "specifically", "state", "states", "stop", "strongly", "substantially", "successfully", "sufficiently", "suggest", "thered", "thereof", "therere", "thereto", "theyd", "theyre", "thou", "thoughh", "thousand", "throug", "til", "tip", "ups", "usefully", "usefulness", "vol", "vols", "wed", "whats", "wheres", "whim", "whod", "whos", "widely", "words", "world", "youd", "youre", "article", "study"]
["able", "about", "above", "abroad", "abstract", "according", "accordingly", "across", "actually", "adj", "after", "afterwards", "again", "against", "ago", "ahead", "ain", "all", "allow", "allows", "almost", "alone", "along", "alongside", "already", "also", "although", "always", "amid", "amidst", "among", "amongst", "and", "another", "any", "anybody", "anyhow", "anyone", "anything", "anyway", "anyways", "anywhere", "apart", "appear", "appropriate", "are", "aren", "around", "aside", "ask", "asking", "associated", "available", "away", "awfully", "back", "backward", "backwards", "became", "because", "become", "becomes", "becoming", "been", "before", "beforehand", "begin", "behind", "being", "below", "beside", "besides", "best", "better", "between", "beyond", "both", "brief", "but", "came", "can", "cannot", "cant", "caption", "cause", "causes", "certain", "certainly", "changes", "clearly", "co", "com", "come", "comes", "concerning", "consequently", "consider", "considering", "contain", "containing", "contains", "corresponding", "could", "couldn", "course", "currently", "dare", "daren", "definitely", "described", "despite", "did", "didn", "different", "directly", "does", "doesn", "doing", "done", "don", "down", "downwards", "during", "each", "edu", "eight", "eighty", "either", "else", "elsewhere", "end", "ending", "enough", "entirely", "especially", "etc", "even", "ever", "evermore", "every", "everybody", "everyone", "everything", "everywhere", "exactly", "example", "except", "fairly", "far", "farther", "few", "fewer", "fifth", "first", "five", "followed", "following", "follows", "for", "forever", "former", "formerly", "forth", "forward", "found", "four", "from", "further", "furthermore", "get", "gets", "getting", "given", "gives", "goes", "going", "gone", "got", "gotten", "greetings", "had", "hadn", "half", "happens", "hardly", "has", "hasn", "have", "haven", "having", "hello", "help", "hence", "her", "here", "hereafter", "hereby", "herein", "hereupon", "hers", "herself", "him", "himself", "his", "hither", "hopefully", "how", "howbeit", "however", "hundred", "ignored", "immediate", "inasmuch", "inc", "inc", "indeed", "indicate", "indicated", "indicates", "inner", "inside", "insofar", "instead", "into", "inward", "isn", "its", "itself", "just", "keep", "keeps", "kept", "know", "known", "knows", "last", "lately", "later", "latter", "latterly", "least", "less", "lest", "let", "like", "liked", "likely", "likewise", "little", "look", "looking", "looks", "low", "lower", "ltd", "made", "mainly", "make", "makes", "many", "may", "maybe", "mayn", "mean", "meantime", "meanwhile", "merely", "might", "mightn", "mine", "minus", "miss", "more", "moreover", "most", "mostly", "mrs", "much", "must", "mustn", "myself", "name", "namely", "near", "nearly", "necessary", "need", "needn", "needs", "neither", "never", "neverf", "neverless", "nevertheless", "new", "next", "nine", "ninety", "nobody", "non", "none", "nonetheless", "noone", "noone", "nor", "normally", "not", "nothing", "notwithstanding", "novel", "now", "nowhere", "obviously", "off", "often", "okay", "old", "once", "one", "ones", "only", "onto", "opposite", "other", "others", "otherwise", "ought", "oughtn", "our", "ours", "ourselves", "out", "outside", "over", "overall", "own", "particular", "particularly", "past", "per", "perhaps", "placed", "please", "plus", "possible", "presumably", "probably", "provided", "provides", "que", "quite", "rather", "really", "reasonably", "recent", "recently", "regarding", "regardless", "regards", "relatively", "respectively", "right", "round", "said", "same", "saw", "say", "saying", "says", "second", "secondly", "see", "seeing", "seem", "seemed", "seeming", "seems", "seen", "self", "selves", "sensible", "sent", "serious", "seriously", "seven", "several", "shall", "shan", "she", "should", "shouldn", "since", "six", "some", "somebody", "someday", "somehow", "someone", "something", "sometime", "sometimes", "somewhat", "somewhere", "soon", "sorry", "specified", "specify", "specifying", "still", "sub", "such", "sup", "sure", "take", "taken", "taking", "tell", "tends", "than", "thank", "thanks", "thanx", "that", "thats", "the", "their", "theirs", "them", "themselves", "then", "thence", "there", "thereafter", "thereby", "therefore", "therein", "theres", "thereupon", "these", "they", "thing", "things", "think", "third", "thirty", "this", "thorough", "thoroughly", "those", "though", "three", "through", "throughout", "thru", "thus", "till", "together", "too", "took", "toward", "towards", "tried", "tries", "truly", "try", "trying", "twice", "two", "under", "underneath", "undoing", "unfortunately", "unless", "unlike", "unlikely", "until", "unto", "upon", "upwards", "use", "used", "useful", "uses", "using", "usually", "value", "various", "versus", "very", "via", "viz", "want", "wants", "was", "wasn", "way", "welcome", "well", "went", "were", "weren", "what", "whatever", "when", "whence", "whenever", "where", "whereafter", "whereas", "whereby", "wherein", "whereupon", "wherever", "whether", "which", "whichever", "while", "whilst", "whither", "who", "whoever", "whole", "whom", "whomever", "whose", "why", "will", "willing", "wish", "with", "within", "without", "wonder", "won", "would", "wouldn", "yes", "yet", "you", "your", "yours", "yourself", "yourselves", "zero", "uucp", "www", "amount", "bill", "bottom", "call", "con", "couldnt", "cry", "describe", "detail", "due", "eleven", "fifteen", "fifty", "fill", "find", "forty", "front", "full", "give", "hasnt", "herse", "himse", "interest", "itse\u201d", "mill", "move", "myse\u201d", "part", "put", "show", "side", "sincere", "sixty", "system", "ten", "thick", "thin", "top", "twelve", "twenty", "abst", "accordance", "act", "added", "adopted", "affected", "affecting", "affects", "announce", "anymore", "apparently", "approximately", "arent", "arise", "auth", "beginning", "beginnings", "begins", "biol", "briefly", "date", "effect", "etal", "fix", "gave", "giving", "heres", "hes", "hid", "home", "immediately", "importance", "important", "index", "information", "itd", "keys", "largely", "lets", "line", "means", "million", "mug", "nay", "necessarily", "nos", "noted", "obtain", "obtained", "omitted", "ord", "owing", "page", "pages", "poorly", "possibly", "potentially", "predominantly", "present", "previously", "primarily", "promptly", "proud", "quickly", "ran", "readily", "ref", "refs", "related", "research", "resulted", "resulting", "results", "run", "sec", "section", "shed", "shes", "showed", "shown", "showns", "shows", "significant", "significantly", "similar", "similarly", "slightly", "somethan", "specifically", "state", "states", "stop", "strongly", "substantially", "successfully", "sufficiently", "suggest", "thered", "thereof", "therere", "thereto", "theyd", "theyre", "thou", "thoughh", "thousand", "throug", "til", "tip", "ups", "usefully", "usefulness", "vol", "vols", "wed", "whats", "wheres", "whim", "whod", "whos", "widely", "words", "world", "youd", "youre", "article", "study", "studies", "result"]

0 comments on commit 05b5f5e

Please sign in to comment.