/Ruby-Ancient-Greek

String methods in Ruby for working with Ancient Greek

Primary LanguageRuby

DEPRECATED

Use the grc gem instead.

Ruby Ancient Greek

How to set it up

  1. Load the path to the file
  2. Require the module
irb(main):001:0> $LOAD_PATH.unshift('/path/to/file')
=>
irb(main):002:0> require 'grc'
=> true

Does the sentence contain greek characters? (string → bool)

irb(main):003:0> 'Πάντες ἄνθρωποι τοῦ εἰδέναι ὀρέγονται φύσει'.grc?
=> true
irb(main):004:0> 'Greekless sentence'.grc?
=> false

Tokenize (string → array)

irb(main):021:0> 'Πάντες ἄνθρωποι τοῦ εἰδέναι ὀρέγονται φύσει.'.tokenize
=>
["Πάντες",                                                                                                        tc
 "ἄνθρωποι",                                                                                                      s
 "τοῦ",
 "εἰδέναι",
 "ὀρέγονται",
 "φύσει",
 "."
 ]

Transliterate (string)

irb(main):005:0> 'Πάντες ἄνθρωποι τοῦ εἰδέναι ὀρέγονται φύσει'.transliterate
=> "pantes anthrōpoi tou eidenai oregontai physei"

No diacritics (string)

irb(main):006:0> 'Πάντες ἄνθρωποι τοῦ εἰδέναι ὀρέγονται φύσει'.no_diacritics
=> "Παντες ανθρωποι του ειδεναι ορεγονται φυσει"

Acute to grave (string)

irb(main):007:0> 'Πάντες ἄνθρωποι τοῦ εἰδέναι ὀρέγονται φύσει'.acute_to_grave
=> "Πὰντες ἂνθρωποι τοῦ εἰδὲναι ὀρὲγονται φὺσει"

Grave to acute (string)

irb(main):022:0> "Πὰντες ἂνθρωποι τοῦ εἰδὲναι ὀρὲγονται φὺσει".grave_to_acute
=> "Πάντες ἄνθρωποι τοῦ εἰδέναι ὀρέγονται φύσει"

Decode (string)

irb(main):010:0> 'μή'.decode
=> "\\u03bc\\u03ae"

Tonos to oxia (string)

irb(main):019:0> "μή with tonos decodes to " + "μή".decode
=> "μή with tonos decodes to \\u03bc\\u03ae"
irb(main):012:0> 'μή'.tonos_to_oxia
=> "μή"
irb(main):013:0> 'μή'.tonos_to_oxia.decode
=> "\\u03bc\\u1f75"
irb(main):020:0> "μή with oxia decodes to " + "μή".tonos_to_oxia.decode
=> "μή with oxia decodes to \\u03bc\\u1f75"

Decompose (string)

irb(main):003:0> "ὅ".decode
=> "\\u1f45"
irb(main):010:0> decom_str = 'ὅ'.decompose
=> "ὅ"
irb(main):013:0> decom_str.decode
=> "\\u03bf\\u0314\\u0301"

Normalize (string)

irb(main):010:0> decom_str = 'ὅ'.decompose
=> "ὅ"
irb(main):011:0> norm_str = decom_str.normalize
=> "ὅ"
irb(main):012:0> norm_str.decode
=> "\\u1f45"