简体   繁体   中英

How can you extract all 6 letter Latin words to a list?

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.

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.

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 (eg mensa ) have a six-letter genitive case (eg 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM