Differences between current version and revision by previous author of Infomer.
Other diffs: Previous Major Revision, Previous Revision, or view the Annotated Edit History
Newer page: | version 9 | Last edited on Wednesday, December 2, 2009 12:28:54 am | by FirstnameLastname | |
Older page: | version 8 | Last edited on Sunday, August 30, 2009 8:20:17 pm | by LawrenceDoliveiro | Revert |
@@ -45,24 +45,24 @@
delims = ["?", ".", "and", ","]
for d in delims:
- line = string
.replace(line,
d, ".")
+ line = line
.replace(d, ".")
- sentences = string
.split(line,
".")
+ sentences = line
.split(".")
for s in sentences:
- words = string
.split(s,
" ")
+ words = s
.split(" ")
for p in prefixes:
if p in words:
words.remove(p)
if first == 1:
first = 0
- ntext = string
.join(words, " "
)
+ ntext = " "
.join(words)
parse_sentence(who, target, ntext)
</verbatim>
@@ -93,33 +93,33 @@
(["I", "am"], [speaker, "is"]),
(["my"], [speaker + "'s"]),
]
- if (
target != None)
:
+ if target != None:
replacements.extend(
[
(["you", "are"], [target, "is"]),
(["are", "you"], ["is", target]),
(["your"], [target + "'s"]),
### bad idea? (["you"], [target]), # catch-all
]
)
- unparsed_tokens = string
.split(sentence
)
+ unparsed_tokens = sentence
.split()
parsed_tokens = []
- while (
len(unparsed_tokens) > )
: # assume len() is evaluated each time
+ while len(unparsed_tokens) > : # assume len() is evaluated each time
for pair in replacements:
made_expansion = 0
term_len = len(pair[0])
- if (
len(unparsed_tokens) >= term_len and
- map(string
.lower,unparsed_tokens[
:term_len]) == pair[])
:
+ if len(unparsed_tokens) >= term_len and \
+ map(str
.lower,unparsed_tokens[:term_len]) == pair[]:
# replace match with replacement
unparsed_tokens = pair[1] + unparsed_tokens[term_len:]
made_expansion = 1
break
- if (
made_expansion == )
:
+ if made_expansion == :
# we couldn't make any expansions at this point...
parsed_tokens.append( unparsed_tokens.pop(0) )
@@ -172,9 +172,9 @@
flag=1
while flag==1:
flag=0
for i in prefixes:
- if map(lambda x:string
.lower(x)
,text[:!len(i)])==i:
+ if map(str
.lower,text[:!len(i)])==i:
text=text[len(i)+1:]
flag=1
return text
</verbatim>