Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gramadan-scala

A Scala 3 port of the Gramadán Irish-language morphology library.

Gramadán inflects Irish nouns, adjectives, verbs, prepositions, and noun/verbal phrases according to the grammar rules of Modern Irish, and can serialise the results to NEID-compatible XML.

Features

  • Phonology engine — character-level predicates for Irish vowels, consonants, broad/slender distinction, and vowel cluster detection
  • Initial mutations — all 13 mutation types (lenition variants Len1–Len3D, eclipsis variants Ecl1–Ecl3, PrefT, PrefH) applied via Mutations.mutate
  • Stem operations — slenderisation, broadening, syncope, prefix attachment, and emphasizer attachment (StemOps)
  • Noun inflection — five-declension paradigm with singular nominative/genitive/vocative/dative and plural nominative/genitive/vocative slots, plus counting forms; BuNaMo XML import
  • Adjective inflection — gender-differentiated singular genitive/vocative, shared plural nominative, graded form, abstract noun, and all four comparative/superlative surface forms
  • Verb inflection — full tense × dependency × person grid (past, past-continuous, present, present-continuous, future, conditional — independent and dependent), imperative and subjunctive moods, verbal noun and verbal adjective
  • Personal prepositions — seven-cell paradigm (sg1/sg2/sg3masc/sg3fem/pl1/pl2/pl3)
  • Noun phrases — head noun ± postpositive or prefixed adjective ± possessive pronoun; unarticulated and articulated forms (including northern/southern dative-with-article variants)
  • Verbal phrases — tense-rule–driven surface forms across tense, person, shape (declarative/interrogative), and polarity
  • Prepositional phrases — combination of preposition and noun phrase with articled variants
  • NEID XML outputPrinter object serialises any inflected type to the NEID XML format used by Foclóir.ie and related tools

Project structure

src/main/scala/gramadan/
├── phonology/
│   ├── Phonology.scala      # Character-level predicates and constants
│   ├── MutationType.scala   # Enum of all 13 Irish initial mutations
│   ├── StemOps.scala        # Slenderisation, broadening, syncope, prefix ops
│   └── EmphasizerType.scala # Emphatic suffix enum
├── inflection/
│   ├── Grammar.scala        # Core grammatical enumerations (Gender, Case, etc.)
│   ├── Forms.scala          # Form, FormSg, FormPlGen value types
│   ├── SingularInfo.scala   # Strategy objects for singular paradigm derivation
│   ├── PluralInfo.scala     # Strategy objects for plural paradigm derivation
│   ├── Noun.scala           # Noun class + apply / fromForms / fromXml constructors
│   ├── Adjective.scala      # Adjective class + fromForms / fromXml constructors
│   ├── Verb.scala           # Verb class with full tense/mood grid
│   ├── Preposition.scala    # Personal preposition class
│   └── Possessive.scala     # Possessive pronoun class
├── phrase/
│   ├── NounPhrase.scala     # Noun phrase builder (head, adjective, possessive)
│   └── VerbalPhrase.scala   # Verbal phrase builder
└── output/
    └── Printer.scala        # NEID XML serialiser for all types

Requirements

  • Scala 3.3.x
  • sbt 1.x
  • JVM 11+

Build and test

sbt compile
sbt test

Usage examples

Inflect a noun

import gramadan.inflection.*

val sing = SingularInfo.First("bád")    // 1st declension strategy
val plur = PluralInfo.Slender("báid")   // slender plural strategy
val noun = Noun("bád", Gender.Masc, declension = 1, sing, plur)

println(noun.sgNom.head.value)  // bád
println(noun.sgGen.head.value)  // báid
println(noun.plNom.head.value)  // báid

Build a noun phrase with an article

import gramadan.phrase.NounPhrase

val np = NounPhrase(noun, isDefinite = true)
println(np.sgNomArt.head.value)  // an bád

Parse from BuNaMo XML

import gramadan.inflection.Noun
import scala.xml.XML

val xml = XML.loadFile("bád.xml")
val noun = Noun.fromXml(xml.head.asInstanceOf[scala.xml.Elem])

Serialise to NEID XML

import gramadan.output.Printer

println(Printer.noun(noun))
println(Printer.nounPhrase(np))

Relationship to the original Gramadán

The original Gramadán library is a C# project by Michal Měchura. This port targets Scala 3 and follows the same domain model (BuNaMo XML input, NEID XML output) while using idiomatic Scala 3 features: opaque enums, case classes, extension methods, and pattern matching.

License

See the original Gramadán project for licensing context. This port is a derivative work.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages