I am trying to do three simple steps efficiently in Python.
I have a list of lists (of strings). Let us call it L.
I want to flatten the list of lists to a single list LL. (I know how to do this efficiently)
Construct the set of words with frequency 1 from the list LL of step 1. Let us call this set S. (I also know how to do this
efficiently)Remove all the words from the list of lists L which occur in S.
If you can suggest an efficient way of doing step 3, that will be a great help.
use a simple
list comprehensionfor the 3rd step:if you’ve a set
R: