Question

please i need help with the pseudocode and actual code of making a concordance program using...

please i need help with the pseudocode and actual code of making a concordance program using C programming language
0 0
Add a comment Improve this question Transcribed image text
Answer #1
Here is the C code #include <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> #include "ap_getline.h" #include "uthash.h" /* a struct to store word -> count mappings */ typedef struct {     char* word;     int count;     UT_hash_handle hh; } word_count_t; /* function to compare two word_count_t structs by count */ int compare_count(word_count_t* a, word_count_t* b) {     return (a->count - b->count); } int main() {     word_count_t* concordance = NULL;     word_count_t* word_count = NULL;     word_count_t* tmp = NULL;     char* line;     int len;     while (!feof(stdin)) {         len = ap_getline(&line, stdin);         /* iterate through each word in line */         char* word;         word = strtok(line, " \n");         while (word != NULL) {             /* find word count in hash */             HASH_FIND_STR(concordance, word, word_count);             /* if found, update count */             if (word_count != NULL) {                 word_count->count++;             }             /* otherwise, alloc a new structure and add it to the hash */             else {                 word_count = (word_count_t*)malloc(sizeof(word_count_t));                 /* malloc word, copy into it */                 word_count->word = (char*)malloc(strlen(word)+1);                 strcpy(word_count->word, word);                 word_count->count = 1;                 HASH_ADD_KEYPTR(hh, concordance, word_count->word,                         strlen(word_count->word), word_count);             }             word = strtok(NULL, " \n");         }         free(line);     }     /* sort by count */     HASH_SORT(concordance, compare_count);     /* iterate through the hash, deleting and freeing as we go */     HASH_ITER(hh, concordance, word_count, tmp) {         printf("%s: %d\n", word_count->word, word_count->count);         HASH_DEL(concordance, word_count);         free(word_count->word);         free(word_count);     }     return 0; } 
Add a comment
Know the answer?
Add Answer to:
please i need help with the pseudocode and actual code of making a concordance program using...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need help writing a C programming code. I am trying to create a program that...

    I need help writing a C programming code. I am trying to create a program that returns ANY given number's decimal value as an Integer (Whole number). Examples: User input: 0.35 Output: 35 User input: 1.465 Output: 465 User input: 10.6054 Output: 6054

  • I need help creating program for the Test_Bisection pseudocode. I need to find a root for...

    I need help creating program for the Test_Bisection pseudocode. I need to find a root for each function f and g and get the output below. Pseudocode Now let's construct pseudocode to carry out this procedure. We shall not try to create a piece of high-quality software with many "bells and whistles,” but we write the pseudocode in the form of a procedure for general use. This allows the reader an opportunity to review how a main program and one...

  • I need help using this given program and making it not create a hole in the...

    I need help using this given program and making it not create a hole in the file. Once compiled and executed this program creates a file that is 16394 bytes but has a hole in it. I need to make a file WITHOUT A HOLE that is the same size (16394 bytes) from this program. I know I need to remove/change the lseek portion. I just dont know what to replace it with. A write function? Given Program: #include "apue.h"...

  • C++ programming language , I need help writing the code . Please explain if you can...

    C++ programming language , I need help writing the code . Please explain if you can . Exercise 10: Unit conversion (10 points) Write a console program that converts meters into feet and inches. The program starts by asking the user for a measurement in meters. The program should accept a floating point number. After getting the number, the program computes the number of feet and inches equal to the specified number of meters. The program outputs feet and inches...

  • SOLVE THE PSEUDOCODE ONLY. PLEASE DO NOT CODE IT. PROGRAMMING LOGIC AND DESIGN. JAVA. Q.6.2 Using...

    SOLVE THE PSEUDOCODE ONLY. PLEASE DO NOT CODE IT. PROGRAMMING LOGIC AND DESIGN. JAVA. Q.6.2 Using pseudocode, write the code that will perform the necessary file operations as described in the short scenario below: "During registration at a college, student's details will be captured by a staff member and written to a file called "student Details.dat". The following student details will be captured: name, surname, student Number, registered Course. The staff member will be prompted for the student details. After...

  • PLEASE DO IN PYTHON Program 2: Design (pseudocode) and implement (source code) a program (name it...

    PLEASE DO IN PYTHON Program 2: Design (pseudocode) and implement (source code) a program (name it FeetMeters) to display a conversion tables for feet and meter as show below. Document your code and properly. Feet Meter 1.0 0.305 2.0 0.610 3.0 0.915 . . . . . . 19.0 5.7.95 20.0 6.100 Meter Feet 1.0 3.279 2.0 6.558 3.0 9.837 . . . . . . 19.0 62.301 20.0 65.574 The program defines the following methods: Method feetToMeter() converts from...

  • Python 3.6 I need the code ready to run using GUI programming Write a program for...

    Python 3.6 I need the code ready to run using GUI programming Write a program for the Knight's Tour problem. Your program should let the user move a knight to any starting square and click the Solve button to animate a knight moving along the path, as shown below.

  • I need help with ARM assembly program : Using the following code as basic : 1...

    I need help with ARM assembly program : Using the following code as basic : 1 ) Write a program code that is able to calculate the following : Result = A + ( B * C ) - D Place the result as the return value so you can print it afterwards in the command prompt. 2) This time, use MLA instruction to reduce the number of instructions in question 1. Place the result as the return value so...

  • How do i write the pseudocode for this java code? First, write out pseudocode, and then create a program to help you by accomplishing the following tasks: :  Use command line interface to ask the use...

    How do i write the pseudocode for this java code? First, write out pseudocode, and then create a program to help you by accomplishing the following tasks: :  Use command line interface to ask the user to input the following. ○ How many apples are on hand ○ How many apples should be in stock ○ How many oranges are on hand ○ How many oranges should be in stock  Perform an operation to determine how many of...

  • Write pseudocode and the write the source code in C++, thanks! Program 0: Insulted yet? Most...

    Write pseudocode and the write the source code in C++, thanks! Program 0: Insulted yet? Most people get harassed by telemarketers, so for your warmup question, you're going to design (pseudocode) and write (source code) a program that generates (clean) insults at random. The program must have a function that takes in the name of a person and prints out an insult directed to them. Further, the program should ask if the person has had enough insults and continue until...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT