BPS counting for knots and combinatorics on words