• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env ruby
2#
3# This script generates TeX hyphenation patterns for Armenian
4#
5# Rules written by Sahak Petrosyan <sahak at mit.edu> (author)
6#
7# These are just primitive rules that says that if there is a
8# combination like <vowel><consonant><vowel>, then it should hyphenate
9# like this: <vowel> - <consonant><vowel>.
10#
11# There are more rules to implement
12#
13# Script written by Mojca Miklavec <mojca.miklavec.lists at gmail.com>
14# (who is not the author of patterns)
15#
16$file = File.new("../../../../../tex/generic/hyph-utf8/patterns/tex/hyph-hy.tex", "w")
17
18# write comments into the file
19def add_comment(str)
20	$file.puts "% " + str.gsub(/\n/, "\n% ").gsub(/% \n/, "%\n")
21end
22
23vowels=%w{ա ե է ը ի ո օ}
24consonants=%w{բ գ դ զ թ ժ լ խ ծ կ հ ձ ղ ճ մ յ ն շ չ պ ջ ռ ս վ տ ր ց փ ք}
25
26add_comment(
27"Hyphenation patterns for Armenian.
28
29Written by Sahak Petrosyan <sahak at mit.edu>
30	for Hyphenator.js (http://code.google.com/p/hyphenator/)
31	and later adapted for TeX
32
33Licence: LGPL
34Version: May 2010
35
36These are just primitive rules that hyphenate combinations like
37<vowel> - <consonant><vowel>.
38
39File auto-generated by a script (see source/generic/hyph-utf8/languages/hy)
40
41Vowels:     #{vowels.join(" ")}
42Consonants: #{consonants.join(" ")}
43
44Some of the patterns below represent combinations that never
45appear in Armenian, but they would be hyphenated according to the rules.
46")
47
48$file.puts '\patterns{'
49
50add_comment(
51"և-<vowel>")
52vowels.each do |vowel|
53	$file.puts "և1#{vowel}"
54end
55
56add_comment(
57"<vowel>-<consonant><vowel>")
58vowels.each do |v1|
59	consonants.each do |c|
60		patterns = []
61		vowels.each do |v2|
62			patterns.push "#{v1}1#{c}#{v2}"
63		end
64		$file.puts patterns.join(" ")
65	end
66	$file.puts "%"
67end
68
69$file.puts "}"
70