def _convert(self, string, dictionary = [], is_dict_group = False):
tree = StringTree(string)<EOL>for c_dict in dictionary:<EOL><INDENT>if isinstance(c_dict, tuple):<EOL><INDENT>tree.convert_tree(c_dict)<EOL>if not is_dict_group:<EOL><INDENT>tree = StringTree("<STR_LIT>".join(tree.inorder()))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>tree = StringTree(self._convert("<STR_LIT>".join(tree.inorder()), c_dict, True))<EOL><DEDENT><DEDENT>return "<STR_LIT>".join(tree.inorder())<EOL>
Convert string from Simplified Chinese to Traditional Chinese or vice versa
If a dictionary is part of a group of dictionaries, stop conversion on a word
after the first match is found.
:param string: the input string
:param dictionary: list of dictionaries to be applied against the string
:param is_dict_group: indicates if this is a group of dictionaries in which only
                      the first match in the dict group should be used
:return: converted string