def create_visual_conf(docgraph, pointing_chains):
    '\n    creates a visual.conf file (as a string)\n    for the given document graph.\n    '
    num_of_entities = len(pointing_chains)
    mapsize = max(3, min(12, num_of_entities))
    colormap = brewer2mpl.get_map(name='Paired', map_type='Qualitative', number=mapsize)
    colors = (range(mapsize) * int(math.ceil((num_of_entities / float(mapsize)))))
    endless_color_cycle = itertools.cycle(colors)
    ret_str = u'[drawing]\n\n'
    for chain in pointing_chains:
        background_color = colormap.hex_colors[endless_color_cycle.next()]
        for markable in chain:
            span_tokens = spanstring2tokens(docgraph, docgraph.node[markable][(docgraph.ns + ':span')])
            span_text = dg.tokens2text(docgraph, span_tokens)
            ascii_markable = unidecode(span_text)
            ret_str += u'{0}\tbgColor:{1}\n'.format(ascii_markable, background_color)
    ret_str += '\n[labels]'
    return ret_str
creates a visual.conf file (as a string)
for the given document graph.
def create_visual_conf(docgraph, pointing_chains):
    '\n    creates a visual.conf file (as a string)\n    for the given document graph.\n    '
    num_of_entities = len(pointing_chains)
    mapsize = max(3, min(12, num_of_entities))
    colormap = brewer2mpl.get_map(name='Paired', map_type='Qualitative', number=mapsize)
    colors = (range(mapsize) * int(math.ceil((num_of_entities / float(mapsize)))))
    endless_color_cycle = itertools.cycle(colors)
    ret_str = u'[drawing]\n\n'
    for chain in pointing_chains:
        background_color = colormap.hex_colors[endless_color_cycle.next()]
        for markable in chain:
            span_tokens = spanstring2tokens(docgraph, docgraph.node[markable][(docgraph.ns + ':span')])
            span_text = dg.tokens2text(docgraph, span_tokens)
            ascii_markable = unidecode(span_text)
            ret_str += u'{0}\tbgColor:{1}\n'.format(ascii_markable, background_color)
    ret_str += '\n[labels]'
    return ret_str