defs.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef __defs_h__
  2. #define __defs_h__
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5. #include <ctype.h>
  6. #include "sti/sti.h"
  7. #define FOR(a, limit) for(long a = 0; a < limit; a++)
  8. #define MAX(a, b) ((a) > (b) ? (a) : (b))
  9. #define MIN(a, b) ((a) < (b) ? (a) : (b))
  10. typedef unsigned char u8;
  11. typedef struct {
  12. int n_into_book;
  13. int num_words;
  14. int num_sentences;
  15. int num_paragraphs;
  16. int start_word;
  17. int start_sentence;
  18. int start_paragraph;
  19. } chapter_info;
  20. typedef struct {
  21. int n_into_book;
  22. int n_into_chapter;
  23. int num_words;
  24. int num_sentences;
  25. int start_word;
  26. int start_sentence;
  27. } paragraph_info;
  28. typedef struct {
  29. int n_into_book;
  30. int n_into_chapter;
  31. int n_into_paragraph;
  32. int num_words;
  33. int start_word;
  34. int* word_list;
  35. int num_unique_words;
  36. int* unique_word_list; // sorted
  37. } sentence_info;
  38. typedef struct {
  39. char* text;
  40. int ordinal;
  41. int count;
  42. int starts_sentence;
  43. int starts_paragraph;
  44. int starts_chapter;
  45. float* follows; // this uses about 220mb
  46. } word_stats;
  47. typedef struct {
  48. HT(word_stats*) word_lookup;
  49. long words_alloc;
  50. long words_len;
  51. word_stats* words;
  52. long word_list_alloc;
  53. long word_list_len;
  54. int* word_list;
  55. long sentence_list_alloc;
  56. long sentence_list_len;
  57. sentence_info* sentence_list;
  58. long paragraph_list_alloc;
  59. long paragraph_list_len;
  60. paragraph_info* paragraph_list;
  61. long chapter_list_alloc;
  62. long chapter_list_len;
  63. chapter_info* chapter_list;
  64. } book_info;
  65. #endif //__defs_h__