
-----------------------------------
iop
Sat Jul 17, 2004 11:07 pm

making turing find words
-----------------------------------
i want to create a bot that can talk to people.  for that i need turning to get input, then find words in that input that will tell it what to do.

how can i make turning look for words in user input?

-----------------------------------
Tony
Sun Jul 18, 2004 12:23 am


-----------------------------------
substrings as in

var text:string := "my name is tony"
put text(4..7)


obviously white spaces are flags and you get individual words between them. To find where " " is located, you use index() function

var text : string := "my name is tony" %string working with
var firstSpace : int := index (text, " ") %first occurance of " "
var tempText : string := text (firstSpace + 1 .. *) %string with first word cut out
var wordLength : int := index (tempText, " ") %occurance of second " "
put text (firstSpace + 1 .. firstSpace + wordLength) %putting it all together


-----------------------------------
iop
Sun Jul 18, 2004 12:46 am


-----------------------------------
doesnt turing have like a scan command or something that looks over inputed data for whatever its looking for?

-----------------------------------
AsianSensation
Sun Jul 18, 2004 9:02 am


-----------------------------------
m...........yeah, like tony pointed out above, index is the function you would be using, how well it works would depend on your creativity and skill at string manipulations really.

-----------------------------------
Tony
Sun Jul 18, 2004 9:53 am


-----------------------------------
yeah... instead of breaking the string up into individual words, you can search for an occurance of the substring directly.

var text:string := "my name is tony"

if index(text,"tony") >0 then
put "did somebody say my name?"
else
put "i only answer to tony"
end if


ofcourse it will result true for any occurance of substring, even if its *tony*

a solution would be to add whitespaces to the search " tony " but that doesn't work for the first and last words inputed. So you'd have to be creative. A solution would be to add such whitespaces yourself.

as AsianSensation said : it comes down to your creativity and skill at string manipulations

-----------------------------------
DanShadow
Mon Jul 26, 2004 6:48 pm


-----------------------------------
hmm...this is my way of finding a word in a string:

var text:string:="Hello and welcome to bobbys wonder land.."
var input:string:=""
put "Enter a word to search for: "..
get input
var num:int
num:=length(input)
for i:1..length(text)
    if i+num 0 then
    put "tony was found"
end if

 :wink: 
this way tony and blah_tony_blah are different things :D

-----------------------------------
DanShadow
Fri Jul 30, 2004 8:57 pm


-----------------------------------
aww! Lol, I didnt even know of the index function before I created that. Well, I guess thats cool.  :lol:
