Download - Implementation of computer dictionary
8/7/2019 Implementation of computer dictionary
http://slidepdf.com/reader/full/implementation-of-computer-dictionary 1/17
Lovely Professional
University
Topic: Implementation of computer
dictionary
Submitted to:
Submitted by:
8/7/2019 Implementation of computer dictionary
http://slidepdf.com/reader/full/implementation-of-computer-dictionary 2/17
Mr. Deepak Prashar
Surjeet singh
D.S. LECT.
RM1801A08
10802849
B.Tech(C.S
.E)
………….COMPUTERDICTIONARY…………………A dictionary or wordbook is a collection of words in one or morespecific languages, often listed alphabetically , with usageinformation, definitions , etymologies, phonetics, pronunciations, andother information;or a book of words in one language with their equivalents in another, also known as a lexicon .According to Nielsen2008 a dictionary may be regarded as a L exicographical product thatis characterised by three significant features:
(1) it has been prepared for one or more functions;
(2) it contains data that have been selected for the purpose of fulfillingthose functions; and
(3) its lexicographic structures link and establish relationshipsbetween the data so that they can meet the needs of users and fulfilthe functions of the dictionary.
Further, each word may have multiple meanings. A dictionarytypically includes each separate meaning in the order of mostcommon usage.
In many languages, words can appear in many different forms, but
only the undeclined or unconjugated form appears as the headword inmost dictionaries. Dictionaries are most commonly found in the form
8/7/2019 Implementation of computer dictionary
http://slidepdf.com/reader/full/implementation-of-computer-dictionary 3/17
of a book, but some newer dictionaries, like StarDict and the NewOxford American Dictionary are dictionary software running onPDAs or computers . There are also many online dictionariesaccessible via the Internet .
Variations between dictionaries
Prescription and description
Lexicographers apply two basic philosophies to the defining of words:prescriptive or descriptive . Noah Webster , intent on forging a distinctidentity for the American language, altered spellings and accentuated
differences in meaning and pronunciation of some words. This is whyAmerican English now uses the spelling color while the rest of theEnglish-speaking world prefers colour . (Similarly, British English subsequently underwent a few spelling changes that did not affectAmerican English; see further at American and British Englishspelling differences .) Large 20th-century dictionaries such as theOxford English Dictionary (OED) and Webster's Third aredescriptive, and attempt to describe the actual use of words.
A dictionary open at the word " Internet ", viewedthrough a lens
While descriptivists argue that prescriptivism is an unnatural attemptto dictate usage or curtail change, prescriptivists argue that toindiscriminately document "improper" or "inferior" usages sanctions
those usages by default and causes language to deteriorate. Althoughthe debate can become very heated, only a small number of
8/7/2019 Implementation of computer dictionary
http://slidepdf.com/reader/full/implementation-of-computer-dictionary 4/17
controversial words are usually affected. But the softening of usagenotations, from the previous edition, for two words, ain't andirregardless, out of over 450,000 in Webster's Third in 1961, wasenough to provoke outrage among many with prescriptivist leanings,who branded the dictionary as "permissive."
The prescriptive/descriptive issue has been given much considerationin modern times. Most dictionaries of English now apply thedescriptive method to a word's definition, and then, outside of thedefinition itself, add information alerting readers to attitudes whichmay influence their choices on words often considered vulgar,offensive, erroneous, or easily confused. Merriam-Webster is subtle,only adding italicized notations such as, sometimes offensive or nonstand (nonstandard.) American Heritage goes further, discussingissues separately in numerous "usage notes." Encarta provides similar notes, but is more prescriptive, offering warnings and admonitionsagainst the use of certain words considered by many to be offensiveor illiterate, such as, "an offensive term for..." or "a taboo termmeaning..."
Because of the widespread use of dictionaries, and their acceptance bymany as language authorities, their treatment of the language doesaffect usage to some degree, even the most descriptive dictionariesproviding conservative continuity. In the long run, however, themeanings of words in English are primarily determined by usage, andthe language is being changed and created every day. As Jorge LuisBorges says in the prologue to "El otro, el mismo": " It is oftenforgotten that (dictionaries) are artificial repositories, put together
well after the languages they define. The roots of language areirrational and of a magical nature. "
8/7/2019 Implementation of computer dictionary
http://slidepdf.com/reader/full/implementation-of-computer-dictionary 5/17
CODING OF COMPUTER DICTIONARY (first we
have to input the words to store them)#include <stdio.h> //standard I/p andO/p
#include<iostream.h>
#include <conio.h>
#include <string.h>#include <stdlib.h> // for standardlibrary
#include<dos.h> //to store the wordsin memory
#define LEFT 1
#define RIGHT 2
struct node
{
char word[20],meaning[100];
8/7/2019 Implementation of computer dictionary
http://slidepdf.com/reader/full/implementation-of-computer-dictionary 6/17
node *left,*right;
};
node *maketree(char[],char[]);
node* treefromfile();
void filefromtree(node*);
void addword(node*,char[],char[]);
void seperateword(char[],char[],char[]);
void displayall(node*);
node* bsearch(node*,char[]);
void showmenu();
FILE *file_ptr;
void prog()
{
clrscr();
char word[20],meaning[100];
int menuchoice;
node *temp;
temp=treefromfile();
if(temp==NULL)
8/7/2019 Implementation of computer dictionary
http://slidepdf.com/reader/full/implementation-of-computer-dictionary 7/17
{
printf("File does not exist or dictionary isempty...");
getch();
}
while(1)
{
clrscr();showmenu();
scanf("%d",&menuchoice);
switch(menuchoice)
{
case 1:printf("Enter word : ");
scanf("%s",word);
printf("Enter meaning : " );
flushall();
gets(meaning);
if(temp==NULL)
temp=maketree(word,meaning);
else
addword(temp,word,meaning);
break;
8/7/2019 Implementation of computer dictionary
http://slidepdf.com/reader/full/implementation-of-computer-dictionary 8/17
case 2:if(temp==NULL)
printf("The dictionary is empty...");
else{
printf("Find meaning of : ");
flushall();
gets(word);
node *t;
t=bsearch(temp,word);
if(t==NULL)
printf("Word not found...");
else
{
printf("%s : ",t->word);
puts(t->meaning);
}
}
getch();
break;
case 3:if(temp==NULL)
printf("Dictionary is empty...");
else
8/7/2019 Implementation of computer dictionary
http://slidepdf.com/reader/full/implementation-of-computer-dictionary 9/17
displayall(temp);
getch();
break;case 4:filefromtree(temp);
exit(1);
break;
default:cout<<"Enter Again";
delay(1000);
prog();
break;
}
}
}
void showmenu()
{
printf(" COMPUTER DICTIONARY");
printf("[1]. Add a word.");
printf("[2]. Find meaning.");
printf("[3]. Display all.");
printf("[4]. Save and Close.\nEnter Choice");
}
node* treefromfile()
8/7/2019 Implementation of computer dictionary
http://slidepdf.com/reader/full/implementation-of-computer-dictionary 10/17
{
node *ptree=NULL;
char word[20],meaning[100],str[120],*i;int flags=0;
file_ptr=fopen("C:\dict.anu","r");
if(file_ptr==NULL)
ptree=NULL;
else
{
while(!feof(file_ptr))
{
i=fgets(str,120,file_ptr);
if(i==NULL)
break;
seperateword(str,word,meaning);
if(flags==0)
{
ptree=maketree(word,meaning);
flags=1;
}
else
addword(ptree,word,meaning);
8/7/2019 Implementation of computer dictionary
http://slidepdf.com/reader/full/implementation-of-computer-dictionary 11/17
}
fclose(file_ptr);}
return ptree;
}
node* maketree(char w[],char m[])
{
node *p;
p=new node;
strcpy(p->word,w);
strcpy(p->meaning,m);
p->left=NULL;
p->right=NULL;
return p;
}
void seperateword(char str[],char w[],char m[])
{
int i,j;
for(i=0;str[i]!=' ';i++)
w[i]=str[i];
8/7/2019 Implementation of computer dictionary
http://slidepdf.com/reader/full/implementation-of-computer-dictionary 12/17
w[i++]=NULL; //Append the null and skip thespace.
for(j=0;str[i]!=' ';i++,j++)
{
m[j]=str[i];
}
m[j]=NULL;
}void addword(node *tree,char word[],charmeaning[])
{
node *p,*q;
p=q=tree;while(strcmp(word,p->word)!=0 && p!=NULL)
{
q=p;
if(strcmp(word,p->word)<0)
p=p->left;
else
p=p->right;
}
if(strcmp(word,q->word)==0)
{
8/7/2019 Implementation of computer dictionary
http://slidepdf.com/reader/full/implementation-of-computer-dictionary 13/17
printf("This word already exists...");
delay(1000);
}else if(strcmp(word,q->word)<0)
q->left=maketree(word,meaning);
else
q->right=maketree(word,meaning);
}
node* bsearch(node *tree,char word[])
{
node *q;
q=tree;
while(q!=NULL)
{
//p=q;
if(strcmp(word,q->word)<0)
q=q->left;
else if(strcmp(word,q->word)>0)
q=q->right;
if(strcmp(word,q->word)==0)
break;
}
8/7/2019 Implementation of computer dictionary
http://slidepdf.com/reader/full/implementation-of-computer-dictionary 14/17
return q;
}
void filefromtree(node *tree){
void travandwrite(node*);
file_ptr=fopen("C:\dict.anu","w");
if(file_ptr==NULL)
{
printf("Cannot open file for writing data...");
}
else
if(tree==NULL)
{
if(tree!=NULL)
{
travandwrite(tree);
}
fclose(file_ptr); //Close the file anyway.
}
}
void travandwrite(node *tree)
{
8/7/2019 Implementation of computer dictionary
http://slidepdf.com/reader/full/implementation-of-computer-dictionary 15/17
if(tree!=NULL)
{
fprintf(file_ptr,"%s %s",tree->word,tree->meaning);
travandwrite(tree->left);
travandwrite(tree->right);
}
}void displayall(node *tree)
{
if(tree!=NULL)
{
displayall(tree->left);
printf("%s : %s",tree->word,tree->meaning);
displayall(tree->right);
}
}
void intro()
{
int i;
clrscr();
8/7/2019 Implementation of computer dictionary
http://slidepdf.com/reader/full/implementation-of-computer-dictionary 16/17
gotoxy(20,20);
cout<<"DICTIONARY LOADING";
for(i=0;i<50;i++){
gotoxy(15+i,21);
cout<<"???";
gotoxy(20,22);
cout<<2*i<<"% completed";
delay(150);
}
gotoxy(20,20);
cout<<"DICTIONARY LOADING COMPLETED";
clrscr();
}
void main()
{
clrscr();
intro();
prog();
}
8/7/2019 Implementation of computer dictionary
http://slidepdf.com/reader/full/implementation-of-computer-dictionary 17/17