Programming games in historical linguistics with Python
Hello, Following a discussion that began 3 weeks ago I would like to ask a question regarding substitution of letters according to grammatical rules in historical linguistics. I would like to automate the transformation of words according to complex rules of phonology and integrate that script in a visual environment. Here follows the previous thread: http://groups.google.com/group/comp.lang.python/browse_thread/thread/3c55f9f044c3252f/fe7c2c82ecf0dbf5?lnk=gstq=evolutionary+linguistics#fe7c2c82ecf0dbf5 Is there a way to refer to vowels and consonants as a subcategory of text? Is there a function to remove all vowels? How should one create and order the dictionary file for the rules? How to chain several transformations automatically from multiple rules? Finally can anyone show me what existing python program or phonological software can do this? What function could tag syllables, the word nucleus and the codas? How easy is it to bridge this with a more visual environment where interlinear, aligned text can be displayed with Greek notations and braces as usual in the phonology textbooks? Best regards, Dax Bloom -- http://mail.python.org/mailman/listinfo/python-list
Re: Using Python for a demonstration in historical linguistics
On Nov 6, 6:41 am, Vlastimil Brom vlastimil.b...@gmail.com wrote: 2010/11/6 Dax Bloom bloom@gmail.com: Hello, In the framework of a project on evolutionary linguistics I wish to have a program to process words and simulate the effect of sound shift, for instance following the Rask's-Grimm's rule. I look to have python take a dictionary file or a string input and replace the consonants in it with the Grimm rule equivalent. For example: bʰ → b → p → f dʰ → d → t → θ gʰ → g → k → x gʷʰ → gʷ → kʷ → xʷ If the dictionary file has the word Abe I want the program to replace the letter b with f forming the word Afe and write the result in a tabular file. How easy is it to find the python functions to do that? Best regards, Dax Bloom -- http://mail.python.org/mailman/listinfo/python-list Hi, I guess, the most difficult part would be, to select appropriate words, to apply the simple rules on (in order not to get problems with Verner's Law or other special rules). You also normally wouldn't want to chain the changes like the above, but to keep them separated bʰ → b; p → f (ie. *bʰrāter- ... brother and not *p-... (at least without the High German consonant shift)). of course, there are also vowel changes to be dealt with and many more peculiarities ... As for implementation, I guess, the simplest way might be to use regular expression replacements - re.sub(...) with a replace function looking up the appropriate results in a dictionary. maybe something along the lines: Rask_Grimm_re = ur[bdgptk]ʰ? Rask_Grimm_dct = {ub:up, ubʰ: ub, ut: uþ, } # ... def repl_fn(m): return Rask_Grimm_dct.get(m.group(), m.group()) ie_txt = u bʰrāter ... almost_germ_txt = re.sub(Rask_Grimm_re, repl_fn, ie_txt) print u%s %s % (ie_txt, almost_germ_txt) # vowel changes etc. TBD bʰrāter ... brāþer ... hth, vbr Hello, Thx to every one of you for the prompt response. Resuming the thread of November 5 on evolutionary linguistics, is there a way to refer to a sub-category of text like vowels or consonants? If not, is there a way to optimize the code by creating these sub-categories? I would need to arrange substitution rules into groups because there might be a whole lot more than the ones I mentioned in the example on Rask-Grimm rule; I would like each substitution to produce a new entry and not all substitutions to result in a single entry. I want to do things in two steps (or ‘passes’) and apply to the results of the group 1 of rules the rules of group 2. I understand that it could be particularly useful for the study of phonology to have a dynamic analysis system with adjustable rules; in this branch of linguistics parts of a word like the nucleus or the codas are tagged with abbreviatory notations explaining ‘phonological processes’ with schemas; such historical mutations of language as the metathesis, the prothesis, the anaptyxis or fusional assimilation could be included among the rules that we mentioned for the substitution. It might require the replacing of certain letters with Greek notation in applying phonological processes. What function could tag syllables, the word nucleus and the codas? How easy is it to bridge this with a more visual environment where schematic analysis can be displayed with highlights and notations such as in the phonology textbooks? To outline the goals of the program: 1) Arranging rules for substitution into groups of rules 2) Applying substitutions to string input in logic of “Multiple pass multiple replace” 3) Returning a string for each substitution 4) Making program environment visual When quoting parts of code can you please precise where to insert them in the code and what the variables mean? Best wishes, Dax Bloom -- http://mail.python.org/mailman/listinfo/python-list
Re: Using Python for a demonstration in historical linguistics
On Nov 6, 6:18 am, Peter Otten __pete...@web.de wrote: Peter Otten wrote: s = ... In the framework of a project onevolutionarylinguisticsI wish to ... have a program to process words and simulate the effect of sound ... shift, for instance following the Rask's-Grimm's rule. I look to have ... python take a dictionary file or a string input and replace the ... consonants in it with the Grimm rule equivalent. For example: ... rules = [bpf, (d, t, th), gkx] for rule in rules: ... rule = rule[::-1] # go back in time ... for i in range(len(rule)-1): ... s = s.replace(rule[i], rule[i+1]) ... Warning: this simple-minded approach somewhat limits the possible rules. E. g. it fails for a -- b b -- a abba.replace(a, b).replace(b, a) '' while unicode.translate() can deal with it: uabba.translate({ord(ua): ub, ord(ub): ua}) u'baab' Or, if you are using Python 3.x as Steven suggested: abba.translate({ord(a): b, ord(b): a}) 'baab' Peter Hi Peter, I read your interesting replies 20 days ago and after several exams and a university semester, I would like to address more fully your answers to my post. However could you please clarify some of the code inputs that you suggested and in what order to insert them in the script? s = ... In the framework of a project onevolutionarylinguisticsI wish to ... have a program to process words and simulate the effect of sound ... shift, for instance following the Rask's-Grimm's rule. I look to have ... python take a dictionary file or a string input and replace the ... consonants in it with the Grimm rule equivalent. For example: ... rules = [bpf, (d, t, th), gkx] for rule in rules: ... rule = rule[::-1] # go back in time ... for i in range(len(rule)-1): ... s = s.replace(rule[i], rule[i+1]) ... Best regards, Dax Bloom -- http://mail.python.org/mailman/listinfo/python-list
Using Python for a demonstration in historical linguistics
Hello, In the framework of a project on evolutionary linguistics I wish to have a program to process words and simulate the effect of sound shift, for instance following the Rask's-Grimm's rule. I look to have python take a dictionary file or a string input and replace the consonants in it with the Grimm rule equivalent. For example: bʰ → b → p → f dʰ → d → t → θ gʰ → g → k → x gʷʰ → gʷ → kʷ → xʷ If the dictionary file has the word Abe I want the program to replace the letter b with f forming the word Afe and write the result in a tabular file. How easy is it to find the python functions to do that? Best regards, Dax Bloom -- http://mail.python.org/mailman/listinfo/python-list