I don't think arrays will work here any more efficiently because you have the variable names as the ngrams. If they were part of the data then yes an array could work.
One other possible method:
There are (26 choose 2=325) possible combinations + all single values (26) = 351 combinations. Create all and then as you find each, change the indicator variable to a 1/0. But if your data is smaller it may be overkill here to have 351 variables.
... View more