Created
January 27, 2012 10:59
-
-
Save jaroel/1688278 to your computer and use it in GitHub Desktop.
Count words in Plone html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
catalog = context.portal_catalog | |
lexicon = catalog.htmlwordsplitter_lexicon | |
brains = catalog(Language='nl', portal_type='CoolPage') | |
words = dict(Title=0, Description=0, getText=0) | |
for brain in brains: | |
ob = brain.getObject() | |
words['Title'] = ob.Title().split() | |
words['Description'] = ob.Description().split() | |
words['getText'] = lexicon.parseTerms(ob.getText()) | |
no_of_words = len(words['Title']) + len(words['Description']) + len(words['getText']) | |
print ";".join(map(str, ['"%s"' % ob.Title(), ob.absolute_url(), len(words['Title']), len(words['Description']), len(words['getText']), no_of_words])) | |
return printed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment