Debian Codegraph @

texmf-dist/source/support/optexcount/header.py

raw
1 class Header:
2 """
3 Class represents header (all types - title, chapter, section, subsection) and its word counts
4 """
5 def __init__(self, header_type):
6 self.type = header_type # title, chapter, section, subsection
7 self.words = []
8 self.header_count = 0
9 self.text_count = 0
10 self.caption_count = 0
11
12 def add_header_word(self, word):
13 self.words.append(word)
14 self.header_count += 1
15
16 def add_text_word(self):
17 self.text_count += 1
18
19 def add_caption_word(self):
20 self.caption_count += 1
21
22 def __str__(self):
23 result = " " + self.type + " ("
24 result += str(self.header_count) + " + " + str(self.text_count) + " + " + str(self.caption_count) + ")"
25 for word in self.words:
26 result += " " + word
27 return result