|
when using, just press enter after describing a word for it to return to main loop
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
struct elemento {
char valor[100];
struct elemento *prox;
struct elemento *ant;
struct elemento *down;
struct elemento *up;
struct elemento *backtostart;
};
typedef struct elemento ELEM;
ELEM *head = NULL;
int oldornew=0;
int wordexists=0;
void Speak(ELEM* start, char valor[100]);
void AddWord(ELEM* start, char valor[100]);
void DivideWordsforAdd(ELEM* start, char valor[100]);
void DivideWordsforSpeak(ELEM* start, char valor[100]);
void Hear(ELEM* start, char valor[100]);
void CheckifExist (ELEM* start, char valor[100]);
void Speak(ELEM* start, char valor[100]){
int newword=0;
ELEM *elem = start->prox;
while(elem->prox!=NULL){
elem=elem->prox;
}
while(elem){
int written=1;
for(int i=0;i<100;i++){
if(elem->valor[i]==valor[i] || valor[i]==0){
if(valor[i]==' ' || valor[i]==0){
break;
}
}else{
written=0;
}
}
if(written==1){
if (elem->down==NULL){
newword=1;
break;
}
}
elem=elem->ant;
}
if(newword==0){
elem=start->prox;
while(elem->prox!=NULL){
elem=elem->prox;
}
}
while (elem){
if (newword==1){
int num=0;
while(elem->valor[num]!=' '){
num++;
}
if (elem->down==NULL){
cout<<"Me: What is ";
for(int i=0;i<num;i++){
cout << elem->valor[i];
}
cout << " ?" << endl;
oldornew=1;
break;
}
}else{
int match=1;
for(int i=0;i<100;i++){
if (elem->valor[i]==valor[i] || valor[i]==0){
if(valor[i]==0 || valor[i]==' '){
break;
}
}else{
match=0;
}
}
if (match==1){
for (int i=0;i<100;i++){
if(elem->valor[i]!=' '){
cout << elem->valor[i];
}else{
cout<<": "<<endl;
break;
}
}
elem=elem->down;
while (elem->prox!=NULL){
elem=elem->prox;
}
while (elem){
for(int i=0;i<100;i++){
if(elem->valor[i]!=' ' || (elem->valor[i]==' ' && elem->valor[i+1]!=' ')){
cout<<elem->valor[i];
}
}
if (elem->ant==NULL){
break;
}
elem=elem->ant;
cout<<endl;
}
cout<<endl<<endl;
oldornew=0;
}
}
if (elem->up){
elem=elem->up;
}
elem = elem->ant;
}
cout<<endl;
if (oldornew==1){
Hear(elem,valor);
}
}
void AddWord(ELEM* start, char valor[100]){
ELEM *elem = (ELEM*)malloc(sizeof(ELEM));
if (oldornew==1){
if (valor[0]==0){
oldornew=0;
for(int i=0;i<100;i++){
if(valor[i]==0){
valor[i]=' ';
}
}
Hear(start->backtostart,valor);
}
for(int i=0;i<100;i++){
if(valor[i]==0){
valor[i]=' ';
}
}
for(int i=0;i<100;i++){
elem->valor[i]=' ';
}
for(int i=0;i<100;i++){
if (valor[i]==' '&& valor[i-1]==' '){
break;
}
elem->valor[i] = valor[i];
}
elem->down=NULL;
elem->ant=NULL;
elem->up=start;
if (start->down==NULL){
elem->prox=NULL;
}else{
elem->prox=start->down;
elem->prox->ant=elem;
}
start->down=elem;
Hear(start,valor);
}else{
for(int i=0;i<100;i++){
if(valor[i]==0){
valor[i]=' ';
}
}
for(int i=0;i<100;i++){
elem->valor[i]=' ';
}
for(int i=0;i<100;i++){
if (valor[i]==' ' && valor[i-1]==' '){
break;
}
elem->valor[i] = valor[i];
}
elem->down=NULL;
elem->up=NULL;
elem->ant=NULL;
if (start->prox!=NULL){
elem->prox=start->prox;
elem->prox->ant=elem;
}else{
elem->prox=NULL;
}
elem->backtostart=start;
start->prox=elem;
}
}
void CheckifExist(ELEM* start, char valor[100]){
int same=0;
int checkfornew=1;
ELEM* elem=start->prox;
while(elem){
for(int i=0;i<100;i++){
if(elem->valor[i]==valor[i] || valor[i]==0){
same++;
if (valor[i]==0 || valor[i]==' '){
checkfornew=0;
break;
}
}else{
break;
}
}
elem=elem->prox;
}
if (checkfornew==1){
wordexists=1;
return;
}else{
wordexists=0;
}
}
void DivideWordsforSpeak(ELEM* start,char valor[100]){
char word[100];
int k=0;
for(int i=0;i<100;i++){
word[k]=valor[i];
if (valor[i]==' '){
if (valor[i-1]!=' '){
Speak(start,word);
for(int j=0;j<i;j++){
word[j]=' ';
}
}
k=-1;
}
k++;
}
Hear(start,valor);
}
void DivideWordsforAdd(ELEM* start, char valor[100]){
if (oldornew==1){
AddWord(start,valor);
}else{
char word[100];
int k=0;
for(int i=0;i<100;i++){
word[k]=valor[i];
if (valor[i]==' '){
if (valor[i-1]!=' '){
CheckifExist(start,word);
if (wordexists==1){
AddWord(start,word);
}
for(int j=0;j<i;j++){
word[j]=' ';
}
}
k=-1;
}
k++;
}
DivideWordsforSpeak(start,valor);
}
}
void Hear(ELEM* start, char valor[100]){
cout<<"You: ";
char x[100];
for(int i=0;i<100;i++){
x[i]=' ';
}
cin.getline(x,100);
cout << endl;
DivideWordsforAdd(start,x);
}
int main()
{
head = (ELEM*)malloc(sizeof(ELEM));
head->valor[0] = 's';
head->valor[1] = 't';
head->valor[2] = 'a';
head->valor[3] = 'r';
head->valor[4] = 't';
head->prox=NULL;
head->ant=NULL;
head->down=NULL;
head->up=NULL;
head->backtostart=NULL;
cout << "Hello! I am AI to talk." << endl << endl << "You: ";
char x[100];
for(int i=0;i<100;i++){
x[i]=' ';
}
cin.getline(x,100);
cout << endl;
DivideWordsforAdd(head,x);
return 0;
}
|
|
|
|
|
Maybe you had intended to write an article?
|
|
|
|
|
Why should we use it at the first place?
"The only place where Success comes before Work is in the dictionary." Vidal Sassoon, 1928 - 2012
|
|
|
|
|
'Cos it's AI innit? Gorra literally use AI aintcha?
Mind you, I expected AI to be ... um ... a little cleverer than that!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OriginalGriff wrote: Mind you, I expected AI to be ... um ... a little cleverer than that!
Why?! Haven't you learned nothing in QA?
"The only place where Success comes before Work is in the dictionary." Vidal Sassoon, 1928 - 2012
|
|
|
|
|
QA is pretty full of "Artificial", but there is little sign of "Intelligence"!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
Certainly not real intelligence.
|
|
|
|
|
But pretty close to it...
"The only place where Success comes before Work is in the dictionary." Vidal Sassoon, 1928 - 2012
|
|
|
|
|
By today's standards maybe.
|
|
|
|
|
What happens if I enter "42" or "liquid nitrogen"?
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
A CListCtrl explodes.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
I just did and ended up here.
|
|
|
|
|
Welcome!!!
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Quote: "Hello! I am AI to talk."
Needs more work.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Found out lately that Windows has a timer/stopwatch (Universal App?) thingy in it. Cool, I'll use it! But wait, it doesn't make a noise when the time is up. Why? Because they decided that all (Universal Apps) share the same setting, and you must allow all to hear one. Of course I disabled that when installing this box a year ago, because I don't want to hear a beep every time something changes. But it would be nice to hear alarms and timers.
Tempted to use the word 'idiots.' Usability going backwards.
That's all. Gripe's over. Have a good day!
|
|
|
|
|
Then you will have to write a Universal Filter app that can filter out certain sources
|
|
|
|
|
There is probably as much chance of me doing that as there is of you doing that! A big Zero!
|
|
|
|
|
Ash sound durbatulûk,
ash sound gimbatul,
Ash sound thrakatulûk
agh burzum-ishi krimpatul.
|
|
|
|
|
|
Had to do some googling! I lose a thousand geek points! And what's with you, not knowing the words for 'operating system?' Minus a hundred for that!
|
|
|
|
|
David O'Neil wrote: Tempted to use the word 'idiots.' Use it, using only "idiots" to describe some of the ing moronic piece of sh... they are doing lately is still a nice description.
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Need a voice (text to speech) option: "At the tone ...", or "WAKE UP!!", etc.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
This is about file systems in general, although with a primary emphasis on NTFS:
If you are expecting to stor a huge number of files - in the order of 100 k or more - on a disk, is there any significant advantage of spreading them over a number of subdirectories (based on some sort of hash)? Or are modern file systems capable of handling a huge number of files in a single level directory?`
If there are reasons to distribute the files over a series of subdirectories, what are the reasons (/explanations) why it would be an advantage?
Is this differnent e.g among differnt FAT variants, and with NTFS?
|
|
|
|