def expand(self, tags, clique_scoring_func=None):
lattice = Lattice()<EOL>overlapping_spans = []<EOL>def end_token_index():<EOL><INDENT>return max([t.get('<STR_LIT>') for t in overlapping_spans])<EOL><DEDENT>for i in xrange(len(tags)):<EOL><INDENT>tag = tags[i]<EOL>if len(overlapping_spans) > <NUM_LIT:0> and end_token_index() >= tag.get('<STR_LIT>'):<EOL><INDENT>overlapping_spans.append(tag)<EOL><DEDENT>elif len(overlapping_spans) > <NUM_LIT:1>:<EOL><INDENT>cliques = list(self._sub_expand(overlapping_spans))<EOL>if clique_scoring_func:<EOL><INDENT>cliques = sorted(cliques, key=lambda e: -<NUM_LIT:1> * clique_scoring_func(e))<EOL><DEDENT>lattice.append(cliques)<EOL>overlapping_spans = [tag]<EOL><DEDENT>else:<EOL><INDENT>lattice.append(overlapping_spans)<EOL>overlapping_spans = [tag]<EOL><DEDENT><DEDENT>if len(overlapping_spans) > <NUM_LIT:1>:<EOL><INDENT>cliques = list(self._sub_expand(overlapping_spans))<EOL>if clique_scoring_func:<EOL><INDENT>cliques = sorted(cliques, key=lambda e: -<NUM_LIT:1> * clique_scoring_func(e))<EOL><DEDENT>lattice.append(cliques)<EOL><DEDENT>else:<EOL><INDENT>lattice.append(overlapping_spans)<EOL><DEDENT>return lattice.traverse()<EOL>
This is the main function to expand tags into cliques

        Args:
            tags (list): a list of tags to find the cliques.
            clique_scoring_func (func): a function that returns a float
                value for the clique

        Returns:
            list : a list of cliques