def cleanWord(self, word): word = util.splitToWords(util.lower(util.toInputStr(word))) if len(word) == 0: return "" return word[0]
def __init__(self, sp, gScDict): self.sp = sp # user's global dictionary (Dict) self.gScDict = gScDict # key = word found in character names, value = None self.cnames = {} for it in sp.getCharacterNames(): for w in util.splitToWords(it): self.cnames[w] = None self.word = None self.line = self.sp.line # we can't use the current column, because if the cursor is in the # middle of a word, we flag the partial word as misspelled. self.col = 0
def __init__(self, sp): self.sp = sp ls = sp.lines # key = character name, value = CharInfo chars = {} name = None scene = "(NO SCENE NAME)" # how many lines processed for current speech curSpeechLines = 0 for i in xrange(len(ls)): line = ls[i] if (line.lt == screenplay.SCENE) and\ (line.lb == screenplay.LB_LAST): scene = util.upper(line.text) elif (line.lt == screenplay.CHARACTER) and\ (line.lb == screenplay.LB_LAST): name = util.upper(line.text) curSpeechLines = 0 elif line.lt in (screenplay.DIALOGUE, screenplay.PAREN) and name: ci = chars.get(name) if not ci: ci = CharInfo(name, sp) chars[name] = ci if scene: ci.scenes[scene] = ci.scenes.get(scene, 0) + 1 if curSpeechLines == 0: ci.speechCnt += 1 curSpeechLines += 1 # PAREN lines don't count as spoken words if line.lt == screenplay.DIALOGUE: ci.lineCnt += 1 words = util.splitToWords(line.text) ci.wordCnt += len(words) ci.wordCharCnt += reduce(lambda x, y: x + len(y), words, 0) ci.pages.addPage(sp.line2page(i)) else: name = None curSpeechLines = 0 # list of CharInfo objects self.cinfo = [] for v in chars.values(): self.cinfo.append(v) self.cinfo.sort(cmpLines) self.totalSpeechCnt = self.sum("speechCnt") self.totalLineCnt = self.sum("lineCnt") self.totalWordCnt = self.sum("wordCnt") self.totalWordCharCnt = self.sum("wordCharCnt") # information types and what to include self.INF_BASIC, self.INF_PAGES, self.INF_LOCATIONS = range(3) self.inf = [] for s in ["Basic information", "Page list", "Location list"]: self.inf.append(misc.CheckBoxItem(s))