Text Analytics Library
a collection of routines for simple textual analysis
 All Files Functions Typedefs
Functions
analytics.h File Reference

Routines to help analyze text input. More...

#include <stdio.h>
#include "word_list.h"
#include "word_map.h"

Go to the source code of this file.

Functions

word_list_t split_words (FILE *is)
 extract a list of words from a stream More...
 
word_map_t count_words (const word_list_t words)
 count occurrences of words in a list More...
 
void sort_counted_words (word_map_t wm, int opt)
 sort a counted word list More...
 

Detailed Description

Routines to help analyze text input.

Function Documentation

word_map_t count_words ( const word_list_t  words)

count occurrences of words in a list

Parameters
wordsa list of words
Returns
an initialized list of word,integer pairs contained in a word_map_t

initialization of the word_map_t structure includes dynamic memory allocation. It is the caller's responsibility to call word_map_free on the returned object when finished with it.

void sort_counted_words ( word_map_t  wm,
int  opt 
)

sort a counted word list

Sorts first by numerical value, then alphabetically. The sort is done "in place", i.e. the word_map_t object is modified.

Parameters
wmthe word map object to sort
optsort options. May be either AMAP_SORT_ASCENDING or AMAP_SORT_DESCENDING.
word_list_t split_words ( FILE *  is)

extract a list of words from a stream

Parameters
isinput FILE stream
Returns
an initialized word_list_t structure containing the words extracted from the stream

initialization of the word_list_t structure includes dynamic memory allocation. It is the caller's responsibility to call word_list_free on the returned object when finished with it.