Ai Forums Home Welcome Guest    Wednesday, June 19, 2013
Ai Site > Ai Forums > The Artificial Intelligence Forum > Last PostsLoginRegisterWhy Register
Topic:

jeremy duncan
posted 8/7/2012  22:59Reply with quote
In a string of multiple words, in the last word of the string there is consonants. If you match the last words consonts to the other words consonants so only the words that share a consonant with the last word form the string you will find a frank statement instead of a wordy dialog.

Since there is a frank statement it can be a database string, and so, the frank string can have a set of chars used, and then when you make a frank string it can be compared to the database to find the best number of matching chars and so link frank strings to have related thoughts on the matter at hand.

for example;
"a long way home." becomes "long home".
"Long home" can have the char values (1,2,3,4,5,6,7)
This is the frank string, not the wordy dialog, it goes into a database.

Then you repeat this for new input and if it matches enough of the char numbers from the database string, the database string matches the new input string as a related thought.
This can work like a bubble sort algorithm, so the match that fits the most char numbers is put at the top of possible matches from the database.




squarebear
posted 8/13/2012  18:24Send e-mail to userReply with quote
Trying to find the meaning of sentences by comparing consonants in each word is nonsense.

If I understand you correctly, you are comparing the consonants in "home" with consonants in the other words. This will not produce "long home", as long shares no consonants with the word "home".

Last edited by squarebear @ 8/13/2012 6:26:00 PM

jeremy duncan
posted 8/13/2012  23:37Reply with quote
The last word is called the expression word, the rest of the words are used to test to see if they share a letter with the expression word.
First I try a single word from the sentence and test to see if shares a consonant with the expression word; it can match, it can not match, it has been tested already.
Then all the letters of the word have been tested.
Then the word either; has a matching char, or doesn't have a matching char with the expression string.
This goes on for all the words in the input string, comparing it to the expression string until all the words are tested.
This can result in no consonant chars matchin, in which case the vowels of the words from the input string are compared to the vowels of the expression string to see if they match.

If consonants in the input string match the consonants in the expression string, these are concatenated together to form a new string I call the secret string, then the program closes.
Else if the vowels in the input string match the vowels in the expression string, these are concatenated together to form a new string I call the secret string, then the program closes.
else the vowels and consonants in the string do not match the vowels and consonant in the expression string, the program closes with no new secret string.

There is the i/o the program fits into, the program is the (expression) + (secret string) glued together by there being a match which consists of (either a consonant or vowel from the input) + (belonging to the expression string).

Here is a picture of it;

http://www.imagebam.com/image/d02681205817665


squarebear
posted 8/14/2012  10:55Send e-mail to userReply with quote
Yes I understand what you are trying to do but why do you believe that words sharing consonants or vowels has any bearing whatsoever on the meaning of the sentence?


jeremy duncan
posted 8/14/2012  11:56Reply with quote
Since I was asked to write the secret message finder SW, I have done so. But this is a crude version as it can only accept one sentence at a time.
And the sentence must be ended with a period.

Here is the link to the SW, it source code is included too (and it's c++ code in case you were wondering); http://www.mediafire.com/?7w04s77capc4a5x

In case you don't want to dl the file and want to read it instead, too bad, the code is 233 lines and thats too much for a forum I think.
So if you want to see the code your going to have to dl it.

I was just joking; here is the code, the forum may introduce errors not in the source;

#include <iostream>
#include <fstream>
#include <cstdlib> // exit()
#include <string.h>

using namespace std;
// The global variables quality as using an expression.
int countConsonantMatches = 0;
int countVowelMatches = 0;
string holdSentence;
string holdWord;
string holdSentenceAgain;
string holdSentenceOnceMore;
string readConsonantMatch;
string readVowelMatch;
string consonants = "bcdfghjklmnpqrstvwxzBCDFGHJKLMNPQRSTVWXZ";
string vowels = "aeiouyAEIOUY";
// The function used with getLastWordInSentence to create the first step in the program, the expression word
void splitBySentence(){
int character;
int file_character=0;
char buffer[1024];
string readTwice;
string readThrice;
string readFour;
int count = 0;
int count_2 = 0;
int count_3 = 1;

ifstream read ("readtext.txt");
ofstream write ("writetext.txt");
if (!read) { std::cerr<<"file error
readtext2, splitBySentence"; std::exit(1); }
if (!write) { std::cerr<<"file error
writetext, splitBySentence"; std::exit(1); }

if(read.is_open()){
if(write.is_open()){
while(file_character!=EOF){
buffer[0]='\0';
for(character=0;character<sizeof(buffer);character++){
file_character=read.get();
if(file_character==EOF)
break;
if(file_character=='.'){
buffer[character]='\0';
break;
}
else if(file_character=='?'){
buffer[character]='\0';
break;
}
else if(file_character=='!'){
buffer[character]='\0';
break;
}
else if(file_character==' '){
buffer[character]='\0';
break;
}
else if(file_character=='
'){
buffer[character]='\0';
continue;
}
buffer[character]=file_character;
}
if(file_character==EOF)
break;
write << buffer << endl;
}
read.close();
write.close();
}
}

ifstream read2 ("writetext.txt");
std::ofstream fout("file_out.txt");
if (!fout) { std::cerr<<"file error
file_out, splitBySentence"; std::exit(1); }
if (!read2) { std::cerr<<"file error
writetext, splitBySentence"; std::exit(1); }
char ignoreList[] = "~@#$%^&*()_+`1234567890-=[]\'\"/;/|,/{}:<>";
string openToRead;

while(getline(read2, openToRead)){
for (string::size_type a = 0; a < openToRead.length(); ++a){
if((openToRead[a] == ignoreList[0]) || (openToRead[a] == ignoreList[1])
|| (openToRead[a] == ignoreList[2]) || (openToRead[a] == ignoreList[3])
|| (openToRead[a] == ignoreList[4]) || (openToRead[a] == ignoreList[5])
|| (openToRead[a] == ignoreList[6]) || (openToRead[a] == ignoreList[7])
|| (openToRead[a] == ignoreList[8]) || (openToRead[a] == ignoreList[9])
|| (openToRead[a] == ignoreList[10]) || (openToRead[a] == ignoreList[11])
|| (openToRead[a] == ignoreList[12]) || (openToRead[a] == ignoreList[13])
|| (openToRead[a] == ignoreList[14]) || (openToRead[a] == ignoreList[15])
|| (openToRead[a] == ignoreList[16]) || (openToRead[a] == ignoreList[17])
|| (openToRead[a] == ignoreList[18]) || (openToRead[a] == ignoreList[19])
|| (openToRead[a] == ignoreList[20]) || (openToRead[a] == ignoreList[21])
|| (openToRead[a] == ignoreList[22]) || (openToRead[a] == ignoreList[23])
|| (openToRead[a] == ignoreList[24]) || (openToRead[a] == ignoreList[25])
|| (openToRead[a] == ignoreList[26]) || (openToRead[a] == ignoreList[27])
|| (openToRead[a] == ignoreList[28]) || (openToRead[a] == ignoreList[29])
|| (openToRead[a] == ignoreList[30]) || (openToRead[a] == ignoreList[31])
|| (openToRead[a] == ignoreList[32]) || (openToRead[a] == ignoreList[33])
|| (openToRead[a] == ignoreList[34]) || (openToRead[a] == ignoreList[35])
|| (openToRead[a] == ignoreList[36]) || (openToRead[a] == ignoreList[37])
|| (openToRead[a] == ignoreList[38]) || (openToRead[a] == ignoreList[39])
|| (openToRead[a] == ignoreList[40]) || (openToRead[a] == ignoreList[41])
|| (openToRead[a] == ignoreList[42]))
openToRead[a] = ' ';
}

if(openToRead != ""){
fout << openToRead << endl;
}
}
read2.close();
fout.close();
}
// Used to make the expression word
void getLastWordInSentence(){
ifstream read ("file_out.txt");
if (!read) { std::cerr<<"file error
file_out, main"; std::exit(1); }

while(getline(read, holdSentence)){
if(holdSentence != "")
holdWord = holdSentence;
else break;
}

read.close();
}
// compares the rest of the words in the input string to the expression word to find words that have a shared consonant letter
void matchConsonants(){
ifstream read2 ("file_out.txt");
if (!read2) { std::cerr<<"file error
file_out, main"; std::exit(1); }
std::ofstream writeConsonant("consonant.txt", fstream::app);
if (!writeConsonant) { std::cerr<<"file error
consonant, matchConsonants"; std::exit(1); }

while(getline(read2, holdSentenceAgain)){
bool Cond1 = true;
if(holdSentenceAgain != holdWord){
for (string::size_type a = 0; a<holdWord.length(); a++){
for (string::size_type b = 0; b<holdSentenceAgain.length(); b++){
if(holdWord[a] == holdSentenceAgain[b] && (consonants.find(holdSentenceAgain[b]) != string::npos)){
writeConsonant << holdSentenceAgain << " ";
countConsonantMatches++;
Cond1 = false;
break;
}
else{
continue;
}
}
if (Cond1==false){break;}
}
}
}
read2.close();
if(countConsonantMatches != 0)
writeConsonant << holdWord << ".";
writeConsonant.close();
}
// compares the rest of the words in the input string to the expression word to find words that have a shared vowel letter
void matchVowels(){
if(countConsonantMatches == 0){
ifstream read3 ("file_out.txt");
if (!read3) { std::cerr<<"file error
file_out, main"; std::exit(1); }
std::ofstream writeVowel("vowel.txt", fstream::app);
if (!writeVowel) { std::cerr<<"file error
vowel, matchVowels"; std::exit(1); }
while(getline(read3, holdSentenceOnceMore)){
bool Cond2 = true;
if(holdSentenceOnceMore != holdWord){
for (string::size_type a = 0; a<holdWord.length(); a++){
for (string::size_type b = 0; b<holdSentenceOnceMore.length(); b++){
if(holdWord[a] == holdSentenceOnceMore[b] && (vowels.find(holdSentenceOnceMore[b]) != string::npos)){
writeVowel << holdSentenceOnceMore << " ";
countVowelMatches++;
Cond2 = false;
break;
}
else{
continue;
}
}
if (Cond2==false){break;}
}
}
}

read3.close();
if(countVowelMatches != 0)
writeVowel << holdWord << ".";
writeVowel.close();
}
}

int main()
{
// I open the close these files to erase the results of the previous time the program was run
std::ofstream writeVowel("vowel.txt");
if (!writeVowel) { std::cerr<<"file error
vowel, matchVowels"; std::exit(1); }
std::ofstream writeConsonant("consonant.txt");
if (!writeConsonant) { std::cerr<<"file error
consonant, matchConsonants"; std::exit(1); }
writeVowel.close();
writeConsonant.close();
// splitBySentence is used with V to create the expression word from the input sentence.
// These two functions and the global variables and function declarations all served to create the expression step.
splitBySentence();

getLastWordInSentence();
// I get the matching words from the input that share a consonant with the expression word.
matchConsonants();
// I get the matching words from the input that share a vowel with the expression word.
matchVowels();
// I open these two files which hold the secret sentence
ifstream readConsonants ("consonant.txt");
if (!readConsonants) { std::cerr<<"file error
consonant, main"; std::exit(1); }
ifstream readVowels ("vowel.txt");
if (!readVowels) { std::cerr<<"file error
vowel, main"; std::exit(1); }
// reads the consonant made secret message
if(countConsonantMatches != 0){
getline(readConsonants, readConsonantMatch);
cout << readConsonantMatch << endl << endl;
}
// reads the vowel made secret message
else if(countVowelMatches != 0){
getline(readVowels, readVowelMatch);
cout << readVowelMatch << endl << endl;
}
// reads this when there is no secret message
else
cout << "No secret message in the sentence" << endl << endl;

// I pause the console window so you can read the screen results
system ("pause");
}
_______________

Here is the program results;
The text in the readtext.txt file is; "Thanks for watching the video."
And here is the secret message the program displays;
"
for watching the video.

Press any key to continue . . .
"

And a retry using different text in the text file; "She is the best Catwoan for me."

"
She the best me.

Press any key to continue . . .
"

_____________________

The secret message gets to the point of what is being said. That's what its for. But the idea is now for showing my process from my "big AI invention thread", so I think you try the SW on some sentences and see if it does what I say it does. Use the DL link and try or compile the SW and then try it using some sentences from movie reviews or internet articles. Then post your results.


squarebear
posted 8/14/2012  14:41Send e-mail to userReply with quote
 
jeremy duncan wrote @ 8/14/2012 11:56:00 AM:
Use the DL link and try or compile the SW and then try it using some sentences from movie reviews or internet articles. Then post your results.

 
Nobody will do this, as comparing consonants in a sentence has no use.

Here is the program results;
The text in the readtext.txt file is; "Thanks for watching the video."
And here is the secret message the program displays;
"
for watching the video.

Press any key to continue . . .
"

And a retry using different text in the text file; "She is the best Catwoan for me."

"
She the best me.

Press any key to continue . . .
"

I ask again, what use is comparing consonants in a sentence. What practical use do you believe it has? I see no benefit or any use whatsoever to this "secret" message. It certainly has no bearing on the meaning of the sentence.

Last edited by squarebear @ 8/14/2012 2:44:00 PM

jeremy duncan
posted 8/14/2012  22:42Reply with quote
I previously wrote the secret message would have been put into a database, the secret message would be broken up into its char members, and the members would be equal to a int value.

The purpose was to go through with making the secret message, put it into the database, and the original message the secret message came from would be displayed when the secret message was used.

The idea was;
- input
- create secret message in database
input takes last word to create expression word, expression step
the rest of the words are used to compare, for the purpose of creating the secret message
the secret message is displayed, this is put into the database, and the secret message is displayed
- then, the idea was;
- a new secret message is made, but it joins, or glues together the input sentence to the database sentence. so that when the new secret message is made, it has been broken into char members which have int value.
then the database char values are compared to the new secret message char values, and the best match from the database is used as a output response to the input sentence.
- so the (input, program, output)
becomes (input, expression, use of expression value, output)
becomes (input, expression, glue, use of expression value, output),
and this becomes (input, expression, create secret message, display secret message) +
which becomes (input, expression, create secret message, compare with database char values, output string from the database with the best match of char values)
all to have relevant response from the program.
was that as simple as mud or what?

  1  
'Send Send email to user    Reply with quote Reply with quote    Edit message Edit message

Forums Home    Hal and other child machines    Alan and other chatbots    Language Mind and Consciousness  
Contact Us Terms of Use