Comment by TeMPOraL
If you walk through the N-gram database with a copy of Harry Potter in hand and observe that for N=7, you can find any piece of it in the database with above-average frequency, does that mean N-gram database is violating copyright?
If the database is sharing those pieces, it might be yes.
Copyright takes into account the use for such the copying is done. Commercial use will almost always be treated as not fair use, with limited exceptions.