Darstellen von Konjugationstabellen in C #

Ich entwerfe einen Sprachanalysator für französischen Text. Ich habe ein Wörterbuch im XML-Format, das so aussieht:

<?xml version="1.0" encoding="utf-8"?>
<Dictionary>
  <!--This is the base structure for every entry in the dictionary. Values on attributes are given
    as explanations for the attributes. Though this is the structure of the finished product for each word, definition, context and context examples will be ommitted as they don't have a real effect on the application at this moment. Defini-->
  <Word word="The word in the dictionary (any word that would be defined)." aspirate="Whether or not the word starts with an aspirate h. Some adjectives that come before words that start with a non-aspirate h have an extra form (AdjectiveForms -&gt; na [non-aspirate]).">
      <GrammaticalForm form="The grammatical form of the word is the grammatical context in which it is used. Forms may consist of a word in noun, adjective, adverb, exclamatory or other form. Each form (generally) has its own definition, as the meaning of the word changes in the way it is used.">
        <Definition definition=""></Definition>
      </GrammaticalForm>
    <ConjugationTables>
      <NounForms ms="The masculin singular form of the noun." fs="The feminin singular form of the noun." mpl="The masculin plural form of the noun." fpl="The feminin plural form of the noun." gender="The gender of the noun. Determines"></NounForms>
      <AdjectiveForms ms="The masculin singular form of the adjective." fs="The feminin singular form of the adjective." mpl="The masculin plural form of the adjective." fpl="The feminin plural form of the adjective." na="The non-aspirate form of the adjective, in the case where the adjective is followed by a non-aspirate word." location="Where the adjective is placed around the noun (before, after, or both)."></AdjectiveForms>
      <VerbForms group="What group the verb belongs to (1st, 2nd, 3rd or exception)." auxillary="The auxillary verb taken by the verb." prepositions="A CSV list of valid prepositions this verb uses; for grammatical analysis." transitive="Whether or not the verb is transitive." pronominal="The pronominal infinitive form of the verb, if the verb allows pronominal construction.">
        <Indicative>
          <Present fps="(Je) first person singular." sps="(Tu) second person singular." tps="(Il) third person singular." fpp="(Nous) first person plural." spp="(Vous) second person plural." tpp="(Ils) third person plural."></Present>
          <SimplePast fps="(Je) first person singular." sps="(Tu) second person singular." tps="(Il) third person singular." fpp="(Nous) first person plural." spp="(Vous) second person plural." tpp="(Ils) third person plural."></SimplePast>
          <PresentPerfect fps="(Je) first person singular." sps="(Tu) second person singular." tps="(Il) third person singular." fpp="(Nous) first person plural." spp="(Vous) second person plural." tpp="(Ils) third person plural."></PresentPerfect>
          <PastPerfect fps="(Je) first person singular." sps="(Tu) second person singular." tps="(Il) third person singular." fpp="(Nous) first person plural." spp="(Vous) second person plural." tpp="(Ils) third person plural."></PastPerfect>
          <Imperfect fps="(Je) first person singular." sps="(Tu) second person singular." tps="(Il) third person singular." fpp="(Nous) first person plural." spp="(Vous) second person plural." tpp="(Ils) third person plural."></Imperfect>
          <Pluperfect fps="(Je) first person singular." sps="(Tu) second person singular." tps="(Il) third person singular." fpp="(Nous) first person plural." spp="(Vous) second person plural." tpp="(Ils) third person plural."></Pluperfect>
          <Future fps="(Je) first person singular." sps="(Tu) second person singular." tps="(Il) third person singular." fpp="(Nous) first person plural." spp="(Vous) second person plural." tpp="(Ils) third person plural."></Future>
          <PastFuture fps="(Je) first person singular." sps="(Tu) second person singular." tps="(Il) third person singular." fpp="(Nous) first person plural." spp="(Vous) second person plural." tpp="(Ils) third person plural."></PastFuture>
        </Indicative>
        <Subjunctive>
          <Present fps="(Je) first person singular." sps="(Tu) second person singular." tps="(Il) third person singular." fpp="(Nous) first person plural." spp="(Vous) second person plural." tpp="(Ils) third person plural."></Present>
          <Past fps="(Je) first person singular." sps="(Tu) second person singular." tps="(Il) third person singular." fpp="(Nous) first person plural." spp="(Vous) second person plural." tpp="(Ils) third person plural."></Past>
          <Imperfect fps="(Je) first person singular." sps="(Tu) second person singular." tps="(Il) third person singular." fpp="(Nous) first person plural." spp="(Vous) second person plural." tpp="(Ils) third person plural."></Imperfect>
          <Pluperfect fps="(Je) first person singular." sps="(Tu) second person singular." tps="(Il) third person singular." fpp="(Nous) first person plural." spp="(Vous) second person plural." tpp="(Ils) third person plural."></Pluperfect>
        </Subjunctive>
        <Conditional>
          <Present fps="(Je) first person singular." sps="(Tu) second person singular." tps="(Il) third person singular." fpp="(Nous) first person plural." spp="(Vous) second person plural." tpp="(Ils) third person plural."></Present>
          <FirstPast fps="(Je) first person singular." sps="(Tu) second person singular." tps="(Il) third person singular." fpp="(Nous) first person plural." spp="(Vous) second person plural." tpp="(Ils) third person plural."></FirstPast>
          <SecondPast fps="(Je) first person singular." sps="(Tu) second person singular." tps="(Il) third person singular." fpp="(Nous) first person plural." spp="(Vous) second person plural." tpp="(Ils) third person plural."></SecondPast>
        </Conditional>
        <Imperative>
          <Present sps="(Tu) second person singular." fpp="(Nous) first person plural." spp="(Vous) second person plural."></Present>
          <Past sps="(Tu) second person singular." fpp="(Nous) first person plural." spp="(Vous) second person plural."></Past>
        </Imperative>
        <Infinitive present="The present infinitive form of the verb." past="The past infinitive form of the verb."></Infinitive>
        <Participle present="The present participle of the verb." past="The past partciple of the verb."></Participle>
      </VerbForms>
    </ConjugationTables>
  </Word>
