how to find whether the input string is meaningful

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Chuthu
    New Member
    • Jan 2008
    • 8

    how to find whether the input string is meaningful

    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?
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    Originally posted by Chuthu
    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?

    Comment

    • Chuthu
      New Member
      • Jan 2008
      • 8

      #3
      Originally posted by sicarie
      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?

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        Originally posted by Chuthu
        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.

        Comment

        • Chuthu
          New Member
          • Jan 2008
          • 8

          #5
          Originally posted by weaknessforcats
          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?

          Comment

          • weaknessforcats
            Recognized Expert Expert
            • Mar 2007
            • 9214

            #6
            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.

            Comment

            • Chuthu
              New Member
              • Jan 2008
              • 8

              #7
              Originally posted by weaknessforcats
              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?

              Comment

              • weaknessforcats
                Recognized Expert Expert
                • Mar 2007
                • 9214

                #8
                You just use a file rather than memory for your tree:

                [code=cpp]
                struct Word
                {
                char theWord[20];
                char theDefinition[500];
                size_t theLocation; //seek to this for theWord
                //Left:
                size_t Left; //seek to this for the next word less in sequence
                //Right
                size_t Right; //seek to this for the next word greater in sequence


                };
                [/code]

                New words are always added to the end of the file.

                Off you go, and your tree is now a disc file.

                Comment

                Working...