summaryrefslogtreecommitdiffstats
path: root/expo/randSent.py
diff options
context:
space:
mode:
authorsubstantialnoninfringinguser <substantialnoninfringinguser@gmail.com>2009-07-02 20:43:18 +0100
committersubstantialnoninfringinguser <substantialnoninfringinguser@gmail.com>2009-07-02 20:43:18 +0100
commite565a6b73b70f670335c4a095992eab26a1bfbf9 (patch)
treea93c4069e8d858b77e9527e794305f97946d21b1 /expo/randSent.py
parent5baddea474b068ece9d6b93bcc90f4d76f97e5a3 (diff)
downloadtroggle-e565a6b73b70f670335c4a095992eab26a1bfbf9.tar.gz
troggle-e565a6b73b70f670335c4a095992eab26a1bfbf9.tar.bz2
troggle-e565a6b73b70f670335c4a095992eab26a1bfbf9.zip
[svn] Renaming troggle.expo to troggle.core. To do this, used:
perl -p -i -e "s/expo(?=[\s\.']+)/core/g" `find -name \*.py` and then manually checked each change (had to remove a couple)
Diffstat (limited to 'expo/randSent.py')
-rw-r--r--expo/randSent.py32
1 files changed, 0 insertions, 32 deletions
diff --git a/expo/randSent.py b/expo/randSent.py
deleted file mode 100644
index a99b974..0000000
--- a/expo/randSent.py
+++ /dev/null
@@ -1,32 +0,0 @@
-import troggle.settings as settings
-from django import forms
-from troggle.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():
- randSent={}
-
- # needs to handle empty logbooks without crashing
-
- #Choose a random logbook entry
- randSent['entry']=LogbookEntry.objects.order_by('?')[0]
-
- #Choose again if there are no sentances (this happens if it is a placeholder entry)
- while len(re.findall('[A-Z].*?\.',randSent['entry'].text))==0:
- 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