</Dictionary>

Es tut uns leid, es ist so lang, aber es muss genau gezeigt werden, wie die Daten modelliert sind (Baumknotenstruktur).

Zur Zeit benutze ichstructs die Konjugationstabellen modellieren, verschachteltstructs um genauer zu sein. Hier ist die Klasse, die ich erstellt habe, um das zu modellieren, was istein einziger Eintrag in der XML-Datei:

class Word
{
    public string word { get; set; }
    public bool aspirate { get; set; }
    public List<GrammaticalForms> forms { get; set; }

    struct GrammaticalForms
    {
        public string form { get; set; }
        public string definition { get; set; }
    }

    struct NounForms
    {
        public string gender { get; set; }
        public string masculinSingular { get; set; }
        public string femininSingular { get; set; }
        public string masculinPlural { get; set; }
        public string femininPlural { get; set; }
    }

    struct AdjectiveForms
    {
        public string masculinSingular { get; set; }
        public string femininSingular { get; set; }
        public string masculinPlural { get; set; }
        public string femininPlural { get; set; }
        public string nonAspirate { get; set; }
        public string location { get; set; }
    }

    struct VerbForms
    {
        public string group { get; set; }
        public string auxillary { get; set; }
        public string[] prepositions { get; set; }
        public bool transitive { get; set; }
        public string pronominalForm { get; set; }

