diff options
author | substantialnoninfringinguser <substantialnoninfringinguser@gmail.com> | 2009-05-13 05:30:20 +0100 |
---|---|---|
committer | substantialnoninfringinguser <substantialnoninfringinguser@gmail.com> | 2009-05-13 05:30:20 +0100 |
commit | 7a9dc007beff8fa34ceb7d347089304beb58d085 (patch) | |
tree | d4513dc026027519dabd7fdd1ea988f0ed99dba4 | |
parent | 5e5985376afb2ab6d7bfc6a2bd7d9172f962454e (diff) | |
download | troggle-7a9dc007beff8fa34ceb7d347089304beb58d085.tar.gz troggle-7a9dc007beff8fa34ceb7d347089304beb58d085.tar.bz2 troggle-7a9dc007beff8fa34ceb7d347089304beb58d085.zip |
[svn]
Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8160 by aaron @ 1/16/2009 2:41 AM
-rw-r--r-- | expo/randomLogbookSentance.py | 24 |
1 files changed, 0 insertions, 24 deletions
diff --git a/expo/randomLogbookSentance.py b/expo/randomLogbookSentance.py deleted file mode 100644 index d4d3f09..0000000 --- a/expo/randomLogbookSentance.py +++ /dev/null @@ -1,24 +0,0 @@ -import troggle.settings as settings
-from django import forms
-from expo.models import LogbookEntry
-import random
-import re
-
-def weighted_choice(lst):
- n = random.uniform(0,1)
- for item, weight in lst:
- if n < weight:
- break
- n = n - weight
- return item
-
-def randomLogbookSentence():
- #Choose a random logbook entry
- randSent={}
- randSent['entry']=LogbookEntry.objects.order_by('?')[0]
-
- #Choose a random sentence from that entry. Store the sentence as randSent['sentence'], and the number of that sentence in the entry as randSent['number']
- sentenceList=re.findall('[A-Z].*?\.',randSent['entry'].text)
- randSent['number']=random.randrange(0,len(sentenceList))
- randSent['sentence']=sentenceList[randSent['number']]
- return randSent
\ No newline at end of file |