def text_to_title(value):
title = None<EOL>if not value:<EOL><INDENT>return title<EOL><DEDENT>words = value.split("<STR_LIT:U+0020>")<EOL>keep_words = []<EOL>for word in words:<EOL><INDENT>if word.endswith("<STR_LIT:.>") or word.endswith("<STR_LIT::>"):<EOL><INDENT>keep_words.append(word)<EOL>if len(word) > <NUM_LIT:1> and "<STR_LIT>" not in word and "<STR_LIT>" not in word:<EOL><INDENT>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>keep_words.append(word)<EOL><DEDENT><DEDENT>if len(keep_words) > <NUM_LIT:0>:<EOL><INDENT>title = "<STR_LIT:U+0020>".join(keep_words)<EOL>if title.split("<STR_LIT:U+0020>")[-<NUM_LIT:1>] != "<STR_LIT>":<EOL><INDENT>title = title.rstrip("<STR_LIT>")<EOL><DEDENT><DEDENT>return title<EOL>
when a title is required, generate one from the value