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 = {u"b":u"p", u"bʰ": u"b", u"t": 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