Skip to content

Instantly share code, notes, and snippets.

@asterite
Last active December 16, 2015 02:40
Show Gist options
  • Save asterite/efe736c300033f556abd to your computer and use it in GitHub Desktop.
Save asterite/efe736c300033f556abd to your computer and use it in GitHub Desktop.
# Just a single definite article ("the")
definite_articles = %w(la)
# No indefinite articles ("a", "an")
indefinite_articles = nil
# Numbers can be combined, so "twenty three" is "du-dek tri" (2*10 + 3)
numbers = %w(nulo unu du tri kvar kvin sep sep ok nau dek cent mil miliono)
# I, you, he, she, ...
pronouns = %w(mi vi li ŝi ĝi ni ili oni si)
# To, instead, before, at, while, of, inside, under, etc.
prepositions = %w(al anstataŭ antaŭ apud ĉe ĉirkaŭ da de dum ekster el en
ĝis inter je kontraŭ krom kun laŭ malantaŭ malgraŭ per po por post preter
pri pro sen sub super sur tra trans)
# Combine these words for a few meanings. For example:
# - ki...: question word
# - neni...: absence
# - ...u: person
# - ...o: object
# - ...am: time
#
# So:
# - kiu = who
# - kio = what
# - kiam = when
# - neniu = nobody
# - nenio = nothing
# - neniam = never
correlatives = %w(ki ti i ĉi neni).product(%w(u o a e en am om el al es)).map(&.join)
while word = gets
word = word.chomp
case
when definite_articles.includes?(word) then "article"
when numbers.includes?(word) then puts "number"
when pronouns.includes?(word) then puts "pronoun"
when prepositions.includes?(word) then puts "preposition"
when correlatives.includes?(word) then puts "correlative"
when word.ends_with? "o" then puts "noun"
when word.ends_with? "a" then puts "adjective"
when word.ends_with? "e" then puts "adverb"
when word.ends_with? "i" then puts "verb (infinitive)"
when word.ends_with? "as" then puts "verb (present)"
when word.ends_with? "is" then puts "verb (past)"
when word.ends_with? "os" then puts "verb (future)"
when word.ends_with? "us" then puts "verb (conditional)"
when word.ends_with? "u" then puts "verb (imperative)"
else puts "other"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment