Advertisement
Metalhead33

ProtoElf to ProtoHuman

Sep 26th, 2015
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 6.04 KB | None | 0 0
  1. #!/bin/env perl
  2.  
  3. # Voiceless Aspirated Stops
  4. my @AspiratedStop = qw(pʰ tʰ t͡sʰ t͡ʃʰ ʈ͡ʂʰ t͡ɕʰ kʲʰ kʰ kʷʰ);
  5. my @NonAspirant = qw(ɸ θ t͡s t͡ʃ ʈ͡ʂ t͡ɕ xʲ x xʷ);
  6. # Plain Voiceless Stops
  7. my @VoicelessStop = qw(p t t͡s t͡ʃ ʈ͡ʂ t͡ɕ kʲ k kʷ);
  8. # Voiced Stops
  9. my @VoicedStop = qw(b d d͡z d͡ʒ ɖ͡ʐ d͡ʑ gʲ g gʷ);
  10.  
  11. # Shibilants
  12. my @AbstractShibilant = qw(t͡ʃʰ t͡ʃ d͡ʒ ʃ ʒ ḻ ṉ r̠);
  13. my @PalatalShibilant = qw(t͡ɕʰ t͡ɕ d͡ʑ ɕ ʑ ʎ ɲ ɺʲ);
  14. my @RetroflexShibilant = qw(ʈ͡ʂʰ ʈ͡ʂ ɖ͡ʐ ʂ ʐ ɭ ɳ ɻ);
  15. my @Sibilant = qw(sʰ t͡s d͡z s z l n r);
  16.  
  17. # Fricatives for Lenition
  18. my @LenitableStop = qw(b d g gʷ gʲ);
  19. my @VoicedFricative = qw(β ð ɣ ɣʷ j);
  20. my @VoicelessFricative = qw(ɸ θ x xʷ ç);
  21.  
  22. my $Consonant = join "|",@Sibilant,@VoicelessStop;@VoicedStop;
  23.  
  24. # Vowels
  25. my $PelfFrontVowel = join "|",qw(æ e ø i y);
  26. my $PelfBackVowel = join "|",qw(a ə o ɨ u);
  27. my $PhumVowels = join "|",qw(ɑ ɑː e eː ɛː ɔː i u iː uː iu̯ ui̯ eu̯ ɑi̯ ɑu̯);
  28.  
  29. my @Stop = ();
  30. push @Stop, @VoicelessStop, @VoicedStop;
  31.  
  32. my $Consonant = join "|", @S, @Z;
  33.  
  34. # Boundaries
  35. my $V = "a|ə|e|o|i|u|ø|y";
  36.  
  37. use warnings;
  38. use strict;
  39.  
  40. # Open the filer̠
  41. open(my $fh, "<", $ARGV[0]);
  42.  
  43. # Read line by line
  44. while(<$fh>)
  45. {
  46.   # apply early transformations here
  47.   # Abstract -> Palatal 1
  48.   for(my $i = 0; $i < @AbstractShibilant; $i++) {
  49.     # retrieve the source
  50.     my $item = @AbstractShibilant[$i];
  51.     # and replacement
  52.     my $rplc = @PalatalShibilant[$i];
  53.  
  54.     # replace the source by replacement inside the boundaries
  55.     s/((?:$PelfFrontVowel)+)$item/$1$rplc/gi
  56.  
  57.   }
  58.   # Abstract -> Retroflex 1
  59.   for(my $i = 0; $i < @AbstractShibilant; $i++) {
  60.     # retrieve the source
  61.     my $item = @AbstractShibilant[$i];
  62.     # and replacement
  63.     my $rplc = @RetroflexShibilant[$i];
  64.  
  65.     # replace the source by replacement inside the boundaries
  66.     s/((?:$PelfBackVowel)+)$item/$1$rplc/gi
  67.  
  68.   }
  69.   # Abstract -> Palatal 2
  70.   for(my $i = 0; $i < @AbstractShibilant; $i++) {
  71.     # retrieve the source
  72.     my $item = @AbstractShibilant[$i];
  73.     # and replacement
  74.     my $rplc = @PalatalShibilant[$i];
  75.  
  76.     # replace the source by replacement inside the boundaries
  77.     s/$item((?:$PelfFrontVowel)+)/$rplc$1/gi
  78.  
  79.   }
  80.   # Abstract -> Retroflex 2
  81.   for(my $i = 0; $i < @AbstractShibilant; $i++) {
  82.     # retrieve the source
  83.     my $item = @AbstractShibilant[$i];
  84.     # and replacement
  85.     my $rplc = @RetroflexShibilant[$i];
  86.  
  87.     # replace the source by replacement inside the boundaries
  88.     s/$item((?:$PelfBackVowel)+)/$rplc$1/gi
  89.  
  90.   }
  91.   # Nasal Rhotacism /n̠/ > /r̠/
  92.   s/"n̠"/"r̠"/gi
  93.   #Major vowel shift!
  94.   s/"aə̯"/"ɑː"/gi
  95.   s/"aɪ̯"/"ɑi̯"/gi
  96.   s/"aʏ̯"/"ɑu̯"/gi
  97.   s/"aʊ̯"/"ɑu̯"/gi
  98.   s/"aʁ"/"ɑː"/gi
  99.   s/"aʕʷ"/"ɑː"/gi
  100.   s/"æə̯"/"ɑː"/gi
  101.   s/"æɪ̯"/"ɛː"/gi
  102.   s/"æʏ̯"/"eu̯"/gi
  103.   s/"æʊ̯"/"ɑu̯"/gi
  104.   s/"æʁ"/"ɑː"/gi
  105.   s/"æʕʷ"/"ɑː"/gi
  106.   s/"əɪ̯"/"eː"/gi
  107.   s/"əʏ̯"/"eu̯"/gi
  108.   s/"əʊ̯"/"eu̯"/gi
  109.   s/"əʁ"/"ɛː"/gi
  110.   s/"əʕʷ"/"ɑː"/gi
  111.   s/"eə̯"/"eː"/gi
  112.   s/"eɪ̯"/"eː"/gi
  113.   s/"eʏ̯"/"eu̯"/gi
  114.   s/"eʊ̯"/"eu̯"/gi
  115.   s/"eʁ"/"ɛː"/gi
  116.   s/"eʕʷ"/"ɑː"/gi
  117.   s/"oə̯"/"ɑː"/gi
  118.   s/"oɪ̯"/"ɑi̯"/gi
  119.   s/"oʏ̯"/"ɑu̯"/gi
  120.   s/"oʊ̯"/"ɑu̯"/gi
  121.   s/"oʁ"/"ɑː"/gi
  122.   s/"oʕʷ"/"ɑː"/gi
  123.   s/"øə̯"/"ɑː"/gi
  124.   s/"øɪ̯"/"ɑi̯"/gi
  125.   s/"øʏ̯"/"ɑu̯"/gi
  126.   s/"øʊ̯"/"ɑu̯"/gi
  127.   s/"øʁ"/"ɑː"/gi
  128.   s/"øʕʷ"/"ɑː"/gi
  129.   s/"ɨə̯"/"iː"/gi
  130.   s/"ɨʏ̯"/"iu̯"/gi
  131.   s/"ɨʊ̯"/"iu̯"/gi
  132.   s/"ɨʁ"/"ɛː"/gi
  133.   s/"ɨʕʷ"/"ɛː"/gi
  134.   s/"iə̯"/"iː"/gi
  135.   s/"iʏ̯"/"iu̯"/gi
  136.   s/"iʊ̯"/"iu̯"/gi
  137.   s/"iʁ"/"ɛː"/gi
  138.   s/"iʕʷ"/"ɛː"/gi
  139.   s/"uə̯"/"uː"/gi
  140.   s/"uɪ̯"/"ui̯"/gi
  141.   s/"uʁ"/"ɔː"/gi
  142.   s/"uʕʷ"/"ɔː"/gi
  143.   s/"yə̯"/"uː"/gi
  144.   s/"yɪ̯"/"ui̯"/gi
  145.   s/"yʁ"/"ɔː"/gi
  146.   s/"yʕʷ"/"ɔː"/gi
  147.   s/"a"/"ɑ"/gi
  148.   s/"æ"/"ɑ"/gi
  149.   s/"ə"/"e"/gi
  150.   s/"e"/"e"/gi
  151.   s/"o"/"ɑ"/gi
  152.   s/"ø"/"ɑ"/gi
  153.   s/"ɨ"/"i"/gi
  154.   s/"i"/"i"/gi
  155.   s/"u"/"u"/gi
  156.   s/"y"/"u"/gi
  157.   s/"ʁ"((?:$Consonant)+|\b)/"ɑ"$1/gi
  158.   s/"ʁ"/"r"/gi
  159.   s/"ʕʷ"/""/gi
  160.   #Aspirated -> Fricative
  161.   for(my $i = 0; $i < @AspiratedStop; $i++) {
  162.     # retrieve the source
  163.     my $item = @AspiratedStop[$i];
  164.     # and replacement
  165.     my $rplc = @NonAspirant[$i];
  166.  
  167.     # replace the source by replacement inside the boundaries
  168.     s/$item/$rplc/gi
  169.  
  170.   }
  171.  #Depaaltalization
  172.  s/"ʲ"/""/gi
  173.  s/"t͡ɕ"/"ç"/gi
  174.  s/"ɕ"/"ç"/gi
  175.  s/"d͡ʑ"/"j"/gi
  176.  s/"ʑ"/"j"/gi
  177.  s/"ʎ"/"j"/gi
  178.   for(my $i = 0; $i < @RetroflexShibilant; $i++) {
  179.     # retrieve the source
  180.     my $item = @RetroflexShibilant[$i];
  181.     # and replacement
  182.     my $rplc = @Sibilant[$i];
  183.  
  184.     # replace the source by replacement inside the boundaries
  185.     s/$item/$rplc/gi
  186.  
  187.   }
  188.   for(my $i = 0; $i < @PalatalShibilant; $i++) {
  189.     # retrieve the source
  190.     my $item = @PalatalShibilant[$i];
  191.     # and replacement
  192.     my $rplc = @Sibilant[$i];
  193.  
  194.     # replace the source by replacement inside the boundaries
  195.     s/$item/$rplc/gi
  196.  
  197.   }
  198.   # Go through each "source" => "replacement"
  199.   for(my $i = 0; $i < @LenitableStop; $i++) {
  200.     # retrieve the source
  201.     my $item = @LenitableStop[$i];
  202.     # and replacement
  203.     my $rplc = @VoicedFricative[$i];
  204.  
  205.     # replace the source by replacement inside the boundaries
  206.     s/$item((?:$PhumVowels)+|\b)/$rplc$1/gi
  207.  
  208.   }
  209.    #Intervocalic voicing of voiceless fricatives
  210.     s/((?:$PhumVowels)+)"z"((?:$PhumVowels)+)/$1"z"$2/gi
  211.   # Go through each "source" => "replacement"
  212.   for(my $i = 0; $i < @VoicelessFricative; $i++) {
  213.     # retrieve the source
  214.     my $item = @VoicelessFricative[$i];
  215.     # and replacement
  216.     my $rplc = @VoicedFricative[$i];
  217.  
  218.     # replace the source by replacement inside the boundaries
  219.     s/((?:$PhumVowels)+)$item((?:$PhumVowels)+)/$1$rplc$2/gi
  220.  
  221.   }
  222.  
  223.   s/"ŋ"((?:$Consonant)+|\b)/"n"$1/gi
  224.  s/"ŋ"/"ɣ"/gi
  225.   # insert any other transformations here
  226.   s/"g"/"ɣ"/gi
  227.   s/"nɣ"/"ng"/gi
  228.  
  229.   # print the line after modifications
  230.   print;
  231. }
  232.  
  233. close($fh);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement