I have written a script on this but it does not do the requisite job. My requirement is this:
1. I have two kinds of files each with different extensions. One set of files are *.dat (6000 unique DAT files all in one directory) and another set *.dic files (6000 unique DIC files in all in the same directory where DAT files are located)
2. The files only contain words all in new lines. For example:
1.dat contains something like this"
1.dic looks like this:
3. For every corresponding DAT file there is a DIC file. For 1.dat, I have 1.dic, 2.dat and 2.dic .......6000.dat and 6000.dic
4. What I want to do is to read every word from DIC files and search in the corresponding DAT file and find the number of times the word appears in the .dat file and write the result in .cnt file with the same number. For example:
1.dic contains 10 words, I read every word from 1.dic line by line and search in 1.dat as to how many times each word from 1.dic appears in 1.dat. Then I write the result (i.e. count values) in every line in 1.cnt. Similarly, I read every word in 2.dic line by line, search words in 2.dat and write the count values in 2.cnt. My 2.cnt should look something like this
i.e word in the first line (of 2.dic) appears 2 times in 2.dat. Same thing has to be done with all the 6000 files.
What I have done so far:
Last edited by Scott; 01-27-2011 at 01:03 PM..
Reason: Please use code tags
Now, Counting number of files that contain words stored in another file
Hi All,
Thanks for your replies.
Using some of the code above I have come up with a solution of my own to another problem using the same set of files.
What I want to do is to read every word from DIC files and search in "ALL" DAT files and find the "number" of DAT files that contain that word from the DIC file and store the result in FIL files. This means I have to only count once in the DAT files even if that word appears several times in that DAT file. For example:
1.dic contains 10 words, I read every word from 1.dic line by line and search in all DAT files as to how many DAT files contain that word from 1.dic. Then I write the result (i.e. count values) in every line in 1.fil. Similarly, I read every word in 2.dic line by line, search words in all DAT files and write the count values in 2.fil. My 2.fil should look something like this:
i.e word in the first line (of 2.dic) appears 20 times in all the DAT files (counting that word only once in all DAT files even if one DAT file contains that word several times). Same thing has to be done with all the 6000 DIC files.
Dear all,
I am working with names and I have a large file of names in which some words are written together (upto 4 or 5) and their corresponding single forms are also present in the word-list.
An example would make this clear
annamarie
mariechristine
johnsmith
johnjoseph smith
john
smith... (8 Replies)
Hi, Given below is the input file:
http://i53.tinypic.com/2vmvzb8.png
Given below is what the output file should look like:
http://i53.tinypic.com/1e6lfq.png
I know how to count the occurrence of 1 word from a file, but not all of them. Can someone help please? An explanation on the... (1 Reply)
Hello,
I have a complex problem. I have a file in which words have been joined together:
Theboy ranslowly
I want to be able to correctly split the words using a lookup file in which all the words occur:
the
boy
ran
slowly
slow
put
child
ly
The lookup file which is meant for look up... (21 Replies)
Hi All,
I have written a script on this but it does not do the requisite job. My requirement is this:
1. I have two kinds of files each with different extensions. One set of files are *.dat (6000 unique DAT files all in one directory) and another set *.dic files (6000 unique DIC files in... (1 Reply)
Hi Pls help in solving my doubt.Iam having file like below
file1.txt
priya
jenny
jenny
priya
raj
radhika
priya
bharti
bharti
Output required:
I need a output like count of repeated words with name for ex:
priya 3
jenny 2 (4 Replies)
Please find the below program. It contains the purpose of the program itself.
/* Program : Write a program to count the number of words in a given text file */
/* Date : 12-June-2010 */
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
int main( int argc, char *argv )
{... (6 Replies)
Hi
Is there a way to count the no. of words in all files in directory. All are text files.I use wc -w but somehow i am not getting the rite answer.
Is there an alternative.
Thanks in advance (9 Replies)
if i have a long list of data, with every line beginning with an ip-address, like this:
62.165.8.187 - - "GET /bestandnaam.html HTTP/1.1" 200 5848 "http://www.domeinnaam.nl/bestandnaam.html" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
how do i count which ip-adresses are mentioned... (3 Replies)
i want to count the number of words in a file and then redirect this to a file
echo 'total number of words=' wc -users>file
THis isnt working, anyone any ideas. (1 Reply)
I'm trying to figure out a way to count the number of words in the follwing file:
cal 2002 > file1
Is there anyway to do this without using wc but instead using the cut command? (1 Reply)