Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#!C:\pythonCode
# -*- coding: utf-8 -*-
# @Time : 2023/2/17 01:42
# @Author : Lertoon Wang
# @File : funcs.py
# @Software: PyCharm
import logging
def __sliceFactors(para, dict):
"""
slice the factors from the control title with 【】
:param para: the paragraph object
:return: the dict of factors
"""
factors = {}
# slice the factors
factorList = para.text.split("】")
for factor in factorList:
if factor.startswith("【"):
factor = factor[1:]
index = factor.find(":")
if index != -1:
key = dict.get(factor[:index])
value = factor[index + 1:]
factors[key] = value
return factors
def __slicePlainText(para):
"""
slice the plain text into character and dialogue
:param para: the paragraph object
:return: the character and dialogue
"""
index = para.text.find(":")
print("the index of : is " + str(index))
if index > 0:
character = para.runs[0].text[:index - 1]
dialogue = para.runs[0].text[index + 1:]
logging.info(character + ":" + dialogue)
else:
character = ""
dialogue = para.runs[0].text[1:]
return character, dialogue