So, if any public code is allowed and we let it slip through. Google can say for example see all text on Google Docs and __sell__ a solution that generates text for you. Is this allowed?
Yes it is allowed. This is in fact how GMail’s autocomplete came to be. Of course this raised all sorts of interesting problems. One of the funnier ones is when users typed “happy” it would suggest “thanksgiving” since “happy thanksgiving” was the most common phrase starting with happy in their email corpus.