def test_lists(): # Lists itemize = Itemize() itemize.add_item(s="item") itemize.append("append") enum = Enumerate() enum.add_item(s="item") enum.append("append") desc = Description() desc.add_item(label="label", s="item") desc.append("append")
def build_text_automatic(self, record): text = record[Constants.TEXT_FIELD] sentences = nlp_utils.get_sentences(text) lemmatized_words = [] for sentence in sentences: lemmatized_words.append( nlp_utils.lemmatize_sentence(sentence, nltk.re.compile(''), min_length=1, max_length=100)) doc_parts = [] itemize = Itemize() for sentence in lemmatized_words: new_words = [] itemize.add_item('') for tagged_word in sentence: tag = tagged_word[1] word = tagged_word[0] singular = pattern.text.en.singularize(word) word_found = False # if tag == 'VBD': # new_words.append( # '\\colorbox[rgb]{0.5,0.5,0.5}{' + word + '}') # word_found = True # # if tag.startswith('PRP'): # new_words.append( # '\\colorbox[rgb]{0.85,0.85,0.85}{' + word + '}') # word_found = True for topic_id in self.automatic_context_topic_ids: if word in self.topic_words_map[topic_id]: # if singular in context_words[Constants.ITEM_TYPE][topic]: self.tag_word(word) color_id = self.automatic_context_topic_colors[ topic_id] color = self.rgb_tuples[color_id] new_words.append('\\colorbox[rgb]{' + str(color[0]) + ',' + str(color[1]) + ',' + str(color[2]) + '}{' + word + '}') word_found = True break if not word_found: new_words.append(word) itemize.append(NoEscape(' '.join(new_words))) doc_parts.append(itemize) return doc_parts
def build_text_automatic(self, record): text = record[Constants.TEXT_FIELD] sentences = nlp_utils.get_sentences(text) lemmatized_words = [] for sentence in sentences: lemmatized_words.append(nlp_utils.lemmatize_sentence( sentence, nltk.re.compile(''), min_length=1, max_length=100)) doc_parts = [] itemize = Itemize() for sentence in lemmatized_words: new_words = [] itemize.add_item('') for tagged_word in sentence: tag = tagged_word[1] word = tagged_word[0] singular = pattern.text.en.singularize(word) word_found = False # if tag == 'VBD': # new_words.append( # '\\colorbox[rgb]{0.5,0.5,0.5}{' + word + '}') # word_found = True # # if tag.startswith('PRP'): # new_words.append( # '\\colorbox[rgb]{0.85,0.85,0.85}{' + word + '}') # word_found = True for topic_id in self.automatic_context_topic_ids: if word in self.topic_words_map[topic_id]: # if singular in context_words[Constants.ITEM_TYPE][topic]: self.tag_word(word) color_id = self.automatic_context_topic_colors[topic_id] color = self.rgb_tuples[color_id] new_words.append( '\\colorbox[rgb]{' + str(color[0]) + ',' + str(color[1]) + ',' + str(color[2]) + '}{' + word + '}') word_found = True break if not word_found: new_words.append(word) itemize.append(NoEscape(' '.join(new_words))) doc_parts.append(itemize) return doc_parts
def test_lists(): # Lists itemize = Itemize() itemize.add_item(s="item") itemize.append("append") repr(itemize) enum = Enumerate(enumeration_symbol=r"\alph*)", options={'start': 172}) enum.add_item(s="item") enum.add_item(s="item2") enum.append("append") repr(enum) desc = Description() desc.add_item(label="label", s="item") desc.append("append") repr(desc)
def test_lists(): # Lists itemize = Itemize() itemize.add_item(s="item") itemize.append("append") repr(itemize) empty_itemize = Itemize() assert empty_itemize.dumps() == '' repr(empty_itemize) enum = Enumerate() enum.add_item(s="item") enum.append("append") repr(enum) desc = Description() desc.add_item(label="label", s="item") desc.append("append") repr(desc)
a = Axis(data=None, options=None) p = Plot(name=None, func=None, coordinates=None, options=None) # Utils escape_latex(s='') fix_filename(path='') dumps_list(l=[], escape=False, token='\n') bold(s='') italic(s='') verbatim(s='', delimiter='|') # Lists itemize = Itemize() itemize.add_item(s="item") itemize.append("append") enum = Enumerate() enum.add_item(s="item") enum.append("append") desc = Description() desc.add_item(label="label", s="item") desc.append("append")