{"action":"opened","issue":{"url":"https://api.github.com/repos/RaRe-Technologies/gensim/issues/1466","repository_url":"https://api.github.com/repos/RaRe-Technologies/gensim","labels_url":"https://api.github.com/repos/RaRe-Technologies/gensim/issues/1466/labels{/name}","comments_url":"https://api.github.com/repos/RaRe-Technologies/gensim/issues/1466/comments","events_url":"https://api.github.com/repos/RaRe-Technologies/gensim/issues/1466/events","html_url":"https://github.com/RaRe-Technologies/gensim/issues/1466","id":240754694,"number":1466,"title":"Impossible to roll up phrases of more than 2 words while lowering the threshold","user":{"login":"michaelwsherman","id":5303485,"avatar_url":"https://avatars0.githubusercontent.com/u/5303485?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelwsherman","html_url":"https://github.com/michaelwsherman","followers_url":"https://api.github.com/users/michaelwsherman/followers","following_url":"https://api.github.com/users/michaelwsherman/following{/other_user}","gists_url":"https://api.github.com/users/michaelwsherman/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelwsherman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelwsherman/subscriptions","organizations_url":"https://api.github.com/users/michaelwsherman/orgs","repos_url":"https://api.github.com/users/michaelwsherman/repos","events_url":"https://api.github.com/users/michaelwsherman/events{/privacy}","received_events_url":"https://api.github.com/users/michaelwsherman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-07-05T19:40:45Z","updated_at":"2017-07-05T19:40:45Z","closed_at":null,"body":"In [one of the word2vec papers](https://papers.nips.cc/paper/5021-distributed-representations-of-words-and-phrases-and-their-compositionality.pdf), a method for learning phrases is detailed, and this method is implemented in models.phrases.Phrases. One aspect of the method is currently not supported:\r\n\r\n> Typically, we run 2-4 passes over the training data with decreasing threshold value, allowing longer phrases that consists of several words to be formed. \r\n\r\nWith the current implementation of models.phrases.Phrases, lowering the threshold in Phrases to find n-grams where n > 2 does not work--you will also learn all 2-grams that meet the new lower threshold. This menas you cannot learn n > 2 ngrams unless you keep the threshold constant or raise it as you increase n.\r\n\r\nI implemented one workaround for this, which involved changing the delimiter as I built successive Phrases objects to learn increasing n. A check for the existence of the previous n's delimiter was added to export_phrases, so only phrases where one of the words was found for the previous n were found. But this is an ugly solution. \r\n\r\nA better solution might be to use an existing Phrases (or Phraser) object to generate an optional \"whitelist\" when initializing a Phrases object. Then, only phrases with at least one term in the whitelist would be considered as possible phrases by the new Phrases object. (Generating the whitelist could maybe just be a call to whatever addresses #1465). But this also means another potentially very large dictionary in the Phrases object, as well as many lookups to this dictionary when learning/exporting phrases.\r\n\r\nIf there's some kind of consensus about the best way to add this support, I can maybe give this a try."}}
{"actor":{"display_login":"michaelwsherman"}}