Codebase list golang-github-jdkato-prose / 0be8920
New upstream version 1.1.0+git20171031.e27abfd Anthony Fok 6 years ago
23 changed file(s) with 863 addition(s) and 74 deletion(s). Raw diff Collapse all Expand all
77 # Folders
88 _obj
99 _test
10 tag/*.gob
1011
1112 # Architecture specific extensions/prefixes
1213 *.[568vq]
0 # prose [![Travis CI](https://img.shields.io/travis/jdkato/prose.svg?style=flat-square)](https://travis-ci.org/jdkato/prose) [![AppVeyor branch](https://img.shields.io/appveyor/ci/jdkato/prose/master.svg?style=flat-square)](https://ci.appveyor.com/project/jdkato/prose/branch/master) [![GoDoc](https://img.shields.io/badge/godoc-reference-5272B4.svg?style=flat-square)](https://godoc.org/github.com/jdkato/prose) [![Coveralls branch](https://img.shields.io/coveralls/jdkato/prose/master.svg?style=flat-square)](https://coveralls.io/github/jdkato/prose?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/jdkato/prose?style=flat-square)](https://goreportcard.com/report/github.com/jdkato/prose) [![awesome](https://img.shields.io/badge/awesome-%E2%9C%93-ff69b4.svg?style=flat-square)](https://github.com/avelino/awesome-go#natural-language-processing)
0 # prose [![Build Status](https://travis-ci.org/jdkato/prose.svg?branch=master)](https://travis-ci.org/jdkato/prose) [![Build status](https://ci.appveyor.com/api/projects/status/24bepq85nnnk4scr?svg=true)](https://ci.appveyor.com/project/jdkato/prose) [![GoDoc](https://godoc.org/github.com/golang/gddo?status.svg)](https://godoc.org/github.com/jdkato/prose) [![Coverage Status](https://coveralls.io/repos/github/jdkato/prose/badge.svg?branch=master)](https://coveralls.io/github/jdkato/prose?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/jdkato/prose)](https://goreportcard.com/report/github.com/jdkato/prose) [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/avelino/awesome-go#natural-language-processing)
11
2 `prose` is Go library for text (primarily English at the moment) processing that supports tokenization, part-of-speech tagging, named-entity extraction, and more. The library's functionality is split into subpackages designed for modular use. See the [documentation](https://godoc.org/github.com/jdkato/prose) for more information.
2 `prose` is Go library for text (primarily English at the moment) processing that supports tokenization, part-of-speech tagging, named-entity extraction, and more. The library's functionality is split into subpackages designed for modular use.
3
4 See the [GoDoc documentation](https://godoc.org/github.com/jdkato/prose) for more information.
35
46 ## Install
57
68 ```console
79 $ go get github.com/jdkato/prose/...
810 ```
11
12 > **NOTE**: When using some vendoring tools, such as `govendor`, you may need to include the `github.com/jdkato/prose/internal/` package in addition to the core package(s). See [#14](https://github.com/jdkato/prose/issues/14) for more information.
913
1014 ## Usage
1115
7680
7781 ### Transforming ([GoDoc](https://godoc.org/github.com/jdkato/prose/transform))
7882
79 The `tranform` package currently only has one function: converting strings to title case. Unlike `strings.Title`, `tranform` adheres to common guidelines—including styles for both the [AP Stylebook](https://www.apstylebook.com/) and [The Chicago Manual of Style](http://www.chicagomanualofstyle.org/home.html). Additionally, you can easily add your own custom style by defining an [`IgnoreFunc`](https://godoc.org/github.com/jdkato/prose/transform#IgnoreFunc) callback.
83 The `tranform` package implements a number of functions for changing the case of strings, including `Title`, `Snake`, `Pascal`, and `Camel`.
84
85 Additionally, unlike `strings.Title`, `tranform.Title` adheres to common guidelines—including styles for both the [AP Stylebook](https://www.apstylebook.com/) and [The Chicago Manual of Style](http://www.chicagomanualofstyle.org/home.html). You can also add your own custom style by defining an [`IgnoreFunc`](https://godoc.org/github.com/jdkato/prose/transform#IgnoreFunc) callback.
8086
8187 Inspiration and test data taken from [python-titlecase](https://github.com/ppannuto/python-titlecase) and [to-title-case](https://github.com/gouch/to-title-case).
8288
135141 )
136142
137143 func main() {
138 words := tokenize.TextToWords("Go is a open source programming language created at Google.")
144 words := tokenize.TextToWords("Go is an open source programming language created at Google.")
139145 regex := chunk.TreebankNamedEntities
140146
141147 tagger := tag.NewPerceptronTagger()
1313 tagQuads := ""
1414 for _, tok := range tagged {
1515 padding := ""
16 tag := tok.Tag
17 switch len(tag) {
16 pos := tok.Tag
17 switch len(pos) {
1818 case 0:
1919 padding = "____" // should not exist
2020 case 1:
2525 padding = "_"
2626 case 4: // no padding required
2727 default:
28 tag = tag[:4] // longer than 4 ... truncate!
28 pos = pos[:4] // longer than 4 ... truncate!
2929 }
30 tagQuads += tag + padding
30 tagQuads += pos + padding
3131 }
3232 return tagQuads
3333 }
11
22 import (
33 "encoding/json"
4 "fmt"
54 "path/filepath"
65 "testing"
76
87 "github.com/jdkato/prose/internal/util"
98 "github.com/stretchr/testify/assert"
109 )
11
12 var testdata = filepath.Join("..", "testdata")
13
14 func check(expected, observed float64) bool {
15 return fmt.Sprintf("%0.2f", expected) == fmt.Sprintf("%0.2f", observed)
16 }
1710
1811 func TestReadability(t *testing.T) {
1912 tests := make([]testCase, 0)
88 "github.com/jdkato/prose/internal/util"
99 "github.com/stretchr/testify/assert"
1010 )
11
12 var testdata = filepath.Join("..", "testdata")
13
14 func check(expected, observed float64) bool {
15 return fmt.Sprintf("%0.2f", expected) == fmt.Sprintf("%0.2f", observed)
16 }
1117
1218 type testCase struct {
1319 Text string
77 "testing"
88
99 "github.com/jdkato/prose/internal/util"
10 "github.com/jdkato/syllables"
1110 "github.com/montanaflynn/stats"
1211 "github.com/stretchr/testify/assert"
1312 )
8685
8786 for n := 0; n < b.N; n++ {
8887 for word := range tests {
89 syllables.In(word)
88 Syllables(word)
9089 }
9190 }
9291 }
4747 }
4848
4949 assert.Equal(t, nrWords*iter, int(tagger.model.instances))
50 for _, tag := range tagSet {
51 assert.True(t, util.StringInSlice(tag, tagger.model.classes))
52 }
50 assert.Subset(t, tagger.Classes(), tagSet)
5351 }
5452
5553 func random(min, max int) int {
0 [
1 {
2 "input": "follow step-by-step instructions",
3 "none": "follow step by step instructions",
4 "snake": "follow_step_by_step_instructions",
5 "param": "follow-step-by-step-instructions",
6 "dot": "follow.step.by.step.instructions",
7 "constant": "FOLLOW_STEP_BY_STEP_INSTRUCTIONS",
8 "pascal": "FollowStepByStepInstructions",
9 "camel": "followStepByStepInstructions"
10 },
11 {
12 "input": "follow step-BY-step instructions",
13 "none": "follow step by step instructions",
14 "snake": "follow_step_by_step_instructions",
15 "param": "follow-step-by-step-instructions",
16 "dot": "follow.step.by.step.instructions",
17 "constant": "FOLLOW_STEP_BY_STEP_INSTRUCTIONS",
18 "pascal": "FollowStepByStepInstructions",
19 "camel": "followStepByStepInstructions"
20 },
21 {
22 "input": "this sub-phrase is nice",
23 "none": "this sub phrase is nice",
24 "snake": "this_sub_phrase_is_nice",
25 "param": "this-sub-phrase-is-nice",
26 "dot": "this.sub.phrase.is.nice",
27 "constant": "THIS_SUB_PHRASE_IS_NICE",
28 "pascal": "ThisSubPhraseIsNice",
29 "camel": "thisSubPhraseIsNice"
30 },
31 {
32 "input": "catchy title: a subtitle",
33 "none": "catchy title a subtitle",
34 "snake": "catchy_title_a_subtitle",
35 "param": "catchy-title-a-subtitle",
36 "dot": "catchy.title.a.subtitle",
37 "constant": "CATCHY_TITLE_A_SUBTITLE",
38 "pascal": "CatchyTitleASubtitle",
39 "camel": "catchyTitleASubtitle"
40 },
41 {
42 "input": "catchy title: \"a quoted subtitle\"",
43 "none": "catchy title a quoted subtitle",
44 "snake": "catchy_title_a_quoted_subtitle",
45 "param": "catchy-title-a-quoted-subtitle",
46 "dot": "catchy.title.a.quoted.subtitle",
47 "constant": "CATCHY_TITLE_A_QUOTED_SUBTITLE",
48 "pascal": "CatchyTitleAQuotedSubtitle",
49 "camel": "catchyTitleAQuotedSubtitle"
50 },
51 {
52 "input": "catchy title: “‘a twice quoted subtitle’”",
53 "none": "catchy title a twice quoted subtitle",
54 "snake": "catchy_title_a_twice_quoted_subtitle",
55 "param": "catchy-title-a-twice-quoted-subtitle",
56 "dot": "catchy.title.a.twice.quoted.subtitle",
57 "constant": "CATCHY_TITLE_A_TWICE_QUOTED_SUBTITLE",
58 "pascal": "CatchyTitleATwiceQuotedSubtitle",
59 "camel": "catchyTitleATwiceQuotedSubtitle"
60 },
61 {
62 "input": "\"a title inside double quotes\"",
63 "none": "a title inside double quotes",
64 "snake": "a_title_inside_double_quotes",
65 "param": "a-title-inside-double-quotes",
66 "dot": "a.title.inside.double.quotes",
67 "constant": "A_TITLE_INSIDE_DOUBLE_QUOTES",
68 "pascal": "ATitleInsideDoubleQuotes",
69 "camel": "aTitleInsideDoubleQuotes"
70 },
71 {
72 "input": "all words capitalized",
73 "none": "all words capitalized",
74 "snake": "all_words_capitalized",
75 "param": "all-words-capitalized",
76 "dot": "all.words.capitalized",
77 "constant": "ALL_WORDS_CAPITALIZED",
78 "pascal": "AllWordsCapitalized",
79 "camel": "allWordsCapitalized"
80 },
81 {
82 "input": "small words are for by and of lowercase",
83 "none": "small words are for by and of lowercase",
84 "snake": "small_words_are_for_by_and_of_lowercase",
85 "param": "small-words-are-for-by-and-of-lowercase",
86 "dot": "small.words.are.for.by.and.of.lowercase",
87 "constant": "SMALL_WORDS_ARE_FOR_BY_AND_OF_LOWERCASE",
88 "pascal": "SmallWordsAreForByAndOfLowercase",
89 "camel": "smallWordsAreForByAndOfLowercase"
90 },
91 {
92 "input": "a small word starts",
93 "none": "a small word starts",
94 "snake": "a_small_word_starts",
95 "param": "a-small-word-starts",
96 "dot": "a.small.word.starts",
97 "constant": "A_SMALL_WORD_STARTS",
98 "pascal": "ASmallWordStarts",
99 "camel": "aSmallWordStarts"
100 },
101 {
102 "input": "a small word it ends on",
103 "none": "a small word it ends on",
104 "snake": "a_small_word_it_ends_on",
105 "param": "a-small-word-it-ends-on",
106 "dot": "a.small.word.it.ends.on",
107 "constant": "A_SMALL_WORD_IT_ENDS_ON",
108 "pascal": "ASmallWordItEndsOn",
109 "camel": "aSmallWordItEndsOn"
110 },
111 {
112 "input": "do questions work?",
113 "none": "do questions work",
114 "snake": "do_questions_work",
115 "param": "do-questions-work",
116 "dot": "do.questions.work",
117 "constant": "DO_QUESTIONS_WORK",
118 "pascal": "DoQuestionsWork",
119 "camel": "doQuestionsWork"
120 },
121 {
122 "input": "multiple sentences. more than one.",
123 "none": "multiple sentences more than one",
124 "snake": "multiple_sentences_more_than_one",
125 "param": "multiple-sentences-more-than-one",
126 "dot": "multiple.sentences.more.than.one",
127 "constant": "MULTIPLE_SENTENCES_MORE_THAN_ONE",
128 "pascal": "MultipleSentencesMoreThanOne",
129 "camel": "multipleSentencesMoreThanOne"
130 },
131 {
132 "input": "Ends with small word of",
133 "none": "ends with small word of",
134 "snake": "ends_with_small_word_of",
135 "param": "ends-with-small-word-of",
136 "dot": "ends.with.small.word.of",
137 "constant": "ENDS_WITH_SMALL_WORD_OF",
138 "pascal": "EndsWithSmallWordOf",
139 "camel": "endsWithSmallWordOf"
140 },
141 {
142 "input": "double quoted \"inner\" word",
143 "none": "double quoted inner word",
144 "snake": "double_quoted_inner_word",
145 "param": "double-quoted-inner-word",
146 "dot": "double.quoted.inner.word",
147 "constant": "DOUBLE_QUOTED_INNER_WORD",
148 "pascal": "DoubleQuotedInnerWord",
149 "camel": "doubleQuotedInnerWord"
150 },
151 {
152 "input": "single quoted 'inner' word",
153 "none": "single quoted inner word",
154 "snake": "single_quoted_inner_word",
155 "param": "single-quoted-inner-word",
156 "dot": "single.quoted.inner.word",
157 "constant": "SINGLE_QUOTED_INNER_WORD",
158 "pascal": "SingleQuotedInnerWord",
159 "camel": "singleQuotedInnerWord"
160 },
161 {
162 "input": "fancy double quoted “inner” word",
163 "none": "fancy double quoted inner word",
164 "snake": "fancy_double_quoted_inner_word",
165 "param": "fancy-double-quoted-inner-word",
166 "dot": "fancy.double.quoted.inner.word",
167 "constant": "FANCY_DOUBLE_QUOTED_INNER_WORD",
168 "pascal": "FancyDoubleQuotedInnerWord",
169 "camel": "fancyDoubleQuotedInnerWord"
170 },
171 {
172 "input": "fancy single quoted ‘inner’ word",
173 "none": "fancy single quoted inner word",
174 "snake": "fancy_single_quoted_inner_word",
175 "param": "fancy-single-quoted-inner-word",
176 "dot": "fancy.single.quoted.inner.word",
177 "constant": "FANCY_SINGLE_QUOTED_INNER_WORD",
178 "pascal": "FancySingleQuotedInnerWord",
179 "camel": "fancySingleQuotedInnerWord"
180 },
181 {
182 "input": "this vs. that",
183 "none": "this vs that",
184 "snake": "this_vs_that",
185 "param": "this-vs-that",
186 "dot": "this.vs.that",
187 "constant": "THIS_VS_THAT",
188 "pascal": "ThisVsThat",
189 "camel": "thisVsThat"
190 },
191 {
192 "input": "this vs that",
193 "none": "this vs that",
194 "snake": "this_vs_that",
195 "param": "this-vs-that",
196 "dot": "this.vs.that",
197 "constant": "THIS_VS_THAT",
198 "pascal": "ThisVsThat",
199 "camel": "thisVsThat"
200 },
201 {
202 "input": "this v. that",
203 "none": "this v that",
204 "snake": "this_v_that",
205 "param": "this-v-that",
206 "dot": "this.v.that",
207 "constant": "THIS_V_THAT",
208 "pascal": "ThisVThat",
209 "camel": "thisVThat"
210 },
211 {
212 "input": "this v that",
213 "none": "this v that",
214 "snake": "this_v_that",
215 "param": "this-v-that",
216 "dot": "this.v.that",
217 "constant": "THIS_V_THAT",
218 "pascal": "ThisVThat",
219 "camel": "thisVThat"
220 },
221 {
222 "input": "catchy title: substance subtitle",
223 "none": "catchy title substance subtitle",
224 "snake": "catchy_title_substance_subtitle",
225 "param": "catchy-title-substance-subtitle",
226 "dot": "catchy.title.substance.subtitle",
227 "constant": "CATCHY_TITLE_SUBSTANCE_SUBTITLE",
228 "pascal": "CatchyTitleSubstanceSubtitle",
229 "camel": "catchyTitleSubstanceSubtitle"
230 },
231 {
232 "input": "have you read “The Lottery”?",
233 "none": "have you read the lottery",
234 "snake": "have_you_read_the_lottery",
235 "param": "have-you-read-the-lottery",
236 "dot": "have.you.read.the.lottery",
237 "constant": "HAVE_YOU_READ_THE_LOTTERY",
238 "pascal": "HaveYouReadTheLottery",
239 "camel": "haveYouReadTheLottery"
240 },
241 {
242 "input": "Drink this piña colada while you listen to ænima",
243 "none": "drink this piña colada while you listen to ænima",
244 "snake": "drink_this_piña_colada_while_you_listen_to_ænima",
245 "param": "drink-this-piña-colada-while-you-listen-to-ænima",
246 "dot": "drink.this.piña.colada.while.you.listen.to.ænima",
247 "constant": "DRINK_THIS_PIÑA_COLADA_WHILE_YOU_LISTEN_TO_ÆNIMA",
248 "pascal": "DrinkThisPiñaColadaWhileYouListenToÆnima",
249 "camel": "drinkThisPiñaColadaWhileYouListenToÆnima"
250 },
251 {
252 "input": "don't break",
253 "none": "don t break",
254 "snake": "don_t_break",
255 "param": "don-t-break",
256 "dot": "don.t.break",
257 "constant": "DON_T_BREAK",
258 "pascal": "DonTBreak",
259 "camel": "donTBreak"
260 },
261 {
262 "input": "we keep NASA capitalized",
263 "none": "we keep nasa capitalized",
264 "snake": "we_keep_nasa_capitalized",
265 "param": "we-keep-nasa-capitalized",
266 "dot": "we.keep.nasa.capitalized",
267 "constant": "WE_KEEP_NASA_CAPITALIZED",
268 "pascal": "WeKeepNasaCapitalized",
269 "camel": "weKeepNasaCapitalized"
270 },
271 {
272 "input": "leave Q&A unscathed",
273 "none": "leave q a unscathed",
274 "snake": "leave_q_a_unscathed",
275 "param": "leave-q-a-unscathed",
276 "dot": "leave.q.a.unscathed",
277 "constant": "LEAVE_Q_A_UNSCATHED",
278 "pascal": "LeaveQAUnscathed",
279 "camel": "leaveQAUnscathed"
280 },
281 {
282 "input": "your hair[cut] looks (nice)",
283 "none": "your hair cut looks nice",
284 "snake": "your_hair_cut_looks_nice",
285 "param": "your-hair-cut-looks-nice",
286 "dot": "your.hair.cut.looks.nice",
287 "constant": "YOUR_HAIR_CUT_LOOKS_NICE",
288 "pascal": "YourHairCutLooksNice",
289 "camel": "yourHairCutLooksNice"
290 },
291 {
292 "input": "keep that colo(u)r",
293 "none": "keep that colo u r",
294 "snake": "keep_that_colo_u_r",
295 "param": "keep-that-colo-u-r",
296 "dot": "keep.that.colo.u.r",
297 "constant": "KEEP_THAT_COLO_U_R",
298 "pascal": "KeepThatColoUR",
299 "camel": "keepThatColoUR"
300 },
301 {
302 "input": "capitalize hyphenated words on-demand",
303 "none": "capitalize hyphenated words on demand",
304 "snake": "capitalize_hyphenated_words_on_demand",
305 "param": "capitalize-hyphenated-words-on-demand",
306 "dot": "capitalize.hyphenated.words.on.demand",
307 "constant": "CAPITALIZE_HYPHENATED_WORDS_ON_DEMAND",
308 "pascal": "CapitalizeHyphenatedWordsOnDemand",
309 "camel": "capitalizeHyphenatedWordsOnDemand"
310 },
311 {
312 "input": "take them on: special lower cases",
313 "none": "take them on special lower cases",
314 "snake": "take_them_on_special_lower_cases",
315 "param": "take-them-on-special-lower-cases",
316 "dot": "take.them.on.special.lower.cases",
317 "constant": "TAKE_THEM_ON_SPECIAL_LOWER_CASES",
318 "pascal": "TakeThemOnSpecialLowerCases",
319 "camel": "takeThemOnSpecialLowerCases"
320 },
321 {
322 "input": "Notes and observations regarding Apple’s announcements from ‘The Beat Goes On’ special event",
323 "none": "notes and observations regarding apple s announcements from the beat goes on special event",
324 "snake": "notes_and_observations_regarding_apple_s_announcements_from_the_beat_goes_on_special_event",
325 "param": "notes-and-observations-regarding-apple-s-announcements-from-the-beat-goes-on-special-event",
326 "dot": "notes.and.observations.regarding.apple.s.announcements.from.the.beat.goes.on.special.event",
327 "constant": "NOTES_AND_OBSERVATIONS_REGARDING_APPLE_S_ANNOUNCEMENTS_FROM_THE_BEAT_GOES_ON_SPECIAL_EVENT",
328 "pascal": "NotesAndObservationsRegardingAppleSAnnouncementsFromTheBeatGoesOnSpecialEvent",
329 "camel": "notesAndObservationsRegardingAppleSAnnouncementsFromTheBeatGoesOnSpecialEvent"
330 },
331 {
332 "input": "a title and/or string",
333 "none": "a title and or string",
334 "snake": "a_title_and_or_string",
335 "param": "a-title-and-or-string",
336 "dot": "a.title.and.or.string",
337 "constant": "A_TITLE_AND_OR_STRING",
338 "pascal": "ATitleAndOrString",
339 "camel": "aTitleAndOrString"
340 },
341 {
342 "input": "dance with me/let’s face the music and dance",
343 "none": "dance with me let s face the music and dance",
344 "snake": "dance_with_me_let_s_face_the_music_and_dance",
345 "param": "dance-with-me-let-s-face-the-music-and-dance",
346 "dot": "dance.with.me.let.s.face.the.music.and.dance",
347 "constant": "DANCE_WITH_ME_LET_S_FACE_THE_MUSIC_AND_DANCE",
348 "pascal": "DanceWithMeLetSFaceTheMusicAndDance",
349 "camel": "danceWithMeLetSFaceTheMusicAndDance"
350 },
351 {
352 "input": "34th 3rd 2nd",
353 "none": "34th 3rd 2nd",
354 "snake": "34th_3rd_2nd",
355 "param": "34th-3rd-2nd",
356 "dot": "34th.3rd.2nd",
357 "constant": "34TH_3RD_2ND",
358 "pascal": "34th3rd2nd",
359 "camel": "34th3rd2nd"
360 },
361 {
362 "input": "Q&A with steve jobs: 'that's what happens in technology'",
363 "none": "q a with steve jobs that s what happens in technology",
364 "snake": "q_a_with_steve_jobs_that_s_what_happens_in_technology",
365 "param": "q-a-with-steve-jobs-that-s-what-happens-in-technology",
366 "dot": "q.a.with.steve.jobs.that.s.what.happens.in.technology",
367 "constant": "Q_A_WITH_STEVE_JOBS_THAT_S_WHAT_HAPPENS_IN_TECHNOLOGY",
368 "pascal": "QAWithSteveJobsThatSWhatHappensInTechnology",
369 "camel": "qAWithSteveJobsThatSWhatHappensInTechnology"
370 },
371 {
372 "input": "What is AT&T's problem?",
373 "none": "what is at t s problem",
374 "snake": "what_is_at_t_s_problem",
375 "param": "what-is-at-t-s-problem",
376 "dot": "what.is.at.t.s.problem",
377 "constant": "WHAT_IS_AT_T_S_PROBLEM",
378 "pascal": "WhatIsAtTSProblem",
379 "camel": "whatIsAtTSProblem"
380 },
381 {
382 "input": "Apple deal with AT&T falls through",
383 "none": "apple deal with at t falls through",
384 "snake": "apple_deal_with_at_t_falls_through",
385 "param": "apple-deal-with-at-t-falls-through",
386 "dot": "apple.deal.with.at.t.falls.through",
387 "constant": "APPLE_DEAL_WITH_AT_T_FALLS_THROUGH",
388 "pascal": "AppleDealWithAtTFallsThrough",
389 "camel": "appleDealWithAtTFallsThrough"
390 },
391 {
392 "input": "The SEC's Apple probe: what you need to know",
393 "none": "the sec s apple probe what you need to know",
394 "snake": "the_sec_s_apple_probe_what_you_need_to_know",
395 "param": "the-sec-s-apple-probe-what-you-need-to-know",
396 "dot": "the.sec.s.apple.probe.what.you.need.to.know",
397 "constant": "THE_SEC_S_APPLE_PROBE_WHAT_YOU_NEED_TO_KNOW",
398 "pascal": "TheSecSAppleProbeWhatYouNeedToKnow",
399 "camel": "theSecSAppleProbeWhatYouNeedToKnow"
400 },
401 {
402 "input": "The SEC's Apple probe: what you need to know",
403 "none": "the sec s apple probe what you need to know",
404 "snake": "the_sec_s_apple_probe_what_you_need_to_know",
405 "param": "the-sec-s-apple-probe-what-you-need-to-know",
406 "dot": "the.sec.s.apple.probe.what.you.need.to.know",
407 "constant": "THE_SEC_S_APPLE_PROBE_WHAT_YOU_NEED_TO_KNOW",
408 "pascal": "TheSecSAppleProbeWhatYouNeedToKnow",
409 "camel": "theSecSAppleProbeWhatYouNeedToKnow"
410 },
411 {
412 "input": "'by the Way, small word at the start but within quotes.'",
413 "none": "by the way small word at the start but within quotes",
414 "snake": "by_the_way_small_word_at_the_start_but_within_quotes",
415 "param": "by-the-way-small-word-at-the-start-but-within-quotes",
416 "dot": "by.the.way.small.word.at.the.start.but.within.quotes",
417 "constant": "BY_THE_WAY_SMALL_WORD_AT_THE_START_BUT_WITHIN_QUOTES",
418 "pascal": "ByTheWaySmallWordAtTheStartButWithinQuotes",
419 "camel": "byTheWaySmallWordAtTheStartButWithinQuotes"
420 },
421 {
422 "input": "Small word at end is nothing to be afraid of",
423 "none": "small word at end is nothing to be afraid of",
424 "snake": "small_word_at_end_is_nothing_to_be_afraid_of",
425 "param": "small-word-at-end-is-nothing-to-be-afraid-of",
426 "dot": "small.word.at.end.is.nothing.to.be.afraid.of",
427 "constant": "SMALL_WORD_AT_END_IS_NOTHING_TO_BE_AFRAID_OF",
428 "pascal": "SmallWordAtEndIsNothingToBeAfraidOf",
429 "camel": "smallWordAtEndIsNothingToBeAfraidOf"
430 },
431 {
432 "input": "Starting Sub-Phrase With a Small Word: a Trick, Perhaps?",
433 "none": "starting sub phrase with a small word a trick perhaps",
434 "snake": "starting_sub_phrase_with_a_small_word_a_trick_perhaps",
435 "param": "starting-sub-phrase-with-a-small-word-a-trick-perhaps",
436 "dot": "starting.sub.phrase.with.a.small.word.a.trick.perhaps",
437 "constant": "STARTING_SUB_PHRASE_WITH_A_SMALL_WORD_A_TRICK_PERHAPS",
438 "pascal": "StartingSubPhraseWithASmallWordATrickPerhaps",
439 "camel": "startingSubPhraseWithASmallWordATrickPerhaps"
440 },
441 {
442 "input": "Sub-Phrase With a Small Word in Quotes: 'a Trick, Perhaps?'",
443 "none": "sub phrase with a small word in quotes a trick perhaps",
444 "snake": "sub_phrase_with_a_small_word_in_quotes_a_trick_perhaps",
445 "param": "sub-phrase-with-a-small-word-in-quotes-a-trick-perhaps",
446 "dot": "sub.phrase.with.a.small.word.in.quotes.a.trick.perhaps",
447 "constant": "SUB_PHRASE_WITH_A_SMALL_WORD_IN_QUOTES_A_TRICK_PERHAPS",
448 "pascal": "SubPhraseWithASmallWordInQuotesATrickPerhaps",
449 "camel": "subPhraseWithASmallWordInQuotesATrickPerhaps"
450 },
451 {
452 "input": "Starting a Hyphen Delimited Sub-Phrase With a Small Word - a Trick, Perhaps?",
453 "none": "starting a hyphen delimited sub phrase with a small word a trick perhaps",
454 "snake": "starting_a_hyphen_delimited_sub_phrase_with_a_small_word_a_trick_perhaps",
455 "param": "starting-a-hyphen-delimited-sub-phrase-with-a-small-word-a-trick-perhaps",
456 "dot": "starting.a.hyphen.delimited.sub.phrase.with.a.small.word.a.trick.perhaps",
457 "constant": "STARTING_A_HYPHEN_DELIMITED_SUB_PHRASE_WITH_A_SMALL_WORD_A_TRICK_PERHAPS",
458 "pascal": "StartingAHyphenDelimitedSubPhraseWithASmallWordATrickPerhaps",
459 "camel": "startingAHyphenDelimitedSubPhraseWithASmallWordATrickPerhaps"
460 },
461 {
462 "input": "Hyphen Delimited Sub-Phrase With a Small Word in Quotes - 'a Trick, Perhaps?'",
463 "none": "hyphen delimited sub phrase with a small word in quotes a trick perhaps",
464 "snake": "hyphen_delimited_sub_phrase_with_a_small_word_in_quotes_a_trick_perhaps",
465 "param": "hyphen-delimited-sub-phrase-with-a-small-word-in-quotes-a-trick-perhaps",
466 "dot": "hyphen.delimited.sub.phrase.with.a.small.word.in.quotes.a.trick.perhaps",
467 "constant": "HYPHEN_DELIMITED_SUB_PHRASE_WITH_A_SMALL_WORD_IN_QUOTES_A_TRICK_PERHAPS",
468 "pascal": "HyphenDelimitedSubPhraseWithASmallWordInQuotesATrickPerhaps",
469 "camel": "hyphenDelimitedSubPhraseWithASmallWordInQuotesATrickPerhaps"
470 },
471 {
472 "input": "Snakes on a Plane - The TV Edit - The Famous Line",
473 "none": "snakes on a plane the tv edit the famous line",
474 "snake": "snakes_on_a_plane_the_tv_edit_the_famous_line",
475 "param": "snakes-on-a-plane-the-tv-edit-the-famous-line",
476 "dot": "snakes.on.a.plane.the.tv.edit.the.famous.line",
477 "constant": "SNAKES_ON_A_PLANE_THE_TV_EDIT_THE_FAMOUS_LINE",
478 "pascal": "SnakesOnAPlaneTheTvEditTheFamousLine",
479 "camel": "snakesOnAPlaneTheTvEditTheFamousLine"
480 },
481 {
482 "input": "Starting an Em Dash Delimited Sub-Phrase With a Small Word — a Trick, Perhaps?",
483 "none": "starting an em dash delimited sub phrase with a small word a trick perhaps",
484 "snake": "starting_an_em_dash_delimited_sub_phrase_with_a_small_word_a_trick_perhaps",
485 "param": "starting-an-em-dash-delimited-sub-phrase-with-a-small-word-a-trick-perhaps",
486 "dot": "starting.an.em.dash.delimited.sub.phrase.with.a.small.word.a.trick.perhaps",
487 "constant": "STARTING_AN_EM_DASH_DELIMITED_SUB_PHRASE_WITH_A_SMALL_WORD_A_TRICK_PERHAPS",
488 "pascal": "StartingAnEmDashDelimitedSubPhraseWithASmallWordATrickPerhaps",
489 "camel": "startingAnEmDashDelimitedSubPhraseWithASmallWordATrickPerhaps"
490 },
491 {
492 "input": "Em Dash Delimited Sub-Phrase With a Small Word in Quotes — 'a Trick, Perhaps?'",
493 "none": "em dash delimited sub phrase with a small word in quotes a trick perhaps",
494 "snake": "em_dash_delimited_sub_phrase_with_a_small_word_in_quotes_a_trick_perhaps",
495 "param": "em-dash-delimited-sub-phrase-with-a-small-word-in-quotes-a-trick-perhaps",
496 "dot": "em.dash.delimited.sub.phrase.with.a.small.word.in.quotes.a.trick.perhaps",
497 "constant": "EM_DASH_DELIMITED_SUB_PHRASE_WITH_A_SMALL_WORD_IN_QUOTES_A_TRICK_PERHAPS",
498 "pascal": "EmDashDelimitedSubPhraseWithASmallWordInQuotesATrickPerhaps",
499 "camel": "emDashDelimitedSubPhraseWithASmallWordInQuotesATrickPerhaps"
500 },
501 {
502 "input": "Snakes on a Plane — The TV Edit — The Famous Line",
503 "none": "snakes on a plane the tv edit the famous line",
504 "snake": "snakes_on_a_plane_the_tv_edit_the_famous_line",
505 "param": "snakes-on-a-plane-the-tv-edit-the-famous-line",
506 "dot": "snakes.on.a.plane.the.tv.edit.the.famous.line",
507 "constant": "SNAKES_ON_A_PLANE_THE_TV_EDIT_THE_FAMOUS_LINE",
508 "pascal": "SnakesOnAPlaneTheTvEditTheFamousLine",
509 "camel": "snakesOnAPlaneTheTvEditTheFamousLine"
510 },
511 {
512 "input": "\"Nothing to Be Afraid of?\"",
513 "none": "nothing to be afraid of",
514 "snake": "nothing_to_be_afraid_of",
515 "param": "nothing-to-be-afraid-of",
516 "dot": "nothing.to.be.afraid.of",
517 "constant": "NOTHING_TO_BE_AFRAID_OF",
518 "pascal": "NothingToBeAfraidOf",
519 "camel": "nothingToBeAfraidOf"
520 },
521 {
522 "input": "a thing",
523 "none": "a thing",
524 "snake": "a_thing",
525 "param": "a-thing",
526 "dot": "a.thing",
527 "constant": "A_THING",
528 "pascal": "AThing",
529 "camel": "aThing"
530 },
531 {
532 "input": "2lmc Spool: 'gruber on OmniFocus and vapo(u)rware'",
533 "none": "2lmc spool gruber on omni focus and vapo u rware",
534 "snake": "2lmc_spool_gruber_on_omni_focus_and_vapo_u_rware",
535 "param": "2lmc-spool-gruber-on-omni-focus-and-vapo-u-rware",
536 "dot": "2lmc.spool.gruber.on.omni.focus.and.vapo.u.rware",
537 "constant": "2LMC_SPOOL_GRUBER_ON_OMNI_FOCUS_AND_VAPO_U_RWARE",
538 "pascal": "2lmcSpoolGruberOnOmniFocusAndVapoURware",
539 "camel": "2lmcSpoolGruberOnOmniFocusAndVapoURware"
540 },
541 {
542 "input": "reading between the lines of steve jobs’s ‘thoughts on music’",
543 "none": "reading between the lines of steve jobs s thoughts on music",
544 "snake": "reading_between_the_lines_of_steve_jobs_s_thoughts_on_music",
545 "param": "reading-between-the-lines-of-steve-jobs-s-thoughts-on-music",
546 "dot": "reading.between.the.lines.of.steve.jobs.s.thoughts.on.music",
547 "constant": "READING_BETWEEN_THE_LINES_OF_STEVE_JOBS_S_THOUGHTS_ON_MUSIC",
548 "pascal": "ReadingBetweenTheLinesOfSteveJobsSThoughtsOnMusic",
549 "camel": "readingBetweenTheLinesOfSteveJobsSThoughtsOnMusic"
550 },
551 {
552 "input": "seriously, ‘repair permissions’ is voodoo",
553 "none": "seriously repair permissions is voodoo",
554 "snake": "seriously_repair_permissions_is_voodoo",
555 "param": "seriously-repair-permissions-is-voodoo",
556 "dot": "seriously.repair.permissions.is.voodoo",
557 "constant": "SERIOUSLY_REPAIR_PERMISSIONS_IS_VOODOO",
558 "pascal": "SeriouslyRepairPermissionsIsVoodoo",
559 "camel": "seriouslyRepairPermissionsIsVoodoo"
560 },
561 {
562 "input": "generalissimo francisco franco: still dead; kieren McCarthy: still a jackass",
563 "none": "generalissimo francisco franco still dead kieren mc carthy still a jackass",
564 "snake": "generalissimo_francisco_franco_still_dead_kieren_mc_carthy_still_a_jackass",
565 "param": "generalissimo-francisco-franco-still-dead-kieren-mc-carthy-still-a-jackass",
566 "dot": "generalissimo.francisco.franco.still.dead.kieren.mc.carthy.still.a.jackass",
567 "constant": "GENERALISSIMO_FRANCISCO_FRANCO_STILL_DEAD_KIEREN_MC_CARTHY_STILL_A_JACKASS",
568 "pascal": "GeneralissimoFranciscoFrancoStillDeadKierenMcCarthyStillAJackass",
569 "camel": "generalissimoFranciscoFrancoStillDeadKierenMcCarthyStillAJackass"
570 },
571 {
572 "input": "O'Reilly should be untouched",
573 "none": "o reilly should be untouched",
574 "snake": "o_reilly_should_be_untouched",
575 "param": "o-reilly-should-be-untouched",
576 "dot": "o.reilly.should.be.untouched",
577 "constant": "O_REILLY_SHOULD_BE_UNTOUCHED",
578 "pascal": "OReillyShouldBeUntouched",
579 "camel": "oReillyShouldBeUntouched"
580 },
581 {
582 "input": "Mr McTavish went to MacDonalds",
583 "none": "mr mc tavish went to mac donalds",
584 "snake": "mr_mc_tavish_went_to_mac_donalds",
585 "param": "mr-mc-tavish-went-to-mac-donalds",
586 "dot": "mr.mc.tavish.went.to.mac.donalds",
587 "constant": "MR_MC_TAVISH_WENT_TO_MAC_DONALDS",
588 "pascal": "MrMcTavishWentToMacDonalds",
589 "camel": "mrMcTavishWentToMacDonalds"
590 },
591 {
592 "input": "this shouldn't\nget mangled",
593 "none": "this shouldn t get mangled",
594 "snake": "this_shouldn_t_get_mangled",
595 "param": "this-shouldn-t-get-mangled",
596 "dot": "this.shouldn.t.get.mangled",
597 "constant": "THIS_SHOULDN_T_GET_MANGLED",
598 "pascal": "ThisShouldnTGetMangled",
599 "camel": "thisShouldnTGetMangled"
600 },
601 {
602 "input": "mac mc MAC MC machine",
603 "none": "mac mc mac mc machine",
604 "snake": "mac_mc_mac_mc_machine",
605 "param": "mac-mc-mac-mc-machine",
606 "dot": "mac.mc.mac.mc.machine",
607 "constant": "MAC_MC_MAC_MC_MACHINE",
608 "pascal": "MacMcMacMcMachine",
609 "camel": "macMcMacMcMachine"
610 },
611 {
612 "input": "foo bar 5th st",
613 "none": "foo bar 5th st",
614 "snake": "foo_bar_5th_st",
615 "param": "foo-bar-5th-st",
616 "dot": "foo.bar.5th.st",
617 "constant": "FOO_BAR_5TH_ST",
618 "pascal": "FooBar5thSt",
619 "camel": "fooBar5thSt"
620 },
621 {
622 "input": "hmm ... this is interesting...",
623 "none": "hmm this is interesting",
624 "snake": "hmm_this_is_interesting",
625 "param": "hmm-this-is-interesting",
626 "dot": "hmm.this.is.interesting",
627 "constant": "HMM_THIS_IS_INTERESTING",
628 "pascal": "HmmThisIsInteresting",
629 "camel": "hmmThisIsInteresting"
630 }
631 ]
107107 "expect": "We Keep NASA Capitalized"
108108 },
109109 {
110 "input":"leave Q&A unscathed",
111 "expect":"Leave Q&A Unscathed"
112 },
113 {
114 "input":"your hair[cut] looks (nice)",
115 "expect":"Your Hair[cut] Looks (Nice)"
116 },
117 {
118 "input":"keep that colo(u)r",
119 "expect":"Keep That Colo(u)r"
120 },
121 {
122 "input":"capitalize hyphenated words on-demand",
123 "expect":"Capitalize Hyphenated Words On-Demand"
124 },
125 {
126 "input":"take them on: special lower cases",
127 "expect":"Take Them On: Special Lower Cases"
128 },
129 {
130 "input":"Notes and observations regarding Apple’s announcements from ‘The Beat Goes On’ special event",
131 "expect":"Notes and Observations Regarding Apple’s Announcements From ‘The Beat Goes On’ Special Event"
110 "input": "leave Q&A unscathed",
111 "expect": "Leave Q&A Unscathed"
112 },
113 {
114 "input": "your hair[cut] looks (nice)",
115 "expect": "Your Hair[cut] Looks (Nice)"
116 },
117 {
118 "input": "keep that colo(u)r",
119 "expect": "Keep That Colo(u)r"
120 },
121 {
122 "input": "capitalize hyphenated words on-demand",
123 "expect": "Capitalize Hyphenated Words On-Demand"
124 },
125 {
126 "input": "take them on: special lower cases",
127 "expect": "Take Them On: Special Lower Cases"
128 },
129 {
130 "input": "Notes and observations regarding Apple’s announcements from ‘The Beat Goes On’ special event",
131 "expect": "Notes and Observations Regarding Apple’s Announcements From ‘The Beat Goes On’ Special Event"
132132 },
133133 {
134134 "input": "a title and/or string",
249249 {
250250 "input": "hmm ... this is interesting...",
251251 "expect": "Hmm ... This Is Interesting..."
252 },
253 {
254 "input": "a “[“New Entity”],” an [Institution] and [Institution].",
255 "expect": "A “[“New Entity”],” an [Institution] and [Institution]."
256 },
257 {
258 "input": "This Agreement, dated [DATE] (the “Effective Date”) for Design Services (the “Agreement”) is between [DESIGNER NAME], of [DESIGNER COMPANY](“Designer”), and [CLIENT NAME], of [CLIENT COMPANY] (“Client”) (together known as the “Parties”), for the performance of said Design Services and the production of Deliverables, as described in Schedule A, attached hereto and incorporated herein by reference.",
259 "expect": "This Agreement, Dated [DATE] (The “Effective Date”) for Design Services (The “Agreement”) Is Between [DESIGNER NAME], of [DESIGNER COMPANY](“Designer”), and [CLIENT NAME], of [CLIENT COMPANY] (“Client”) (Together Known as the “Parties”), for the Performance of Said Design Services and the Production of Deliverables, as Described in Schedule A, Attached Hereto and Incorporated Herein by Reference."
252260 }
253 ]
261 ]
00 package tokenize
11
22 import (
3 "encoding/json"
4 "path/filepath"
53 "testing"
64
7 "github.com/jdkato/prose/internal/util"
85 "github.com/stretchr/testify/assert"
96 )
10
11 func getWordData(file string) ([]string, [][]string) {
12 in := util.ReadDataFile(filepath.Join(testdata, "treebank_sents.json"))
13 out := util.ReadDataFile(filepath.Join(testdata, file))
14
15 input := []string{}
16 output := [][]string{}
17
18 util.CheckError(json.Unmarshal(in, &input))
19 util.CheckError(json.Unmarshal(out, &output))
20
21 return input, output
22 }
23
24 func getWordBenchData() []string {
25 in := util.ReadDataFile(filepath.Join(testdata, "treebank_sents.json"))
26 input := []string{}
27 util.CheckError(json.Unmarshal(in, &input))
28 return input
29 }
307
318 func TestWordPunctTokenizer(t *testing.T) {
329 input, output := getWordData("word_punct.json")
00 package tokenize
11
22 import (
3 "encoding/json"
34 "fmt"
5 "path/filepath"
46 "testing"
57
8 "github.com/jdkato/prose/internal/util"
69 "github.com/stretchr/testify/assert"
710 )
11
12 var testdata = filepath.Join("..", "testdata")
13
14 func getWordData(file string) ([]string, [][]string) {
15 in := util.ReadDataFile(filepath.Join(testdata, "treebank_sents.json"))
16 out := util.ReadDataFile(filepath.Join(testdata, file))
17
18 input := []string{}
19 output := [][]string{}
20
21 util.CheckError(json.Unmarshal(in, &input))
22 util.CheckError(json.Unmarshal(out, &output))
23
24 return input, output
25 }
26
27 func getWordBenchData() []string {
28 in := util.ReadDataFile(filepath.Join(testdata, "treebank_sents.json"))
29 input := []string{}
30 util.CheckError(json.Unmarshal(in, &input))
31 return input
32 }
833
934 func ExampleNewWordBoundaryTokenizer() {
1035 t := NewWordBoundaryTokenizer()
00 package tokenize
11
22 import (
3 "path/filepath"
43 "testing"
54
65 "github.com/stretchr/testify/assert"
76 )
8
9 var testdata = filepath.Join("..", "testdata")
107
118 func TestTreebankWordTokenizer(t *testing.T) {
129 input, output := getWordData("treebank_words.json")
4747 sm := strings.ToLower(m)
4848 pos = strings.Index(t[idx:], m) + idx
4949 prev := charAt(t, pos-1)
50 ext := len(m)
50 ext := utf8.RuneCountInString(m)
5151 idx = pos + ext
52 // pos > 0 && (pos+ext) < end && util.StringInSlice(sm, smallWords)
5352 if tc.ignore(sm, pos == 0 || idx == end) &&
5453 (prev == ' ' || prev == '-' || prev == '/') &&
5554 charAt(t, pos-2) != ':' && charAt(t, pos-2) != '-' &&
77 "github.com/jdkato/prose/internal/util"
88 "github.com/stretchr/testify/assert"
99 )
10
11 var testdata = filepath.Join("..", "testdata")
1210
1311 type testCase struct {
1412 Input string
11 Package transform implements functions to manipulate UTF-8 encoded strings.
22 */
33 package transform
4
5 import (
6 "regexp"
7 "strings"
8 "unicode"
9 )
10
11 var spaces = regexp.MustCompile(" +")
12
13 func removeCase(s string, sep string, t func(rune) rune) string {
14 out := ""
15 old := ' '
16 for i, c := range s {
17 alpha := unicode.IsLetter(c) || unicode.IsNumber(c)
18 mat := (i > 1 && unicode.IsLower(old) && unicode.IsUpper(c))
19 if mat || !alpha || (unicode.IsSpace(c) && c != ' ') {
20 out += " "
21 }
22 if alpha || c == ' ' {
23 out += string(t(c))
24 }
25 old = c
26 }
27 return spaces.ReplaceAllString(strings.TrimSpace(out), sep)
28 }
29
30 // Simple returns a space-separated, lower-cased copy of the string s.
31 func Simple(s string) string {
32 return removeCase(s, " ", unicode.ToLower)
33 }
34
35 // Dash returns a dash-separated, lower-cased copy of the string s.
36 func Dash(s string) string {
37 return removeCase(s, "-", unicode.ToLower)
38 }
39
40 // Snake returns a underscore-separated, lower-cased copy of the string s.
41 func Snake(s string) string {
42 return removeCase(s, "_", unicode.ToLower)
43 }
44
45 // Dot returns a period-separated, lower-cased copy of the string s.
46 func Dot(s string) string {
47 return removeCase(s, ".", unicode.ToLower)
48 }
49
50 // Constant returns a underscore-separated, upper-cased copy of the string s.
51 func Constant(s string) string {
52 return removeCase(s, "_", unicode.ToUpper)
53 }
54
55 // Pascal returns a Pascal-cased copy of the string s.
56 func Pascal(s string) string {
57 out := ""
58 wasSpace := false
59 for i, c := range removeCase(s, " ", unicode.ToLower) {
60 if i == 0 || wasSpace {
61 c = unicode.ToUpper(c)
62 }
63 wasSpace = c == ' '
64 if !wasSpace {
65 out += string(c)
66 }
67 }
68 return out
69 }
70
71 // Camel returns a Camel-cased copy of the string s.
72 func Camel(s string) string {
73 first := ' '
74 for _, c := range s {
75 if unicode.IsLetter(c) || unicode.IsNumber(c) {
76 first = c
77 break
78 }
79 }
80 return strings.TrimSpace(string(unicode.ToLower(first)) + Pascal(s)[1:])
81 }
00 package transform
11
2 import "fmt"
2 import (
3 "encoding/json"
4 "fmt"
5 "path/filepath"
6 "testing"
7
8 "github.com/jdkato/prose/internal/util"
9 "github.com/stretchr/testify/assert"
10 )
11
12 var testdata = filepath.Join("..", "testdata")
13
14 type testFormat struct {
15 Input string
16 None string
17 Snake string
18 Param string
19 Dot string
20 Constant string
21 Pascal string
22 Camel string
23 }
24
25 func TestTransform(t *testing.T) {
26 tests := make([]testFormat, 0)
27 cases := util.ReadDataFile(filepath.Join(testdata, "case.json"))
28
29 util.CheckError(json.Unmarshal(cases, &tests))
30 for _, test := range tests {
31 assert.Equal(t, test.None, Simple(test.Input))
32 assert.Equal(t, test.Snake, Snake(test.Input))
33 assert.Equal(t, test.Param, Dash(test.Input))
34 assert.Equal(t, test.Dot, Dot(test.Input))
35 assert.Equal(t, test.Constant, Constant(test.Input))
36 assert.Equal(t, test.Pascal, Pascal(test.Input))
37 assert.Equal(t, test.Camel, Camel(test.Input))
38 }
39 }
340
441 func ExampleNewTitleConverter() {
542 tc := NewTitleConverter(APStyle)
643 fmt.Println(tc.Title("the last of the mohicans"))
744 // Output: The Last of the Mohicans
845 }
46
47 func ExampleSimple() {
48 fmt.Println(Simple("test string"))
49 // Output: test string
50 }
51
52 func ExampleDash() {
53 fmt.Println(Dash("test string"))
54 // Output: test-string
55 }
56
57 func ExampleSnake() {
58 fmt.Println(Snake("test string"))
59 // Output: test_string
60 }
61
62 func ExampleDot() {
63 fmt.Println(Dot("test string"))
64 // Output: test.string
65 }
66
67 func ExampleConstant() {
68 fmt.Println(Constant("test string"))
69 // Output: TEST_STRING
70 }
71
72 func ExamplePascal() {
73 fmt.Println(Pascal("test string"))
74 // Output: TestString
75 }
76
77 func ExampleCamel() {
78 fmt.Println(Camel("test string"))
79 // Output: testString
80 }