Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/bot/aiml/Utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'bot/aiml/Utils.py')
-rw-r--r--bot/aiml/Utils.py32
1 files changed, 0 insertions, 32 deletions
diff --git a/bot/aiml/Utils.py b/bot/aiml/Utils.py
deleted file mode 100644
index 75e5a1c..0000000
--- a/bot/aiml/Utils.py
+++ /dev/null
@@ -1,32 +0,0 @@
-"""This file contains assorted general utility functions used by other
-modules in the PyAIML package.
-
-"""
-
-def sentences(s):
- """Split the string s into a list of sentences."""
- try: s+""
- except: raise TypeError, "s must be a string"
- pos = 0
- sentenceList = []
- l = len(s)
- while pos < l:
- try: p = s.index('.', pos)
- except: p = l+1
- try: q = s.index('?', pos)
- except: q = l+1
- try: e = s.index('!', pos)
- except: e = l+1
- end = min(p,q,e)
- sentenceList.append( s[pos:end].strip() )
- pos = end+1
- # If no sentences were found, return a one-item list containing
- # the entire input string.
- if len(sentenceList) == 0: sentenceList.append(s)
- return sentenceList
-
-# Self test
-if __name__ == "__main__":
- # sentences
- sents = sentences("First. Second, still? Third and Final! Well, not really")
- assert(len(sents) == 4) \ No newline at end of file