Are there any tools/APIs that provide this service?
Example:
(After) Free
- Free beer
- Free pizza
- Free stuff
(Before) Beer
- Craft Beer
- Draft Beer
- Free Beer
- Cheap Beer
Thanks.
My favorite tool for this is English-corpora.org. Although there is no API access due to copyright, it is a very powerful tool, at least once you understand how to use it.
For example:
The Oxford Collocations Dictionary uses data from one of those corpora: the BNC.
Google Books NGram search allows searches with wild cards where you can specify part of speech.
For example, searching there for
'beer' preceded by any adjective, returns a chart of the most frequent such pairs:
For help on specifying these wild cards (it has a lot of restrictions) see the Google Books NGram help
But be wary of all the difficulties with Google books: the lack of specification of the corpus, OCR errors, dating problems, etc.
Also be aware that what you think the collocations are going to be like aren't necessarily what actually are the most frequent. And I don't think you can get beyond the top ten. The history graph is very pleasing but COCA will be much more informative.
Yes, What you're looking for is Word2vec. This is a machine learning method that learns a large corpus (e.g. one or more books) and stores a dictionary of words as vectors.
Given a context, e.g. a sentence with a gap, it computes which words are most likely based on the corpus it's trained on.
For a more in-depth description. I suggest considering this question on datascience.SE. And for a deep dive, I'd suggest looking into the [word-embeddings] tag on that site.
Contrary to ready-to-use tools, by making the embeddings yourself, you get to choose the theme. For example, Google's corpus considers a wide variety of texts, which is great for general insight. On the other hand, if you're interested in a specific field, you could build embeddings on texts from that field only, making the results more relevant for your context.
https://www.google.com/
. You will get plain, vanilla Google.