Proagate word counts and save them for files.
This commit is contained in:
@@ -31,11 +31,6 @@ class NWDoc():
|
||||
self.theItem = None
|
||||
self.docHandle = None
|
||||
|
||||
# Document Info
|
||||
self.charCount = None
|
||||
self.lineCount = None
|
||||
self.wordCount = None
|
||||
|
||||
return
|
||||
|
||||
def openDocument(self, tHandle):
|
||||
@@ -83,28 +78,8 @@ class NWDoc():
|
||||
|
||||
if path.isfile(docTemp): unlink(docTemp)
|
||||
|
||||
docAna = TextAnalysis(docText,"en_GB")
|
||||
wC, sC, pC = docAna.getStats()
|
||||
# rScr, gLev = docAna.getReadabilityScore()
|
||||
|
||||
self.theItem.setWordCount(wC)
|
||||
self.theItem.setSentCount(sC)
|
||||
self.theItem.setParaCount(pC)
|
||||
|
||||
return True
|
||||
|
||||
##
|
||||
# Setters
|
||||
##
|
||||
|
||||
def setCharCount(self, theCount):
|
||||
self.charCount = theCount
|
||||
return
|
||||
|
||||
def setLineCount(self, theCount):
|
||||
self.lineCount = theCount
|
||||
return
|
||||
|
||||
##
|
||||
# Internal Functions
|
||||
##
|
||||
|
||||
+15
-14
@@ -37,9 +37,9 @@ class NWItem():
|
||||
self.hasChildren = False
|
||||
self.isExpanded = False
|
||||
|
||||
self.wordCount = None
|
||||
self.sentCount = None
|
||||
self.paraCount = None
|
||||
self.charCount = 0
|
||||
self.wordCount = 0
|
||||
self.paraCount = 0
|
||||
|
||||
return
|
||||
|
||||
@@ -59,9 +59,10 @@ class NWItem():
|
||||
xSub = self._subPack(xPack,"depth", text=str(self.itemDepth))
|
||||
xSub = self._subPack(xPack,"children", text=str(self.hasChildren))
|
||||
xSub = self._subPack(xPack,"expanded", text=str(self.isExpanded))
|
||||
xSub = self._subPack(xPack,"wordCount", text=str(self.wordCount), none=False)
|
||||
xSub = self._subPack(xPack,"sentCount", text=str(self.sentCount), none=False)
|
||||
xSub = self._subPack(xPack,"paraCount", text=str(self.paraCount), none=False)
|
||||
if self.itemType == nwItemType.FILE:
|
||||
xSub = self._subPack(xPack,"charCount", text=str(self.charCount), none=False)
|
||||
xSub = self._subPack(xPack,"wordCount", text=str(self.wordCount), none=False)
|
||||
xSub = self._subPack(xPack,"paraCount", text=str(self.paraCount), none=False)
|
||||
return xPack
|
||||
|
||||
def _subPack(self, xParent, name, attrib=None, text=None, none=True):
|
||||
@@ -85,8 +86,8 @@ class NWItem():
|
||||
elif tagName == "depth": self.setDepth(tagValue)
|
||||
elif tagName == "children": self.setChildren(tagValue)
|
||||
elif tagName == "expanded": self.setExpanded(tagValue)
|
||||
elif tagName == "charCount": self.setCharCount(tagValue)
|
||||
elif tagName == "wordCount": self.setWordCount(tagValue)
|
||||
elif tagName == "sentCount": self.setSentCount(tagValue)
|
||||
elif tagName == "paraCount": self.setParaCount(tagValue)
|
||||
else:
|
||||
logger.error("Unknown tag '%s'" % tagName)
|
||||
@@ -159,18 +160,18 @@ class NWItem():
|
||||
# Set Stats
|
||||
##
|
||||
|
||||
def setCharCount(self, theCount):
|
||||
theCount = self._checkInt(theCount,0)
|
||||
self.charCount = theCount
|
||||
return
|
||||
|
||||
def setWordCount(self, theCount):
|
||||
theCount = self._checkInt(theCount,None,True)
|
||||
theCount = self._checkInt(theCount,0)
|
||||
self.wordCount = theCount
|
||||
return
|
||||
|
||||
def setSentCount(self, theCount):
|
||||
theCount = self._checkInt(theCount,None,True)
|
||||
self.sentCount = theCount
|
||||
return
|
||||
|
||||
def setParaCount(self, theCount):
|
||||
theCount = self._checkInt(theCount,None,True)
|
||||
theCount = self._checkInt(theCount,0)
|
||||
self.paraCount = theCount
|
||||
return
|
||||
|
||||
|
||||
+13
-8
@@ -43,8 +43,9 @@ class NWProject():
|
||||
|
||||
return
|
||||
|
||||
def buildProjectTree(self):
|
||||
return True
|
||||
##
|
||||
# Add Entries
|
||||
##
|
||||
|
||||
def newRoot(self, rootName, rootClass):
|
||||
newItem = NWItem()
|
||||
@@ -85,6 +86,10 @@ class NWProject():
|
||||
hScene = self.newFile("New Scene", nwItemClass.NOVEL, hChapt)
|
||||
return
|
||||
|
||||
##
|
||||
# File I/O
|
||||
##
|
||||
|
||||
def openProject(self, fileName):
|
||||
|
||||
if not path.isfile(fileName):
|
||||
@@ -194,9 +199,9 @@ class NWProject():
|
||||
|
||||
return True
|
||||
|
||||
#
|
||||
##
|
||||
# Set Functions
|
||||
#
|
||||
##
|
||||
|
||||
def setProjectPath(self, projPath):
|
||||
self.projPath = projPath
|
||||
@@ -225,9 +230,9 @@ class NWProject():
|
||||
self.treeOrder = newOrder
|
||||
return True
|
||||
|
||||
#
|
||||
##
|
||||
# Get Functions
|
||||
#
|
||||
##
|
||||
|
||||
def getItem(self, tHandle):
|
||||
if tHandle in self.projTree:
|
||||
@@ -305,9 +310,9 @@ class NWProject():
|
||||
|
||||
return validActions
|
||||
|
||||
#
|
||||
##
|
||||
# Internal Functions
|
||||
#
|
||||
##
|
||||
|
||||
def _checkRootUnique(self, theClass):
|
||||
"""Checks if there already is a root entry of class 'theClass' in the
|
||||
|
||||
Reference in New Issue
Block a user