        struct IndicativePresent
        {
            public string firstPersonSingular { get; set; }
            public string secondPersonSingular { get; set; }
            public string thirdPersonSingular { get; set; }
            public string firstPersonPlural { get; set; }
            public string secondPersonPlural { get; set; }
            public string thirdPersonPlural { get; set; }
        }
        struct IndicativeSimplePast
        {
            public string firstPersonSingular { get; set; }
            public string secondPersonSingular { get; set; }
            public string thirdPersonSingular { get; set; }
            public string firstPersonPlural { get; set; }
            public string secondPersonPlural { get; set; }
            public string thirdPersonPlural { get; set; }
        }
        struct IndicativePresentPerfect
        {
            public string firstPersonSingular { get; set; }
            public string secondPersonSingular { get; set; }
            public string thirdPersonSingular { get; set; }
            public string firstPersonPlural { get; set; }
            public string secondPersonPlural { get; set; }
            public string thirdPersonPlural { get; set; }
        }
        struct IndicativePastPerfect
        {
            public string firstPersonSingular { get; set; }
            public string secondPersonSingular { get; set; }
            public string thirdPersonSingular { get; set; }
            public string firstPersonPlural { get; set; }
            public string secondPersonPlural { get; set; }
            public string thirdPersonPlural { get; set; }
        }
        struct IndicativeImperfect
        {
            public string firstPersonSingular { get; set; }
            public string secondPersonSingular { get; set; }
            public string thirdPersonSingular { get; set; }
            public string firstPersonPlural { get; set; }
            public string secondPersonPlural { get; set; }
            public string thirdPersonPlural { get; set; }
        }
        struct IndicativePluperfect
        {
            public string firstPersonSingular { get; set; }
            public string secondPersonSingular { get; set; }
            public string thirdPersonSingular { get; set; }
            public string firstPersonPlural { get; set; }
            public string secondPersonPlural { get; set; }
            public string thirdPersonPlural { get; set; }
        }
        struct IndicativeFuture
        {
            public string firstPersonSingular { get; set; }
            public string secondPersonSingular { get; set; }
            public string thirdPersonSingular { get; set; }
            public string firstPersonPlural { get; set; }
            public string secondPersonPlural { get; set; }
            public string thirdPersonPlural { get; set; }
        }
        struct IndicativePastFuture
        {
            public string firstPersonSingular { get; set; }
            public string secondPersonSingular { get; set; }
            public string thirdPersonSingular { get; set; }
            public string firstPersonPlural { get; set; }
            public string secondPersonPlural { get; set; }
            public string thirdPersonPlural { get; set; }
        }

        struct SubjunctivePresent
        {
            public string firstPersonSingular { get; set; }
            public string secondPersonSingular { get; set; }
            public string thirdPersonSingular { get; set; }
            public string firstPersonPlural { get; set; }
            public string secondPersonPlural { get; set; }
            public string thirdPersonPlural { get; set; }
        }
        struct SubjunctivePast
        {
            public string firstPersonSingular { get; set; }
            public string secondPersonSingular { get; set; }
            public string thirdPersonSingular { get; set; }
            public string firstPersonPlural { get; set; }
            public string secondPersonPlural { get; set; }
            public string thirdPersonPlural { get; set; }
        }
        struct SubjunctiveImperfect
        {
            public string firstPersonSingular { get; set; }
            public string secondPersonSingular { get; set; }
            public string thirdPersonSingular { get; set; }
            public string firstPersonPlural { get; set; }
            public string secondPersonPlural { get; set; }
            public string thirdPersonPlural { get; set; }
        }
        struct SubjunctivePluperfect
        {
            public string firstPersonSingular { get; set; }
            public string secondPersonSingular { get; set; }
            public string thirdPersonSingular { get; set; }
            public string firstPersonPlural { get; set; }
            public string secondPersonPlural { get; set; }
            public string thirdPersonPlural { get; set; }
        }

        struct ConditionalPresent
        {
            public string firstPersonSingular { get; set; }
            public string secondPersonSingular { get; set; }
            public string thirdPersonSingular { get; set; }
            public string firstPersonPlural { get; set; }
            public string secondPersonPlural { get; set; }
            public string thirdPersonPlural { get; set; }
        }
        struct ConditionalFirstPast
        {
            public string firstPersonSingular { get; set; }
            public string secondPersonSingular { get; set; }
            public string thirdPersonSingular { get; set; }
            public string firstPersonPlural { get; set; }
            public string secondPersonPlural { get; set; }
            public string thirdPersonPlural { get; set; }
        }
        struct ConditionalSecondPast
        {
            public string firstPersonSingular { get; set; }
            public string secondPersonSingular { get; set; }
            public string thirdPersonSingular { get; set; }
            public string firstPersonPlural { get; set; }
            public string secondPersonPlural { get; set; }
            public string thirdPersonPlural { get; set; }
        }

        struct ImperativePresent
        {
            public string secondPersonSingular { get; set; }
            public string firstPersonPlural { get; set; }
            public string secondPersonPlural { get; set; }
        }
        struct ImperativePast
        {
            public string secondPersonSingular { get; set; }
            public string firstPersonPlural { get; set; }
            public string secondPersonPlural { get; set; }
        }

