chinwag 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,23 @@
1
+ #ifndef __RB_CHINWAG_EXT_NNA6BCFM_H
2
+ #define __RB_CHINWAG_EXT_NNA6BCFM_H
3
+
4
+ #include <ruby.h>
5
+
6
+ #ifdef HAVE_RUBY_IO_H
7
+ #include <ruby/io.h>
8
+ #else
9
+ #include <rubyio.h>
10
+ #endif
11
+
12
+ #ifdef HAVE_RUBY_INTERN_H
13
+ #include <ruby/intern.h>
14
+ #else
15
+ #include <intern.h>
16
+ #endif
17
+
18
+ #include "chinwag.h"
19
+
20
+ extern VALUE m_chinwag;
21
+ extern VALUE c_cw_dict;
22
+
23
+ #endif
@@ -0,0 +1,4 @@
1
+ #include "seuss.h"
2
+
3
+ const char* const dict_seuss = "I,a,TV,am,an,as,at,be,by,do,go,he,if,in,is,it,me,my,no,of,oh,on,or,so,to,up,us,we,'em,Eek,Gox,Hoo,How,Ish,Joe,May,Moo,Ned,Pip,Pop,Who,Yop,act,aid,air,all,and,any,are,ask,bad,bed,bee,bet,big,bit,bow,box,bus,but,can,car,cat,cow,cup,cut,dad,day,did,die,dog,ear,eat,egg,end,fan,far,fat,fly,for,fox,fun,get,got,guy,had,ham,has,hat,her,hey,hid,him,his,hit,hop,hot,how,hte,ink,kid,lad,lag,let,lit,lot,low,mad,man,mat,may,met,mix,mot,net,new,not,now,off,oil,old,one,our,out,owl,own,pan,pat,pet,pin,pot,put,ran,red,rid,rot,run,sad,sat,saw,say,see,she,sit,six,sky,sun,ten,the,tie,tin,tip,too,top,toy,try,two,vim,was,way,wet,who,why,wig,win,won,yes,yet,yon,you,why,Boom,Bray,Buzz,Choo,Dopp,Fish,Gack,Grum,Gump,Kiss,Mike,Nook,Tick,Tock,Whos,Wump,Ying,Yink,Yopp,Zans,Zeds,Zeep,able,arms,away,back,ball,beak,beat,been,bell,bent,best,bike,bird,bite,blew,blow,blue,boat,boil,book,both,boys,bump,bust,cage,cake,call,came,cans,care,case,cats,chin,cold,comb,come,cook,cool,cork,dare,dark,days,dead,dear,deep,deft,dish,does,done,door,dope,dots,down,drop,dumb,dunk,dust,each,ears,east,eggs,even,ever,eyes,face,fail,fall,fame,fast,fear,feet,fell,felt,find,fine,fish,five,flew,flip,fool,foot,foul,four,from,full,game,gang,gave,give,glad,goat,gold,gone,good,gown,grab,grow,hair,hall,hand,hard,harm,haul,have,he's,head,hear,heat,help,here,hide,high,hike,hold,home,hook,hops,horn,hour,howl,hump,hung,into,it's,join,joys,jump,just,keen,kept,kind,kiss,kite,know,last,lead,leak,left,like,live,long,look,lose,lots,loud,made,mail,make,many,mean,meet,mess,milk,mind,mine,moon,more,most,move,much,must,name,near,neck,need,news,next,nine,noon,once,only,open,over,pace,pack,pail,pair,pans,park,pass,past,pets,pick,pink,play,plop,pool,poor,pull,quit,race,rain,rake,rang,read,rest,ride,ring,road,roar,rope,safe,said,sank,save,seem,seen,ship,shoe,show,shut,sing,sits,size,slow,snow,soar,soft,some,soon,sore,sort,sour,star,stay,step,stew,stop,such,sure,tact,tail,take,tall,tame,tell,than,that,them,then,they,thin,this,thus,till,time,tiny,told,took,tops,town,tree,true,turn,twas,upon,very,walk,wall,want,wave,well,went,were,west,what,when,wide,wild,will,wind,wing,wink,wire,wish,with,wood,work,yell,yelp,yipp,your,fear,Bixby,Blurp,Brown,Clark,Jo-Jo,Klopp,Knock,Lurch,Slump,Slurp,Yo-Yo,about,after,again,alarm,alive,alone,along,asked,birds,black,blame,blood,bones,books,brass,break,brush,bumps,burst,caged,can't,chirp,clean,clear,clock,comes,could,creek,cried,curls,doing,don't,drink,eagle,eight,elbow,every,extra,faint,favor,folks,found,funny,games,girls,going,great,green,grind,grows,gusts,hands,he'll,heads,heard,hello,hills,house,how's,humpf,juice,jumps,kicks,kinds,kites,knots,lasso,latte,light,likes,loose,makes,maybe,mayor,miles,mixed,mouse,mouth,named,never,night,noise,ought,pants,patch,perch,phone,piled,piped,place,plane,pouch,prove,prowl,quick,quiet,quite,raced,ready,right,roads,roped,sadly,Sally,saved,scare,seven,shake,shall,shame,share,sheep,shine,shoes,shook,shout,silly,sings,sleep,smack,small,smart,sneak,socks,soget,sorry,sough,sound,space,speak,speck,speed,spoke,stand,star,start,state,steer,stick,story,sunny,swift,swish,talks,teeth,thank,their,there,these,thick,thing,think,those,three,thump,tight,times,tired,today,toots,train,trees,trick,trunk,twerp,under,using,vigor,voice,we're,we've,where,while,white,who's,whole,whose,wings,won't,world,worry,would,young,mayor,'cause,Dibble,Friday,Horton,Sizzle,Splatt,across,afraid,almost,always,anyone,aren't,around,banner,barley,before,begged,behind,better,beyond,bigger,birdie,brains,brainy,breeze,bright,broken,bungle,called,cannot,chance,chased,choose,clocks,clover,coming,counts,course,darked,decide,didn't,dozens,easily,either,eleven,enough,escape,except,family,famous,finger,fliers,flight,floors,flower,flutes,footsy,forget,fought,friend,frying,gasped,gently,groans,happen,headed,helped,hidden,hither,holler,houses,indeed,inside,jungle,kettle,kindly,landed,life's,lifted,likely,little,lonely,looked,loudly,making,marked,matter,mauled,mighty,mostly,mother,noises,onward,opener,pearls,people,person,picked,placed,places,please,points,proved,racket,really,rooter,ruckus,rushed,scared,scored,scream,seeing,seemed,should,sights,simple,smiled,sprain,sticks,stones,stores,street,string,strong,summer,surely,that's,things,though,throat,thumps,toward,town's,tricks,uncles,voices,walked,wasn't,what's,who'll,who've,winner,wonder,yellow,you'll,you're,you've,smiled,spread,Buxbaum,Hoo Hoo,Moo Moo,Whisper,against,already,amounts,another,because,beeping,believe,between,bicycle,biggest,bipping,blasted,blowing,calling,carried,chances,cleared,clearly,climbed,clovers,country,cousins,crashed,darkest,despair,distant,disturb,dropped,drowned,enemies,engaged,existed,finally,fingers,flapped,friends,frowned,garbage,getting,goodbye,grabbed,greater,grocery,haircut,heights,howling,humpfed,hundred,hustled,in-laws,kettles,laughed,lighted,magical,managed,mayor's,meeting,monkeys,morning,mothers,neither,nothing,nowhere,oompahs,percent,perhaps,persons,playing,pleaded,plucked,plunged,protect,quickly,rattled,repairs,shaking,shirker,shouted,smashed,snapped,sneered,somehow,someone,squeaky,started,staying,stomach,stopped,strange,streets,strings,succeed,talking,there's,they'll,they're,they've,thought,through,thunder,tom-tom,trouble,useless,waiting,walking,weather,whether,whisper,whooped,wiggled,windows,working,yapping,yipping,Horton's,Mr. Gump,Sam-I-am,answered,anything,anywhere,battered,bazookas,bouncing,building,ceilings,chatting,children,churches,confused,creature,drinking,elephant,enjoying,everyone,fall-ish,flapping,friendly,goldfish,grateful,greabbed,greatest,hang-ups,humpfted,insisted,jungle's,kangaroo,mountain,murmured,nonsense,person's,planning,problems,remember,searched,shirking,shoulder,shouting,smallest,snatched,sneakers,speckhah,standing,starting,steaming,straight,suddenly,tattered,tea-pots,terrible,terribly,thankful,thousand,toenails,tomorrow,up-up-up,watching,weirdish,whatever,wherever,worrying,yourself,Buzz Buzz,Dopp Dopp,Fish Kiss,Grum Grum,Mr. Brown,Mr. Mayor,Tick Tock,Who-ville,afternoon,balancing,bellowing,boom-pahs,buildings,butterfly,certainly,clarinets,cranberry,dexterous,direction,happening,kangaroos,littlecar,millionth,mountains,peaceable,sincerely,small-ish,something,sometimes,somewhere,splashing,stretched,wonderful,Boom Bands,Uncle Jake,beezle-nut,discovered,elephant's,everywhere,frequently,playthings,prickle-ly,unpleasant,yourselves,guaranteed,hullabaloo,Blurp Blurp,Hoo Hoo Hoo,Knock Knock,Pop Pop Pop,Slurp Slurp,frightening,nonsensical,not-so-good,speck-voice,un-slumping,winning-est,wonderfully,Great Places,Hakken-Kraks,carryings-on,fun-in-a-box,kangaroos',Dibble Dibble,Sizzle Sizzle,Waiting Place,blackbottomed,break-necking,flip-flapping,Boom Boom Boom,Dopp Dopp Dopp,Grum Grum Grum,Jungle of Nool,black-bottomed,floor-to-floor,rocking-chairs,Hoo Hoo Hoo Hoo,Whisper Whisper,congratulations,Eiffelberg Tower,Vlad Vlad-i-koff,mind-maker-upper,Cock-a-Doodle-Doo,Klopp Klopp Klopp,Knock Knock Knock,Choo Choo Choo Chu,Wickersham Brothers,Splatt Splatt Splatt,Who-ville Town Square,hippopotamus chewing gum,right-and-three-quarters,Dibble Dibble Dibble Dopp,Dibble Dibble Dibble Dropp,Dibble Dibble Dibble Dibble,Dibble Dibble Dibble Dribble,Mordecai Ali Van Allen O'Shea,";
4
+ const unsigned dict_seuss_len = 1102;
@@ -0,0 +1,9 @@
1
+ #ifndef __SEUSS_2GYTCD1U_H
2
+ #define __SEUSS_2GYTCD1U_H
3
+
4
+ #include "chinwag.h"
5
+
6
+ extern const char* const dict_seuss;
7
+ extern const unsigned dict_seuss_len;
8
+
9
+ #endif
@@ -0,0 +1,53 @@
1
+ #include "tokenize.h"
2
+
3
+ U32 stringify_file(char** buffer, FILE* fp)
4
+ {
5
+ // setup
6
+ U64 sz = 0;
7
+
8
+ // determine file size and setup file buffer
9
+ fseek(fp, 0L, SEEK_END);
10
+ sz = ftell(fp);
11
+ fseek(fp, 0L, SEEK_SET);
12
+ *buffer = (char*)malloc(sizeof(char) * (sz + 1));
13
+ if(*buffer == NULL) return 0;
14
+
15
+ // read file into file buffer
16
+ size_t len = fread(*buffer, sizeof(char), sz, fp);
17
+ if (len == 0) fputs("Error reading file", stderr);
18
+ else (*buffer)[++len] = '\0'; // just to be safe
19
+
20
+ fseek(fp, 0L, SEEK_SET);
21
+
22
+ return sz;
23
+ }
24
+
25
+ dict_t tokenize(const char* const buffer, const char* delimiters)
26
+ {
27
+ char* tok;
28
+ char* mutable_buffer = (char*)malloc(strlen(buffer) + 1 * sizeof(char));
29
+ dict_t dict = open_dict();
30
+
31
+ // get mutable copy of buffer; a bit slower, but allows for const-ness
32
+ strcpy(mutable_buffer, buffer);
33
+ mutable_buffer[strlen(buffer)] = '\0';
34
+
35
+ // natively tokenize input string
36
+ tok = strtok(mutable_buffer, delimiters);
37
+ while(tok != NULL)
38
+ {
39
+ // add tok to dict
40
+ dict = place_word_in_dict_strict(dict, tok);
41
+
42
+ // get new tok (if any)
43
+ tok = strtok(NULL, delimiters);
44
+ }
45
+
46
+ // close mutable buffer
47
+ free(mutable_buffer);
48
+
49
+ // clean up dict
50
+ dict = prune_dict(dict, true);
51
+
52
+ return dict;
53
+ }
@@ -0,0 +1,9 @@
1
+ #ifndef __TOKENIZE_3D9CGA6A_H
2
+ #define __TOKENIZE_3D9CGA6A_H
3
+
4
+ #include "chinwag.h"
5
+
6
+ U32 stringify_file(char** buffer, FILE* fp);
7
+ dict_t tokenize(const char* const buffer, const char* delimiters);
8
+
9
+ #endif
@@ -0,0 +1,143 @@
1
+ #include "utility.h"
2
+
3
+ bool exclude(char const* str, char const* substr)
4
+ {
5
+ if(strstr(str, substr) == NULL) return true;
6
+
7
+ return false;
8
+ }
9
+
10
+ bool exclude_num(U32* nums, U32 size, U32 subnum)
11
+ {
12
+ for(U32 i = 0; i != size; ++i)
13
+ {
14
+ if(nums[i] == subnum) return false;
15
+ }
16
+
17
+ return true;
18
+ }
19
+
20
+ bool include(char const* str, char const* substr)
21
+ {
22
+ if(strstr(str, substr) != NULL) return true;
23
+
24
+ return false;
25
+ }
26
+
27
+ bool include_mtx(char const* str,const char* const* substr,const int size)
28
+ {
29
+ for(int i = 0; i != size; ++i)
30
+ {
31
+ if(strstr(str, substr[i]) != NULL) return true;
32
+ }
33
+
34
+ return false;
35
+ }
36
+
37
+ U32 count(char* string, char const* delimiters)
38
+ {
39
+ char* tok = NULL;
40
+ U32 count = 0;
41
+
42
+ tok = strtok(string, delimiters);
43
+ while(tok != NULL)
44
+ {
45
+ ++count;
46
+ tok = strtok(NULL, delimiters);
47
+ }
48
+
49
+ return count;
50
+ }
51
+
52
+ char* substring_with_size(const char* string, U32 start, U32 end)
53
+ {
54
+ char* result = NULL;
55
+ U32 len = strlen(string), size = end - start;
56
+
57
+ if(len == 0 || start > end || start >= len || end >= len) return result;
58
+
59
+ if(start == 0)
60
+ {
61
+ result = (char*)malloc(2);
62
+ result[0] = string[start];
63
+ result[1] = '\0';
64
+ }
65
+ else
66
+ {
67
+ result = (char*)malloc(size + 1);
68
+ result = memcpy(result, &string[start], size);
69
+ result[size] = '\0';
70
+ }
71
+
72
+ return result;
73
+ }
74
+
75
+ char* sample_substring_with_size(const char* string, U32 size)
76
+ {
77
+ char* result = NULL;
78
+ U32 len = strlen(string), access = 0, difference = 0;
79
+
80
+ if(len == 0 || len < size || size == 0) return result;
81
+
82
+ if(len == size)
83
+ {
84
+ result = (char*)malloc(size + 1);
85
+ result = strcpy(result, string);
86
+ result[len] = '\0';
87
+ }
88
+ else
89
+ {
90
+ access = motherr(0, len - 1);
91
+
92
+ difference = (len - 1) - access;
93
+ while(difference < size) { --access; difference = (len - 1) - access; }
94
+
95
+ result = (char*)malloc(size + 1);
96
+ result = memcpy(result, &string[access], size);
97
+ result[size] = '\0';
98
+ }
99
+
100
+ return result;
101
+ }
102
+
103
+ char* add_suffix(char* string, char* suffix)
104
+ {
105
+ U32 len = strlen(string) + strlen(suffix);
106
+ char* temp = (char*)malloc(len + 1);
107
+
108
+ strcpy(temp, string);
109
+ strcat(temp, suffix);
110
+ temp[len] = '\0';
111
+
112
+ free(string);
113
+ string = temp; temp = NULL;
114
+
115
+ return string;
116
+ }
117
+
118
+ char* upcase(char* word)
119
+ {
120
+ for(U32 i = 0; i != strlen(word); ++i)
121
+ {
122
+ word[i] = (char)toupper(word[i]);
123
+ }
124
+
125
+ return word;
126
+ }
127
+
128
+ char* downcase(char* word)
129
+ {
130
+ for(U32 i = 0; i != strlen(word); ++i)
131
+ {
132
+ word[i] = (char)tolower(word[i]);
133
+ }
134
+
135
+ return word;
136
+ }
137
+
138
+ char* capitalize(char* word)
139
+ {
140
+ word[0] = toupper(word[0]);
141
+
142
+ return word;
143
+ }
@@ -0,0 +1,20 @@
1
+ #ifndef __UTILITY_B2605RTY_H
2
+ #define __UTILITY_B2605RTY_H
3
+
4
+ #include "chinwag.h"
5
+
6
+ bool exclude(char const* str, char const* substr);
7
+ bool exclude_num(U32* nums, U32 size, U32 subnum);
8
+ bool include(char const* str, char const* substr);
9
+ bool include_mtx(char const* str,const char* const* substr,const int sz);
10
+
11
+ U32 count(char* string, char const* delimiters);
12
+
13
+ char* substring_with_size(const char* string, U32 start, U32 end);
14
+ char* sample_substring_with_size(const char* string, U32 size);
15
+ char* add_suffix(char* string, char* suffix);
16
+ char* upcase(char* word);
17
+ char* downcase(char* word);
18
+ char* capitalize(char* word);
19
+
20
+ #endif
data/lib/chinwag.rb ADDED
@@ -0,0 +1,5 @@
1
+ module Chinwag
2
+ # Your code goes here...
3
+ end
4
+
5
+ require 'chinwag/chinwag'
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chinwag
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Chris Calo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-15 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A text-synthesis library, for use in layout testing (and more). It houses
14
+ flexible methods for generation, and a dictionary class (CWDict) allowing adequate
15
+ token files (or embedded defaults) to be used as the basis for output creation.
16
+ email:
17
+ - ccalo@vulcanca.com
18
+ executables: []
19
+ extensions:
20
+ - ext/chinwag/extconf.rb
21
+ extra_rdoc_files: []
22
+ files:
23
+ - Rakefile
24
+ - ext/chinwag/chinwag.c
25
+ - ext/chinwag/chinwag.h
26
+ - ext/chinwag/config.c
27
+ - ext/chinwag/config.h
28
+ - ext/chinwag/dict.c
29
+ - ext/chinwag/dict.h
30
+ - ext/chinwag/extconf.rb
31
+ - ext/chinwag/generator.c
32
+ - ext/chinwag/generator.h
33
+ - ext/chinwag/ingredient.h
34
+ - ext/chinwag/latin.c
35
+ - ext/chinwag/latin.h
36
+ - ext/chinwag/rb_chinwag_ext.c
37
+ - ext/chinwag/rb_chinwag_ext.h
38
+ - ext/chinwag/seuss.c
39
+ - ext/chinwag/seuss.h
40
+ - ext/chinwag/tokenize.c
41
+ - ext/chinwag/tokenize.h
42
+ - ext/chinwag/utility.c
43
+ - ext/chinwag/utility.h
44
+ - lib/chinwag.rb
45
+ homepage: https://github.com/vulcancreative/chinwag-ruby
46
+ licenses:
47
+ - MIT
48
+ metadata: {}
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ - ext
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubyforge_project:
66
+ rubygems_version: 2.4.3
67
+ signing_key:
68
+ specification_version: 4
69
+ summary: A text-synthesis library, for use in layout testing (and more).
70
+ test_files: []