words = getWordsFromPi[200];
For[i = 0, i < Length[words], i++,
if[DictionaryWordQ[StringJoin[words[[i]]],
Insert[list, words[[i]]]]]]
words
is a list of lists that contain 5-character elements. My goal with the For-loop is to check which 5-characters, when joined together in string, create a valid word recognized by DictionaryWordQ
.
When I find a valid word it, I want to accumulate it in another list.
I do not know where to go from here.
getWordsFromPi[n_] :=
Map[StringJoin,
Partition[
Map[FromCharacterCode,
Flatten@ToExpression@
StringSplit[Delete[StringPartition[ToString[N[Pi, n]], 2], 1],
","]], 5]];
words = getWordsFromPi[10000];
Select[words, DictionaryWordQ]
The issue I am having now is that the DictionaryWordQ built-in function isn't working how I wanted it to. When you execute the code above, you will obtain this list:
{"H-W\.00B", "\.00\.05D
G", "\.00C3\.03\"", "XX\.00NE", "\.00:L\.07:", "\.00\.1d`\.07S", "F\
\.00E\\R", "\.00\"\.0fW\.16", "\.00P\.1f7Z", "\.00%\[RawEscape]b'"}
Clearly none of these are the English words that I am looking for. In fact, I expected the list to be empty, but instead I obtained this nonsense. What am I doing wrong?
Select[words, DictionaryWordQ]
should generate the subset ofwords
that are dictionary words. $\endgroup$Select[words,DictionaryWordQ[StringJoin@#]&]
. But I need this list in order to check if this works $\endgroup$