Basically, you have two files... source.txt and dictionary.txt. i want the program to look in source.txt for any matches with words in dictionary.com... then just makes result.txt which states which matches have been made "i.e carrot apple elf" etc
How would i make/find this program? Thanks.
withdraw
Aug 29 2004, 09:42 AM
I think this might do it http://www.guiffy.com/ but I havent tried it out yet.... But it works on almost any platform!!
nuorder
Aug 29 2004, 09:48 AM
is source.txt a lot of sentences or just a list of words with a newline after each word
There are hidden words in the file, i want a program that searches the file for words.
nuorder
Aug 29 2004, 10:23 AM
ok heres a rough idea of what u need the code probly needs to be redone cos i havnt check it much but it worked with the small amount of data i gave it
CODE
#include <fstream.h> #include <stdlib.h> #include <string.h> #define MAX 255
void main () { ifstream in1; ifstream in2; ofstream out; int cur1,cur2; char str_in1[MAX]; char str_in2[MAX]; char * c;
//loops to look for the strings while ( (cur1=in1.peek()) != EOF ) { in1.getline(str_in1,MAX,'\n');
//look in the dictionary - i shouldnt really be opening this file over and over but it works in2.open("dictionary.txt",ios::nocreate); while ( (cur2=in2.peek()) != EOF ) { in2.getline(str_in2,MAX,'\n'); cout << str_in2 << endl; c = strstr (str_in1,str_in2); //check if its there and output if (c != NULL) out << str_in2 << endl; } in2.close(); cout << "yo" << endl; } in1.close(); out.close(); }
also doesnt account for duplicate results in the search - but could be implemented without too much hassle
the VB eqivalent would basically be the same idea and use the instr() function to find the substring (dictionary) within the source string
epi
Aug 29 2004, 12:33 PM
Thanks I'm going to have a look through it and see if i can make sense of it, hehe..
BBQ CD
Aug 29 2004, 01:13 PM
maybe textpad (www.textpad.com) is the tool u're searching for, give it a try
n0n4m3
Sep 13 2004, 06:39 PM
well, i think i know a good program for you. it's called "remdupes 2" search for it via google, i'm sure you'll find it
it's easy to use, if there are any questions, ask me, maybe i can help you, but it's very easy to use...
cya noname
typecast
Sep 14 2004, 08:29 AM
You could easily do this task in perl. This should give you the idea how to do this:
# maybe you shouldn't do this with huge files :D @source=<$SOURCEFILE>;
while ( $testedword = <$WORDFILE> ) { chop $testedword; for (@source) { print "Matched $testedword in sourcefile\n" if /$testedWord/; } }
(This also doesn't count dublicate results, but it's also easy to implement this)
With bigger filez u could get a prob with "@source=<$SOURCEFILE>;". File could get to big for it and u would have to use 2 while loops, one loop within the other.
typecast
Sep 14 2004, 08:30 PM
QUOTE (z73 @ Sep 14 2004, 01:59 PM)
With bigger filez u could get a prob with "@source=<$SOURCEFILE>;". File could get to big for it and u would have to use 2 while loops, one loop within the other.
Yes, that's why i wrote:
# maybe you shouldn't do this with huge files
This peace of code should only give the idea of how to do this in perl.
z73
Sep 15 2004, 01:16 AM
QUOTE (typecast @ Sep 14 2004, 08:30 PM)
QUOTE (z73 @ Sep 14 2004, 01:59 PM)
With bigger filez u could get a prob with "@source=<$SOURCEFILE>;". File could get to big for it and u would have to use 2 while loops, one loop within the other.
Yes, that's why i wrote:
# maybe you shouldn't do this with huge files
This peace of code should only give the idea of how to do this in perl.
Heh i knew u know bout it perl is the best approach for this task. Ur suggestion was nice. Just tried to explain it to the others
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.