472,993 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,993 software developers and data experts.

how to find whether the input string is meaningful

8
I'm writing a C program where the user enters a string and the program aims at finding whether the input string is meaningful English word or not. Comparing each and every input word with the dictionary words kept in another file is highly impossible. Is there any another way to do this?
Jan 11 '08 #1
7 3735
sicarie
4,677 Expert Mod 4TB
I'm writing a C program where the user enters a string and the program aims at finding whether the input string is meaningful English word or not. Comparing each and every input word with the dictionary words kept in another file is highly impossible. Is there any another way to do this?
Why is that impossible?
Jan 11 '08 #2
Chuthu
8
Why is that impossible?
What I assumed was to keep a list of all meaningful English words in a separate text file and get the usr input.The user may enter any text and any amount of text at run rime. To check if each entered word is meaningful or not, it has to be compared with every word in the text file and if it matches, it's meaningful or else it's not. But is it really feasible to have all the words in the dictionary (which may run to lakhs of words) in a file and check for text matching? Is there a better alternative for this?
Jan 11 '08 #3
weaknessforcats
9,208 Expert Mod 8TB
To check if each entered word is meaningful or not, it has to be compared with every word in the text file
Yes there is. It comes down to your lookup. If a words starts with H, maybe you only check the words that start with H and not then entire dictionary.

Here's where functions can help you.

You an write a Lookup() that does a complete dictionary search and call it to find a word. Later you can rewrite Lookup() to do a more efficicent search. Then all you need to is recompile your code to use the new function.
Jan 11 '08 #4
Chuthu
8
Yes there is. It comes down to your lookup. If a words starts with H, maybe you only check the words that start with H and not then entire dictionary.

Here's where functions can help you.

You an write a Lookup() that does a complete dictionary search and call it to find a word. Later you can rewrite Lookup() to do a more efficicent search. Then all you need to is recompile your code to use the new function.

Okay. Searching can be narrowed down. But can all the words found in the dictionary be made to fit in the file?
Jan 12 '08 #5
weaknessforcats
9,208 Expert Mod 8TB
Probably. Do understand a dictionary does not have to be in one file. You could have a lot of files and those files could be organized as trees so you don't have to search the entire file evey time.
Jan 12 '08 #6
Chuthu
8
Probably. Do understand a dictionary does not have to be in one file. You could have a lot of files and those files could be organized as trees so you don't have to search the entire file evey time.
Can you please tell me how to organize the collection of files as a tree hierarchy?
Jan 13 '08 #7
weaknessforcats
9,208 Expert Mod 8TB
You just use a file rather than memory for your tree:

Expand|Select|Wrap|Line Numbers
  1. struct Word
  2. {
  3.      char theWord[20];
  4.      char theDefinition[500];
  5.      size_t  theLocation;           //seek to this for theWord
  6.      //Left:
  7.      size_t   Left;                    //seek to this for the next word less in sequence
  8.      //Right
  9.     size_t    Right;                  //seek to this for the next word greater in sequence
  10.  
  11.  
  12. };
  13.  
New words are always added to the end of the file.

Off you go, and your tree is now a disc file.
Jan 13 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Paul E Collins | last post by:
Given a string variable (form input), how can I determine whether it represents a valid integer? is_numeric is true for floats as well as integers, and is_int always fails on a string. P.
4
by: Johannes Busse | last post by:
Hello NG, I'm struggling with the following problem. I think can be solved quite easily (in fact it should be a FAQ), but it seems that I cannot solve it myself :-( my source looks like...
3
by: zhi lin | last post by:
hi, guys I am doing a c program which need me to print out the error message during the file input, suppose we need to read in a struct { int pid; char *name; char *skill; }
14
by: Stegano | last post by:
I am learning C Programming after working with Java for 5 years. I want to know where can I find the source files for C language itself. For example strcat is a function, which concatenates two...
3
by: David Marsh | last post by:
The program calculates the continued fraction representation of the input: #include <stdio.h> #include <stdlib.h> int main(int argc, char* argv) { double diff, n, r, i; if(argc != 2)...
4
by: cdrom205 | last post by:
static void MDString ( unsigned char *input) { MD5_CTX context; unsigned char digest; unsigned int len = sizeof(input);//strlen (const char*) md5.MD5Init (&context); md5.MD5Update...
34
by: priyanka | last post by:
Hi, I was wondering if we could parse or do something in the executable( whose source language was C). How can I use some scripting language like perl/python to find out the information about...
2
by: willie | last post by:
Martin v. Löwis: Thanks for the thorough explanation. One last question about terminology then I'll go away :) What is the proper way to describe "ustr" below? <type 'unicode'>
16
by: Lastwebpage | last post by:
Hello, I am little surprised about the following: <a href="#" ... I found some lines about the href tag for a site should point to an name or in XHTML to an ID, but in both cases this seems to...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.