|
20 | 20 | end
|
21 | 21 |
|
22 | 22 | end
|
| 23 | + |
| 24 | + method :words_without_punctuation do |
| 25 | + |
| 26 | + test do |
| 27 | + # English |
| 28 | + x = "How?? I don't believe you!!!" |
| 29 | + x.words_without_punctuation.assert == ['How', 'I', "don't", 'believe', 'you'] |
| 30 | + x = 'Slowly, grudgingly he said: "This has to stop."' |
| 31 | + x.words_without_punctuation.assert == ['Slowly', 'grudgingly', 'he', 'said', 'This', 'has', 'to', 'stop'] |
| 32 | + end |
| 33 | + |
| 34 | + test do |
| 35 | + # French |
| 36 | + x = "« Bonjour ! J'ai rendezvous avec mademoiselle Dupont-Fleury ! »" |
| 37 | + x.words_without_punctuation.assert == ['Bonjour', "J'ai", "rendezvous", "avec", "mademoiselle", "Dupont-Fleury"] |
| 38 | + end |
| 39 | + |
| 40 | + test do |
| 41 | + # Spanish |
| 42 | + x = "«¡María, te amo!», exclamó Juan. … «¿Por qué me sigues mintiendo?" |
| 43 | + x.words_without_punctuation.assert == ['María', 'te', 'amo', 'exclamó', 'Juan', 'Por', 'qué', 'me', 'sigues', 'mintiendo'] |
| 44 | + end |
| 45 | + |
| 46 | + test do |
| 47 | + # Italian |
| 48 | + x = 'Alcune persone scrivono al computer; altre con la penna: io con le due.' |
| 49 | + x.words_without_punctuation.assert == ['Alcune', 'persone', 'scrivono', 'al', 'computer', 'altre', 'con', 'la', 'penna', 'io', 'con', 'le', 'due'] |
| 50 | + end |
| 51 | + |
| 52 | + test do |
| 53 | + # German |
| 54 | + x = '“chevron,” „französische“ Anführungszeichen' |
| 55 | + x.words_without_punctuation.assert == ['chevron', 'französische', 'Anführungszeichen'] |
| 56 | + end |
| 57 | + |
| 58 | + test do |
| 59 | + # Russian |
| 60 | + x = '"А ты прав." — сказал он, — "Я великолепен!".' |
| 61 | + x.words_without_punctuation.assert == ['А', 'ты', 'прав', 'сказал', 'он', 'Я', 'великолепен'] |
| 62 | + end |
| 63 | + end |
23 | 64 |
|
24 | 65 | end
|
0 commit comments