I want to make a selection on this list
words = {{{"word1", "word2"}, 19}, {{"word1", "word3"},
8}, {{"word1", "word4"}, 7}, {{"word2", "word5"},
7}, {{"word2", "word5"}, 7}, {{"word3", "word6"},
7}, {{"word3", "word7"}, 7}, {{"word3", "word8"},
6}, {{"word4", "word6"}, 6}};
From this list, I want to select all 'records' which have one of these words
wordsselect = {"word2", "word4", "word8"}
The desirde output is:
wordsnew = {{{"word1", "word2"}, 19}, {{"word1", "word4"},
7}, {{"word2", "word5"}, 7}, {{"word2", "word5"},
7}, {{"word3", "word8"}, 6}, {{"word4", "word6"}, 6}}
I tried to make a selection based on one word
Select[words[[All, {1, 2}]], MemberQ[#[[1]], "word2"] &]
this works fine. So I tried the next script
Select[words[[All, {1, 2}]], MemberQ[#[[1]], wordsselect ] &]
The output is empty {}
I have two questions:
How do I get the desired output?
Why is my second try not working?