        struct Infinitive
        {
            public string present { get; set; }
            public string past { get; set; }
        }

        struct Participle
        {
            public string present { get; set; }
            public string past { get; set; }
        }
    }
}

Ich bin neu in C # und mit den Datenstrukturen nicht allzu vertraut. Aufgrund meiner begrenzten Kenntnisse in C ++ weiß ich dasstructs sind nützlich, wenn Sie kleine, in hohem Maße verwandte Datenelemente modellieren, weshalb ich sie derzeit auf diese Weise verwende.

Alle diese Strukturen könnten realistisch zu einerKonjugationstabellen classund hätte in hohem Maße die gleiche Struktur. Ich bin nicht sicher, ob ich diese in eine Klasse umwandeln oder eine andere Datenstruktur verwenden soll, die für das Problem besser geeignet wäre. Um weitere Informationen zu den Problemspezifikationen zu erhalten, sage ich Folgendes:

Sobald diese Werte aus der XML-Datei geladen wurden, werden sienicht geändert werden.Diese Werte werdensehr oft gelesen / geholt.Die tischähnliche Strukturmuss gepflegt werden - das heißt dasIndicativePresent muss unter verschachtelt seinVerbForms; Gleiches gilt für alle anderen Strukturen, die Mitglieder der sindVerbForms struct. Dies sind KonjugationenTabellen Letztendlich!Vielleicht das wichtigste: Ich muss die Organisation der Daten so einrichten, dass zum Beispiel aWord in der XML-Datei hat keineGrammaticalForm vonVerb, das nichtVerbForms Für diesen Eintrag wird tatsächlich eine Struktur erstellt. Auf diese Weise soll die Effizienz verbessert werden - warum instanziieren?VerbForms Ist das Wort eigentlich kein Verb? Diese Idee, die unnötige Erstellung dieser "Formular" -Tabellen zu vermeiden (die derzeit als dargestellt werden)struct XXXXXForms) ist unbedingt erforderlich.

In Übereinstimmung mit (hauptsächlich) Punkt# 4 oben, welche Arten von Datenstrukturen würden am besten bei der Modellierung der Konjugation verwendetTabellen (nichtDatenbank Tabellen)? Muss ich das Format meiner Daten ändern, um # 4 zu erfüllen? Wenn ich a instanziierenew WordWerden die Strukturen in ihrem aktuellen Zustand ebenfalls instanziiert und nehmen viel Platz ein? Hier ist ein bisschen Mathe ... nachdem du herumgegoogelt und schließlich gefunden hastdiese Frage...

In allen Konjugationstabellen (Substantive, Adjektive, Verben) gibt es insgesamt (Zufall?)100 strings zugewiesen, und das sind leer. Damit100 x 18 Bytes =1800 Bytes für jedenWordZumindest dann, wenn diese Datenstrukturen erstellt werden und leer bleiben (es wird immer mindestens ein gewisser Overhead für die Werte vorhanden sein, die tatsächlich ausgefüllt würden). Also angenommen (nur zufällig, könnte mehr oder weniger sein)50.000 WordDas müsste in Erinnerung bleiben90 Millionen Bytesoder ungefähr85.8307 Megabyte.

Das ist viel Aufwand, nur um leere Tische zu haben. Auf welche Weise kann ich diese Daten zusammenfassen, damit ich sie instanziieren kann?nur bestimmte Tabellen (Substantiv, Adjektiv, Verb) es hängt davon abWasGrammaticalForms dasWord hat eigentlich (in der XML-Datei).

Ich möchte, dass diese Tische ein Mitglied von sindWord Klasse, aber instanziieren nur die Tabellen, die ich brauche. Ich kann mir keinen Ausweg vorstellen, und jetzt, wo ich die Mathematik auf dem gemacht habestructs Ich weiß, dass es keine gute Lösung ist. Mein erster Gedanke ist, für jeden Typ eine Klasse zu erstellenNounForms, AdjectiveForms, undVerbFormsund instanziieren Sie die Klasse, wenn das Formular in der XML-Datei angezeigt wird. Ich bin mir nicht sicher, ob das richtig ist ...

Irgendwelche Vorschläge?

Antworten auf die Frage(3)

Ihre Antwort auf die Frage