New and ridiculous (incomplete) Python solution.

Having utterly failed at achieving an agreeable Erlang, C or Elixir solution, I now present this horrible text sculpture for which I nurture much affection. 

How does it work?
- It reads a stream (file, stdin, ..);
- It creates a mathematical sum for each one of the g() calls, based on the Unicode code points of the parsed characters;
- It then breaks down each one of those sums with a simple logarithm and voila, we have a likely-good-amount of o's for each g() call and proceed to generate a list of strings that the function can then return.