views:

705

answers:

2

I need to have all 6 letter Latin words in a list.

I would also like to have words which follow the pattern Xyzzyx in a list.

I have used little Python.

+5  A: 

Regular expressions are your friend, my friend! Is this homework?

Here's an example that's close to what you want:

egrep "^\w{6}$" /usr/share/dict/words | egrep "(.)(.)(.)\3\2\1"

I'll leave it as an exercise for the reader to create a latin word list and deal with the uppercase X in the second regex, but the general idea should be evident.

jcrossley3
I thought you wuz his friend, not Regex! :P
Cerebrus
Is Python suitable for scraping the Latin words to a list?
Masi
I'm sure it is. Any language that has a built-in Regular Expressions engine should be able to do it.
Cerebrus
Thank you! I managed to find those words directly in Terminal, without Python with your code :)
Masi
You're welcome! Always nice when you can find the tool most appropriate for the job. :-)
jcrossley3
A: 

Note that unless your list contains all of the nouns' declensions and verbs' conjugations, your program won't produce anything like all the six-letter words in Latin.

For instance, your list probably contains only the nominative case of the nouns. First-declension nouns whose nominative case is five letters long (e.g. mensa) have a six-letter genitive case (e.g. mensae). All of the declensions contain cases where the noun's length is different from its nominative case.

The same's even more true of verbs, each of which have (at least) four principal parts, which can be of varying length, and whose conjugations can be of varying lengths as well. So the first-person singular present tense of lego is four letters long, but its infinitive legere is six; porto is five in the first-person singular but six in the the second-person singular, portas.

I suppose it's possible in principle to build an engine that programmatically declines and conjugates Latin words given enough metainformation about each word. Python would actually be a pretty good language to do that in. But that's a much bigger task than just writing a regular expression.

Robert Rossney