Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. +1 points for every 100 words
  2. +1 points for every child element that has > 100 words
  3. -1 points if the section name contains the word 'nav'
  4. -2 points if the section name contains the word 'advert'
  5.  
  6. # Import the Template class.
  7. >>> from templatemaker import Template
  8.  
  9. # Create a Template instance.
  10. >>> t = Template()
  11.  
  12. # Learn a Sample String.
  13. >>> t.learn('<b>this and that</b>')
  14.  
  15. # Output the template so far, using the "!" character to mark holes.
  16. # We've only learned a single string, so the template has no holes.
  17. >>> t.as_text('!')
  18. '<b>this and that</b>'
  19.  
  20. # Learn another string. The True return value means the template gained
  21. # at least one hole.
  22. >>> t.learn('<b>alex and sue</b>')
  23. True
  24.  
  25. # Sure enough, the template now has some holes.
  26. >>> t.as_text('!')
  27. '<b>! and !</b>'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement