Sto usando nltk
per generare n-grammi dalle frasi rimuovendo prima le parole di stop date. Tuttavia, nltk.pos_tag()
è estremamente lento e richiede fino a 0,6 secondi sulla mia CPU (Intel i7).POS-Tagger è incredibilmente lento
L'output:
['The first time I went, and was completely taken by the live jazz band and atmosphere, I ordered the Lobster Cobb Salad.']
0.620481014252
["It's simply the best meal in NYC."]
0.640982151031
['You cannot go wrong at the Red Eye Grill.']
0.644664049149
Il codice:
for sentence in source:
nltk_ngrams = None
if stop_words is not None:
start = time.time()
sentence_pos = nltk.pos_tag(word_tokenize(sentence))
print time.time() - start
filtered_words = [word for (word, pos) in sentence_pos if pos not in stop_words]
else:
filtered_words = ngrams(sentence.split(), n)
è davvero questo che rallentano o sto facendo qualcosa di sbagliato qui?
puoi pubblicare il testo che hai inserito? Qual è la specifica della tua macchina (velocità della CPU e RAM)? Ti stai connettendo a una nuvola e come stai cronometrando la funzione? Vedi anche http://stackoverflow.com/questions/33558836/pos-tagging-using-nltk-takes-time – alvas
@alvas È un Intel i7 (indicato nella domanda). 16 GB di RAM. No, non è nel cloud è locale. Puoi vedere nel mio esempio di codice come lo faccio ora. – displayname
È necessario parallelizzare la soluzione se si dispone di un set di dati enorme. Altrimenti (se puoi tenere le frasi taggate nella RAM), raccogli semplicemente tutte le frasi taggate e poi fai il filtro. – alvas