From 977d5ccdb2db2e0ba662f9c1e7289724238d454a Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Sat, 29 Sep 2007 12:49:14 +0000 Subject: [PATCH] Use Neutral everywhere instead of Neuter. Make localization for special types work. svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=718659 --- keduvocdocument/keduvocconjugation.h | 4 +- keduvocdocument/keduvocdeclination.h | 7 -- keduvocdocument/keduvocgrammar.cpp | 4 +- keduvocdocument/keduvocgrammar.h | 2 +- keduvocdocument/keduvockvtml2reader.cpp | 85 ++++++------- keduvocdocument/keduvockvtml2writer.cpp | 67 +++++----- keduvocdocument/keduvockvtmlreader.cpp | 16 +-- keduvocdocument/keduvockvtmlwriter.cpp | 6 +- keduvocdocument/keduvocpersonalpronoun.cpp | 18 +-- keduvocdocument/keduvocpersonalpronoun.h | 4 +- keduvocdocument/keduvocwordtype.cpp | 139 ++++++++------------- keduvocdocument/keduvocwordtype.h | 6 +- keduvocdocument/kvtml2defs.h | 15 ++- 13 files changed, 168 insertions(+), 205 deletions(-) diff --git a/keduvocdocument/keduvocconjugation.h b/keduvocdocument/keduvocconjugation.h index 4d87de9..56e17e2 100644 --- a/keduvocdocument/keduvocconjugation.h +++ b/keduvocdocument/keduvocconjugation.h @@ -43,13 +43,13 @@ public: NumberMAX }; - // store third person neuter/common in the same sttr + // store third person neutral/common in the same sttr enum ConjugationPerson { First, Second, ThirdMale, ThirdFemale, - ThirdNeuterCommon, + ThirdNeutralCommon, PersonMAX }; diff --git a/keduvocdocument/keduvocdeclination.h b/keduvocdocument/keduvocdeclination.h index dfd5ef0..7252579 100644 --- a/keduvocdocument/keduvocdeclination.h +++ b/keduvocdocument/keduvocdeclination.h @@ -37,13 +37,6 @@ public: Dual, Plural }; -/* - enum DeclinationGender { - Undefined, - Masculine, - Feminine, - Neuter - };*/ enum DeclinationCase { Nominative = 1, diff --git a/keduvocdocument/keduvocgrammar.cpp b/keduvocdocument/keduvocgrammar.cpp index 748c76c..948c89f 100644 --- a/keduvocdocument/keduvocgrammar.cpp +++ b/keduvocdocument/keduvocgrammar.cpp @@ -150,11 +150,11 @@ KEduVocArticle::KEduVocArticle( const QString &fem_def, const QString &fem_indef { setArticle( mal_def, Singular, Definite, Masculine ); setArticle( fem_def, Singular, Definite, Feminine ); - setArticle( neu_def, Singular, Definite, Neuter ); + setArticle( neu_def, Singular, Definite, Neutral ); setArticle( mal_indef, Singular, Indefinite, Masculine ); setArticle( fem_indef, Singular, Indefinite, Feminine ); - setArticle( neu_indef, Singular, Indefinite, Neuter ); + setArticle( neu_indef, Singular, Indefinite, Neutral ); } KEduVocArticle::~KEduVocArticle() diff --git a/keduvocdocument/keduvocgrammar.h b/keduvocdocument/keduvocgrammar.h index 3795e46..9679cf4 100644 --- a/keduvocdocument/keduvocgrammar.h +++ b/keduvocdocument/keduvocgrammar.h @@ -50,7 +50,7 @@ public: enum ArticleGender { Masculine, Feminine, - Neuter, + Neutral, GenderMAX }; diff --git a/keduvocdocument/keduvockvtml2reader.cpp b/keduvocdocument/keduvockvtml2reader.cpp index fa35d49..8e9255c 100644 --- a/keduvocdocument/keduvockvtml2reader.cpp +++ b/keduvocdocument/keduvockvtml2reader.cpp @@ -550,56 +550,49 @@ bool KEduVocKvtml2Reader::readTypes( QDomElement &typesElement ) // set type and specialtype mainTypeName = currentTypeElement.firstChildElement( KVTML_TYPENAME ).text(); - m_doc->wordTypes().addType( mainTypeName, - currentTypeElement.firstChildElement( KVTML_SPECIALWORDTYPE ).text() ); + + QString specialType = currentTypeElement.firstChildElement( KVTML_SPECIALWORDTYPE ).text(); + if ( !specialType.isEmpty() ) { + // get the localized version + if ( specialType == KVTML_SPECIALWORDTYPE_NOUN ) { + specialType = m_doc->wordTypes().specialTypeNoun(); + } + if ( specialType == KVTML_SPECIALWORDTYPE_VERB ) { + specialType = m_doc->wordTypes().specialTypeVerb(); + } + if ( specialType == KVTML_SPECIALWORDTYPE_ADVERB ) { + specialType = m_doc->wordTypes().specialTypeAdverb(); + } + if ( specialType == KVTML_SPECIALWORDTYPE_ADJECTIVE ) { + specialType = m_doc->wordTypes().specialTypeAdjective(); + } + } + m_doc->wordTypes().addType( mainTypeName, specialType ); // iterate sub type elements - QDomElement currentSubTypeElement = currentTypeElement.firstChildElement( KVTML_SUBWORDTYPEDEFINITION ); + QDomElement currentSubTypeElement = currentTypeElement.firstChildElement( KVTML_SUBWORDTYPEDEFINITION ); while ( !currentSubTypeElement.isNull() ) { + QString specialSubType = currentSubTypeElement.firstChildElement( KVTML_SPECIALWORDTYPE ).text(); + if ( !specialSubType.isEmpty() ) { + // get the localized version + if ( specialSubType == KVTML_SPECIALWORDTYPE_NOUN_MALE ) { + specialSubType = m_doc->wordTypes().specialTypeNounMale(); + } + if ( specialSubType == KVTML_SPECIALWORDTYPE_NOUN_FEMALE ) { + specialSubType = m_doc->wordTypes().specialTypeNounFemale(); + } + if ( specialSubType == KVTML_SPECIALWORDTYPE_NOUN_NEUTRAL ) { + specialSubType = m_doc->wordTypes().specialTypeNounNeutral(); + } + } // set type and specialtype m_doc->wordTypes().addSubType( mainTypeName, currentSubTypeElement.firstChildElement( KVTML_SUBTYPENAME ).text(), - currentSubTypeElement.firstChildElement( KVTML_SPECIALWORDTYPE ).text() ); - - + specialSubType ); currentSubTypeElement = currentSubTypeElement.nextSiblingElement( KVTML_SUBWORDTYPEDEFINITION ); } - - - - - currentTypeElement = currentTypeElement.nextSiblingElement( KVTML_WORDTYPEDEFINITION ); } - - - /* - for (int i = 0; i < typeNodes.count(); ++i) - { - QDomElement currentElement = typeNodes.item(i).toElement(); - if (currentElement.parentNode() == typesElement) - { - m_doc->wordTypes().addType(currentElement.text()); - } - }*/ - - - - - - - -// QDomNodeList typeNodes = typesElement.elementsByTagName(KVTML_WORDTYPEDEFINITION); -// for (int i = 0; i < typeNodes.count(); ++i) -// { -// QDomElement currentElement = typeNodes.item(i).toElement(); -// if (currentElement.parentNode() == typesElement) -// { -// m_doc->wordTypes().addType(currentElement.text()); -// } -// } - -// m_doc->setTypeDescriptions(types); return true; } @@ -796,9 +789,9 @@ bool KEduVocKvtml2Reader::readConjugationPerson(QDomElement & personElement, KEd conjugation.setConjugation( currentElement.text(), KEduVocConjugation::ThirdFemale, number ); - currentElement = personElement.firstChildElement( KVTML_THIRD_NEUTER_COMMON ); + currentElement = personElement.firstChildElement( KVTML_THIRD_NEUTRAL_COMMON ); conjugation.setConjugation( currentElement.text(), - KEduVocConjugation::ThirdNeuterCommon, number ); + KEduVocConjugation::ThirdNeutralCommon, number ); } @@ -806,8 +799,8 @@ bool KEduVocKvtml2Reader::readPersonalPronoun(QDomElement & pronounElement, KEdu { pronoun.setMaleFemaleDifferent(!pronounElement.firstChildElement( KVTML_THIRD_PERSON_MALE_FEMALE_DIFFERENT).isNull()); - pronoun.setNeuterExists( !pronounElement.firstChildElement( - KVTML_THIRD_PERSON_NEUTER_EXISTS).isNull() ); + pronoun.setNeutralExists( !pronounElement.firstChildElement( + KVTML_THIRD_PERSON_NEUTRAL_EXISTS).isNull() ); pronoun.setDualExists( !pronounElement.firstChildElement( KVTML_DUAL_EXISTS).isNull() ); @@ -846,9 +839,9 @@ bool KEduVocKvtml2Reader::readPersonalPronounChild(QDomElement & personElement, pronoun.setPersonalPronoun( currentElement.text(), KEduVocConjugation::ThirdFemale, number ); - currentElement = personElement.firstChildElement( KVTML_THIRD_NEUTER_COMMON ); + currentElement = personElement.firstChildElement( KVTML_THIRD_NEUTRAL_COMMON ); pronoun.setPersonalPronoun( currentElement.text(), - KEduVocConjugation::ThirdNeuterCommon, number ); + KEduVocConjugation::ThirdNeutralCommon, number ); } diff --git a/keduvocdocument/keduvockvtml2writer.cpp b/keduvocdocument/keduvockvtml2writer.cpp index 71e793b..a48bac9 100644 --- a/keduvocdocument/keduvockvtml2writer.cpp +++ b/keduvocdocument/keduvockvtml2writer.cpp @@ -238,11 +238,11 @@ bool KEduVocKvtml2Writer::writeArticle( QDomElement &articleElement, int article } // neutral - articleString = m_doc->identifier(article).article().article( KEduVocArticle::Singular, KEduVocArticle::Definite, KEduVocArticle::Neuter ); + articleString = m_doc->identifier(article).article().article( KEduVocArticle::Singular, KEduVocArticle::Definite, KEduVocArticle::Neutral ); if ( !articleString.isEmpty() ) { definite.appendChild( newTextElement( KVTML_NEUTRAL, articleString ) ); } - articleString = m_doc->identifier(article).article().article( KEduVocArticle::Singular, KEduVocArticle::Indefinite, KEduVocArticle::Neuter ); + articleString = m_doc->identifier(article).article().article( KEduVocArticle::Singular, KEduVocArticle::Indefinite, KEduVocArticle::Neutral ); if ( !articleString.isEmpty() ) { indefinite.appendChild( newTextElement( KVTML_NEUTRAL, articleString ) ); } @@ -271,35 +271,46 @@ bool KEduVocKvtml2Writer::writeTypes( QDomElement &typesElement ) kDebug() << "Writing type: " << mainTypeName; QDomElement typeDefinitionElement = m_domDoc.createElement( KVTML_WORDTYPEDEFINITION ); typeDefinitionElement.appendChild( newTextElement( KVTML_TYPENAME, mainTypeName ) ); - if ( !wt.specialType( mainTypeName ).isEmpty() ) { - typeDefinitionElement.appendChild( newTextElement( KVTML_SPECIALWORDTYPE, wt.specialType( mainTypeName ) ) ); + + QString specialType = wt.specialType( mainTypeName ); + if ( !specialType.isEmpty() ) { + // get the NOT localized version for the doc + if ( specialType == m_doc->wordTypes().specialTypeNoun() ) { + specialType = KVTML_SPECIALWORDTYPE_NOUN; + } + if ( specialType == m_doc->wordTypes().specialTypeVerb()) { + specialType = KVTML_SPECIALWORDTYPE_VERB; + } + if ( specialType == m_doc->wordTypes().specialTypeAdverb()) { + specialType = KVTML_SPECIALWORDTYPE_ADVERB; + } + if ( specialType == m_doc->wordTypes().specialTypeAdjective()) { + specialType = KVTML_SPECIALWORDTYPE_ADJECTIVE; + } + typeDefinitionElement.appendChild( newTextElement( KVTML_SPECIALWORDTYPE, specialType ) ); } // subtypes foreach( QString subTypeName, wt.subTypeNameList( mainTypeName ) ) { QDomElement subTypeDefinitionElement = m_domDoc.createElement( KVTML_SUBWORDTYPEDEFINITION ); subTypeDefinitionElement.appendChild( newTextElement( KVTML_SUBTYPENAME, subTypeName ) ); - if ( !wt.specialSubType( mainTypeName, subTypeName ).isEmpty() ) { - subTypeDefinitionElement.appendChild( newTextElement( KVTML_SPECIALWORDTYPE, wt.specialSubType( mainTypeName, subTypeName ) ) ); + QString specialSubType = wt.specialSubType( mainTypeName, subTypeName ); + if ( !specialSubType.isEmpty() ) { + if ( specialSubType == m_doc->wordTypes().specialTypeNounMale() ) { + specialSubType = KVTML_SPECIALWORDTYPE_NOUN_MALE; + } + if ( specialSubType == m_doc->wordTypes().specialTypeNounFemale() ) { + specialSubType = KVTML_SPECIALWORDTYPE_NOUN_FEMALE; + } + if ( specialSubType == m_doc->wordTypes().specialTypeNounNeutral() ) { + specialSubType = KVTML_SPECIALWORDTYPE_NOUN_NEUTRAL; + } + subTypeDefinitionElement.appendChild( newTextElement( KVTML_SPECIALWORDTYPE, specialSubType ) ); } typeDefinitionElement.appendChild( subTypeDefinitionElement ); } typesElement.appendChild( typeDefinitionElement ); } - - - - - - /* - foreach(QString type, m_doc->typeDescriptions()) - { - if (!(type.isNull()) ) - { - typesElement.appendChild(newTextElement(KVTML_WORDTYPE, type)); - } - }*/ - return true; } @@ -548,7 +559,7 @@ bool KEduVocKvtml2Writer::writeConjugation( QDomElement &conjugationElement, QString third_female = conjugation.conjugation( KEduVocConjugation::ThirdFemale, num ); QString third_neutral = conjugation.conjugation( - KEduVocConjugation::ThirdNeuterCommon, num ); + KEduVocConjugation::ThirdNeutralCommon, num ); if ( !first.isEmpty() || !second.isEmpty() || !third_female.isEmpty() || !third_male.isEmpty() || !third_neutral.isEmpty() ) { @@ -569,7 +580,7 @@ bool KEduVocKvtml2Writer::writeConjugation( QDomElement &conjugationElement, number.appendChild( newTextElement( KVTML_2NDPERSON, second ) ); number.appendChild( newTextElement( KVTML_THIRD_MALE, third_male ) ); number.appendChild( newTextElement( KVTML_THIRD_FEMALE, third_female ) ); - number.appendChild( newTextElement( KVTML_THIRD_NEUTER_COMMON, third_neutral ) ); + number.appendChild( newTextElement( KVTML_THIRD_NEUTRAL_COMMON, third_neutral ) ); conjugationElement.appendChild( number ); } @@ -592,8 +603,8 @@ bool KEduVocKvtml2Writer::writePersonalPronoun(QDomElement & pronounElement, con if ( pronoun.maleFemaleDifferent() ) { pronounElement.appendChild( m_domDoc.createElement( KVTML_THIRD_PERSON_MALE_FEMALE_DIFFERENT ) ); } - if ( pronoun.neuterExists() ) { - pronounElement.appendChild( m_domDoc.createElement( KVTML_THIRD_PERSON_NEUTER_EXISTS ) ); + if ( pronoun.neutralExists() ) { + pronounElement.appendChild( m_domDoc.createElement( KVTML_THIRD_PERSON_NEUTRAL_EXISTS ) ); } if ( pronoun.dualExists() ) { pronounElement.appendChild( m_domDoc.createElement( KVTML_DUAL_EXISTS ) ); @@ -609,7 +620,7 @@ bool KEduVocKvtml2Writer::writePersonalPronoun(QDomElement & pronounElement, con QString third_female = pronoun.personalPronoun( KEduVocConjugation::ThirdFemale, num ); QString third_neutral = pronoun.personalPronoun( - KEduVocConjugation::ThirdNeuterCommon, num ); + KEduVocConjugation::ThirdNeutralCommon, num ); if ( !first.isEmpty() || !second.isEmpty() || !third_female.isEmpty() || !third_male.isEmpty() || !third_neutral.isEmpty() ) { @@ -630,13 +641,13 @@ bool KEduVocKvtml2Writer::writePersonalPronoun(QDomElement & pronounElement, con number.appendChild( newTextElement( KVTML_2NDPERSON, second ) ); number.appendChild( newTextElement( KVTML_THIRD_MALE, third_male ) ); number.appendChild( newTextElement( KVTML_THIRD_FEMALE, third_female ) ); - number.appendChild( newTextElement( KVTML_THIRD_NEUTER_COMMON, third_neutral ) ); + number.appendChild( newTextElement( KVTML_THIRD_NEUTRAL_COMMON, third_neutral ) ); if ( pronoun.maleFemaleDifferent() ) { number.appendChild( m_domDoc.createElement( KVTML_THIRD_PERSON_MALE_FEMALE_DIFFERENT ) ); } - if ( pronoun.neuterExists() ) { - number.appendChild( m_domDoc.createElement( KVTML_THIRD_PERSON_NEUTER_EXISTS ) ); + if ( pronoun.neutralExists() ) { + number.appendChild( m_domDoc.createElement( KVTML_THIRD_PERSON_NEUTRAL_EXISTS ) ); } pronounElement.appendChild( number ); } diff --git a/keduvocdocument/keduvockvtmlreader.cpp b/keduvocdocument/keduvockvtmlreader.cpp index 45bc80e..fd570c9 100644 --- a/keduvocdocument/keduvockvtmlreader.cpp +++ b/keduvocdocument/keduvockvtmlreader.cpp @@ -484,25 +484,25 @@ bool KEduVocKvtmlReader::readConjugation( QDomElement &domElementParent, KEduVoc conjugation.setConjugation( pers2_plur, KEduVocConjugation::Second, numP); if ( s3_common ) { - conjugation.setConjugation( pers3_f_sing, KEduVocConjugation::ThirdNeuterCommon, KEduVocConjugation::Singular ); + conjugation.setConjugation( pers3_f_sing, KEduVocConjugation::ThirdNeutralCommon, KEduVocConjugation::Singular ); } else { conjugation.setConjugation( pers3_m_sing, KEduVocConjugation::ThirdMale, KEduVocConjugation::Singular ); conjugation.setConjugation( pers3_f_sing, KEduVocConjugation::ThirdFemale, KEduVocConjugation::Singular ); conjugation.setConjugation( pers3_n_sing, - KEduVocConjugation::ThirdNeuterCommon, KEduVocConjugation::Singular ); + KEduVocConjugation::ThirdNeutralCommon, KEduVocConjugation::Singular ); } if ( p3_common ) { - conjugation.setConjugation( pers3_f_plur, KEduVocConjugation::ThirdNeuterCommon, KEduVocConjugation::Plural ); + conjugation.setConjugation( pers3_f_plur, KEduVocConjugation::ThirdNeutralCommon, KEduVocConjugation::Plural ); } else { conjugation.setConjugation( pers3_m_plur, KEduVocConjugation::ThirdMale, KEduVocConjugation::Plural ); conjugation.setConjugation( pers3_f_plur, KEduVocConjugation::ThirdFemale, KEduVocConjugation::Plural ); conjugation.setConjugation( pers3_n_plur, - KEduVocConjugation::ThirdNeuterCommon, KEduVocConjugation::Plural ); + KEduVocConjugation::ThirdNeutralCommon, KEduVocConjugation::Plural ); } return true; @@ -590,14 +590,14 @@ bool KEduVocKvtmlReader::readPersonalPronouns( QDomElement &domElementParent, KE // used to have common in female if ( s3_common ) { - pronouns.setPersonalPronoun( pers3_f_sing, KEduVocConjugation::ThirdNeuterCommon, numS ); + pronouns.setPersonalPronoun( pers3_f_sing, KEduVocConjugation::ThirdNeutralCommon, numS ); } else { pronouns.setPersonalPronoun( pers3_m_sing, KEduVocConjugation::ThirdMale, numS ); pronouns.setPersonalPronoun( pers3_f_sing, KEduVocConjugation::ThirdFemale, numS ); pronouns.setPersonalPronoun( pers3_n_sing, - KEduVocConjugation::ThirdNeuterCommon, numS ); + KEduVocConjugation::ThirdNeutralCommon, numS ); pronouns.setMaleFemaleDifferent(true); } @@ -606,14 +606,14 @@ bool KEduVocKvtmlReader::readPersonalPronouns( QDomElement &domElementParent, KE pronouns.setPersonalPronoun( pers1_sing, KEduVocConjugation::First, numP ); pronouns.setPersonalPronoun( pers2_sing, KEduVocConjugation::Second, numP ); if ( p3_common ) { - pronouns.setPersonalPronoun( pers3_f_plur, KEduVocConjugation::ThirdNeuterCommon, numP ); + pronouns.setPersonalPronoun( pers3_f_plur, KEduVocConjugation::ThirdNeutralCommon, numP ); } else { pronouns.setPersonalPronoun( pers3_m_plur, KEduVocConjugation::ThirdMale, numP ); pronouns.setPersonalPronoun( pers3_f_plur, KEduVocConjugation::ThirdFemale, numP ); pronouns.setPersonalPronoun( pers3_n_plur, - KEduVocConjugation::ThirdNeuterCommon, numP ); + KEduVocConjugation::ThirdNeutralCommon, numP ); pronouns.setMaleFemaleDifferent(true); } diff --git a/keduvocdocument/keduvockvtmlwriter.cpp b/keduvocdocument/keduvockvtmlwriter.cpp index cadab68..2493650 100644 --- a/keduvocdocument/keduvockvtmlwriter.cpp +++ b/keduvocdocument/keduvockvtmlwriter.cpp @@ -383,8 +383,8 @@ bool KEduVocKvtmlWriter::writeArticle( QDomElement &domElementParent ) domElementEntry.appendChild( domElementMI ); } - // neuter - articleString = m_doc->identifier(i).article().article( KEduVocArticle::Singular, KEduVocArticle::Definite, KEduVocArticle::Neuter ); + // neutral + articleString = m_doc->identifier(i).article().article( KEduVocArticle::Singular, KEduVocArticle::Definite, KEduVocArticle::Neutral ); if ( !articleString.isEmpty() ) { QDomElement domElementND = m_domDoc.createElement( KV_ART_ND ); QDomText domTextND = m_domDoc.createTextNode( articleString ); @@ -392,7 +392,7 @@ bool KEduVocKvtmlWriter::writeArticle( QDomElement &domElementParent ) domElementND.appendChild( domTextND ); domElementEntry.appendChild( domElementND ); } - articleString = m_doc->identifier(i).article().article( KEduVocArticle::Singular, KEduVocArticle::Indefinite, KEduVocArticle::Neuter ); + articleString = m_doc->identifier(i).article().article( KEduVocArticle::Singular, KEduVocArticle::Indefinite, KEduVocArticle::Neutral ); if ( !articleString.isEmpty() ) { QDomElement domElementNI = m_domDoc.createElement( KV_ART_NI ); QDomText domTextNI = m_domDoc.createTextNode( articleString ); diff --git a/keduvocdocument/keduvocpersonalpronoun.cpp b/keduvocdocument/keduvocpersonalpronoun.cpp index 6a4634a..c167a60 100644 --- a/keduvocdocument/keduvocpersonalpronoun.cpp +++ b/keduvocdocument/keduvocpersonalpronoun.cpp @@ -22,7 +22,7 @@ public: Private(); bool m_maleFemaleDifferent; - bool m_neuterExists; + bool m_neutralExists; bool m_dualExists; QMap m_personalpronouns; }; @@ -31,7 +31,7 @@ public: KEduVocPersonalPronoun::Private::Private() { m_maleFemaleDifferent = false; - m_neuterExists = false; + m_neutralExists = false; m_dualExists = false; } @@ -44,7 +44,7 @@ KEduVocPersonalPronoun::KEduVocPersonalPronoun( const KEduVocPersonalPronoun& ot : d( new Private ) { d->m_maleFemaleDifferent = other.d->m_maleFemaleDifferent; - d->m_neuterExists = other.d->m_neuterExists; + d->m_neutralExists = other.d->m_neutralExists; d->m_personalpronouns = other.d->m_personalpronouns; d->m_dualExists = other.d->m_dualExists; } @@ -59,7 +59,7 @@ KEduVocPersonalPronoun::~KEduVocPersonalPronoun() KEduVocPersonalPronoun& KEduVocPersonalPronoun::operator = ( const KEduVocPersonalPronoun& other ) { d->m_maleFemaleDifferent = other.d->m_maleFemaleDifferent; - d->m_neuterExists = other.d->m_neuterExists; + d->m_neutralExists = other.d->m_neutralExists; d->m_personalpronouns = other.d->m_personalpronouns; d->m_dualExists = other.d->m_dualExists; return *this; @@ -70,7 +70,7 @@ bool KEduVocPersonalPronoun::operator ==(const KEduVocPersonalPronoun& other) co { return d->m_personalpronouns == other.d->m_personalpronouns && d->m_maleFemaleDifferent == other.d->m_maleFemaleDifferent && - d->m_neuterExists == other.d->m_neuterExists && + d->m_neutralExists == other.d->m_neutralExists && d->m_dualExists == other.d->m_dualExists; } @@ -105,14 +105,14 @@ void KEduVocPersonalPronoun::setMaleFemaleDifferent(bool different) d->m_maleFemaleDifferent = different; } -bool KEduVocPersonalPronoun::neuterExists() const +bool KEduVocPersonalPronoun::neutralExists() const { - return d->m_neuterExists; + return d->m_neutralExists; } -void KEduVocPersonalPronoun::setNeuterExists(bool exists) +void KEduVocPersonalPronoun::setNeutralExists(bool exists) { - d->m_neuterExists = exists; + d->m_neutralExists = exists; } bool KEduVocPersonalPronoun::dualExists() const diff --git a/keduvocdocument/keduvocpersonalpronoun.h b/keduvocdocument/keduvocpersonalpronoun.h index 05a921e..d5638fc 100644 --- a/keduvocdocument/keduvocpersonalpronoun.h +++ b/keduvocdocument/keduvocpersonalpronoun.h @@ -44,8 +44,8 @@ public: bool maleFemaleDifferent() const; void setMaleFemaleDifferent(bool different); - bool neuterExists() const; - void setNeuterExists(bool exists); + bool neutralExists() const; + void setNeutralExists(bool exists); bool dualExists() const; void setDualExists(bool exists); diff --git a/keduvocdocument/keduvocwordtype.cpp b/keduvocdocument/keduvocwordtype.cpp index 0e32af1..9f72e22 100644 --- a/keduvocdocument/keduvocwordtype.cpp +++ b/keduvocdocument/keduvocwordtype.cpp @@ -63,14 +63,12 @@ public: { QString m_subTypeName; QString m_specialType; - QString m_specialTypeExplanation; bool operator== ( const subWordType& other ); }; struct wordType { QString m_typeName; QString m_specialType; - QString m_specialTypeExplanation; QList m_subWordTypeList; bool operator== ( const wordType& other ); }; @@ -78,68 +76,46 @@ public: /// Map containing the word type name and its properties. QList m_wordTypeList; - static const QString WORDTYPE_NOUN; - static const QString WORDTYPE_NOUN_MALE; - static const QString WORDTYPE_NOUN_FEMALE; - static const QString WORDTYPE_NOUN_NEUTRAL; - - static const QString WORDTYPE_VERB; - static const QString WORDTYPE_VERB_REGULAR; - static const QString WORDTYPE_VERB_IRREGULAR; - static const QString WORDTYPE_ADJECTIVE; - static const QString WORDTYPE_ADVERB; - - static const QString WORDTYPE_NOUN_EXPLANATION; - static const QString WORDTYPE_NOUN_MALE_EXPLANATION; - static const QString WORDTYPE_NOUN_FEMALE_EXPLANATION; - static const QString WORDTYPE_NOUN_NEUTRAL_EXPLANATION; - - static const QString WORDTYPE_VERB_EXPLANATION; - static const QString WORDTYPE_VERB_REGULAR_EXPLANATION; - static const QString WORDTYPE_VERB_IRREGULAR_EXPLANATION; - static const QString WORDTYPE_ADJECTIVE_EXPLANATION; - static const QString WORDTYPE_ADVERB_EXPLANATION; -}; - -const QString KEduVocWordType::Private::WORDTYPE_NOUN = QString( "noun" ); -const QString KEduVocWordType::Private::WORDTYPE_NOUN_MALE = QString( "noun male" ); -const QString KEduVocWordType::Private::WORDTYPE_NOUN_FEMALE = QString( "noun female" ); -const QString KEduVocWordType::Private::WORDTYPE_NOUN_NEUTRAL = QString( "noun neutral" ); - -const QString KEduVocWordType::Private::WORDTYPE_VERB = QString( "verb" ); -const QString KEduVocWordType::Private::WORDTYPE_VERB_REGULAR = QString( "verb regular" ); -const QString KEduVocWordType::Private::WORDTYPE_VERB_IRREGULAR = QString( "verb irregular" ); - -const QString KEduVocWordType::Private::WORDTYPE_ADJECTIVE = QString( "adjective" ); -const QString KEduVocWordType::Private::WORDTYPE_ADVERB = QString( "adverb" ); - + static const QString WORDTYPE_SPECIAL_NOUN; + static const QString WORDTYPE_SPECIAL_NOUN_MALE; + static const QString WORDTYPE_SPECIAL_NOUN_FEMALE; + static const QString WORDTYPE_SPECIAL_NOUN_NEUTRAL; -const QString KEduVocWordType::Private::WORDTYPE_NOUN_EXPLANATION = QString( i18n( "This holds the words of type noun. You can rename it but not delete since the article training relies on it!" ) ); -const QString KEduVocWordType::Private::WORDTYPE_NOUN_MALE_EXPLANATION = QString( "This holds the words of type noun male. You can rename it but not delete since the article training relies on it!" ); -const QString KEduVocWordType::Private::WORDTYPE_NOUN_FEMALE_EXPLANATION = QString( "This holds the words of type noun female. You can rename it but not delete since the article training relies on it!" ); -const QString KEduVocWordType::Private::WORDTYPE_NOUN_NEUTRAL_EXPLANATION = QString( "This holds the words of type noun neutral. You can rename it but not delete since the article training relies on it!" ); + static const QString WORDTYPE_SPECIAL_VERB; + static const QString WORDTYPE_SPECIAL_VERB_REGULAR; + static const QString WORDTYPE_SPECIAL_VERB_IRREGULAR; + static const QString WORDTYPE_SPECIAL_ADJECTIVE; + static const QString WORDTYPE_SPECIAL_ADVERB; +}; -const QString KEduVocWordType::Private::WORDTYPE_VERB_EXPLANATION = QString( "This holds the words of type verb. You can rename it but not delete since the article training relies on it!" ); -const QString KEduVocWordType::Private::WORDTYPE_VERB_REGULAR_EXPLANATION = QString( "This holds the words of type regular verbs. You can rename it but not delete since the article training relies on it!" ); -const QString KEduVocWordType::Private::WORDTYPE_VERB_IRREGULAR_EXPLANATION = QString( "This holds the words of type irregular verbs. You can rename it but not delete since the article training relies on it!" ); +const QString KEduVocWordType::Private::WORDTYPE_SPECIAL_NOUN = + QString( i18nc( "@item:inlistbox The grammatical type of a word", "Noun" ) ); +const QString KEduVocWordType::Private::WORDTYPE_SPECIAL_NOUN_MALE = + QString( i18nc( "@item:inlistbox A subtype of the grammatical word type: Noun", "Male" ) ); +const QString KEduVocWordType::Private::WORDTYPE_SPECIAL_NOUN_FEMALE = + QString( i18nc( "@item:inlistbox A subtype of the grammatical word type: Noun", "Female" ) ); +const QString KEduVocWordType::Private::WORDTYPE_SPECIAL_NOUN_NEUTRAL = + QString( i18nc( "@item:inlistbox A subtype of the grammatical word type: Noun", "Neutral" ) ); -const QString KEduVocWordType::Private::WORDTYPE_ADJECTIVE_EXPLANATION = QString( "This holds the words of type adjective. You can rename it but not delete since the article training relies on it!" ); -const QString KEduVocWordType::Private::WORDTYPE_ADVERB_EXPLANATION = QString( "This holds the words of type adverb. You can rename it but not delete since the article training relies on it!" ); +const QString KEduVocWordType::Private::WORDTYPE_SPECIAL_VERB = + QString( i18nc( "@item:inlistbox The grammatical type of a word", "Verb" ) ); +const QString KEduVocWordType::Private::WORDTYPE_SPECIAL_ADJECTIVE = + QString( i18nc( "@item:inlistbox The grammatical type of a word", "Adjective" ) ); +const QString KEduVocWordType::Private::WORDTYPE_SPECIAL_ADVERB = + QString( i18nc( "@item:inlistbox The grammatical type of a word", "Adverb" ) ); bool KEduVocWordType::Private::wordType::operator ==(const wordType & other) { return m_typeName == other.m_typeName && m_specialType == other.m_specialType && - m_specialTypeExplanation == other.m_specialTypeExplanation && m_subWordTypeList == other.m_subWordTypeList; } bool KEduVocWordType::Private::subWordType::operator ==(const subWordType & other) { return m_subTypeName == other.m_subTypeName && - m_specialType == other.m_specialType && - m_specialTypeExplanation == other.m_specialTypeExplanation; + m_specialType == other.m_specialType; } bool KEduVocWordType::operator ==(const KEduVocWordType & other) @@ -171,39 +147,28 @@ KEduVocWordType::KEduVocWordType( const KEduVocWordType & other ) void KEduVocWordType::createDefaultWordTypes() { - // first the special types which cannot be deleted: - addType( i18nc( "@item:inlistbox The grammatical type of a word", "Noun" ), - d->WORDTYPE_NOUN, d->WORDTYPE_NOUN_EXPLANATION ); - - addSubType( i18nc( "@item:inlistbox The grammatical type of a word", "Noun" ), - i18nc( "@item:inlistbox A subtype of the grammatical word type: Noun", "Male" ), - d->WORDTYPE_NOUN_MALE, d->WORDTYPE_NOUN_MALE_EXPLANATION ); + // first the special types + addType( d->WORDTYPE_SPECIAL_NOUN, d->WORDTYPE_SPECIAL_NOUN ); - addSubType( i18nc( "@item:inlistbox The grammatical type of a word", "Noun" ), - i18nc( "@item:inlistbox A subtype of the grammatical word type: Noun", "Female" ), - d->WORDTYPE_NOUN_FEMALE, d->WORDTYPE_NOUN_FEMALE_EXPLANATION ); + addSubType( d->WORDTYPE_SPECIAL_NOUN, + d->WORDTYPE_SPECIAL_NOUN_MALE, d->WORDTYPE_SPECIAL_NOUN_MALE ); - addSubType( i18nc( "@item:inlistbox The grammatical type of a word", "Noun" ), - i18nc( "@item:inlistbox A subtype of the grammatical word type: Noun", "Neutral" ), - d->WORDTYPE_NOUN_NEUTRAL, d->WORDTYPE_NOUN_NEUTRAL_EXPLANATION ); + addSubType( d->WORDTYPE_SPECIAL_NOUN, + d->WORDTYPE_SPECIAL_NOUN_FEMALE, d->WORDTYPE_SPECIAL_NOUN_FEMALE ); - addType( i18nc( "@item:inlistbox The grammatical type of a word", "Verb" ), - d->WORDTYPE_VERB, d->WORDTYPE_VERB_EXPLANATION ); + addSubType( d->WORDTYPE_SPECIAL_NOUN, + d->WORDTYPE_SPECIAL_NOUN_NEUTRAL, d->WORDTYPE_SPECIAL_NOUN_NEUTRAL ); - addSubType( i18nc( "@item:inlistbox The grammatical type of a word", "Verb" ), - i18nc( "@item:inlistbox A subtype of the grammatical word type: Verb with regular conjugation","Regular" ), - d->WORDTYPE_VERB_REGULAR, d->WORDTYPE_VERB_REGULAR_EXPLANATION ); + addType( d->WORDTYPE_SPECIAL_VERB, d->WORDTYPE_SPECIAL_VERB ); - addSubType( i18nc( "@item:inlistbox The grammatical type of a word", "Verb" ), - i18nc( "@item:inlistbox A subtype of the grammatical word type: Verb with irregular conjugation","Irregular" ), - d->WORDTYPE_VERB_IRREGULAR, d->WORDTYPE_VERB_IRREGULAR_EXPLANATION ); + addSubType( d->WORDTYPE_SPECIAL_VERB, + i18nc( "@item:inlistbox A subtype of the grammatical word type: Verb with regular conjugation","Regular" ) ); - addType( i18nc( "@item:inlistbox The grammatical type of a word", "Adjective" ) , - d->WORDTYPE_ADJECTIVE, d->WORDTYPE_ADJECTIVE_EXPLANATION ); - - addType( i18nc( "@item:inlistbox The grammatical type of a word", "Adverb" ), - d->WORDTYPE_ADVERB, d->WORDTYPE_ADVERB_EXPLANATION ); + addSubType( d->WORDTYPE_SPECIAL_VERB, + i18nc( "@item:inlistbox A subtype of the grammatical word type: Verb with irregular conjugation","Irregular" ) ); + addType( d->WORDTYPE_SPECIAL_ADJECTIVE, d->WORDTYPE_SPECIAL_ADJECTIVE ); + addType( d->WORDTYPE_SPECIAL_ADVERB, d->WORDTYPE_SPECIAL_ADVERB ); addType( i18nc( "@item:inlistbox The grammatical type of an entry", "Question" ) ); addType( i18nc( "@item:inlistbox The grammatical type of a word", "Name" ) ); @@ -266,7 +231,7 @@ QStringList KEduVocWordType::subTypeNameList( const QString & mainType ) const } -void KEduVocWordType::addType( const QString & typeName, const QString & specialType, const QString & specialTypeExplanation ) +void KEduVocWordType::addType( const QString & typeName, const QString & specialType ) { if ( typeName.isEmpty() ) { kDebug() << "Attempting to add empty type. When opening old kvtml documents this is ok."; @@ -279,10 +244,9 @@ void KEduVocWordType::addType( const QString & typeName, const QString & special d->m_wordTypeList.append( Private::wordType() ); d->m_wordTypeList[d->m_wordTypeList.count()-1].m_typeName = typeName; d->m_wordTypeList[d->m_wordTypeList.count()-1].m_specialType = specialType; - d->m_wordTypeList[d->m_wordTypeList.count()-1].m_specialTypeExplanation = specialTypeExplanation; } -void KEduVocWordType::addSubType( const QString & mainType, const QString & typeName, const QString & specialType, const QString & specialTypeExplanation ) +void KEduVocWordType::addSubType( const QString & mainType, const QString & typeName, const QString & specialType ) { int mt = mainTypeIndex( mainType ); @@ -290,7 +254,6 @@ void KEduVocWordType::addSubType( const QString & mainType, const QString & type d->m_wordTypeList[mt].m_subWordTypeList[d->m_wordTypeList[mt].m_subWordTypeList.count()-1].m_subTypeName = typeName; d->m_wordTypeList[mt].m_subWordTypeList[d->m_wordTypeList[mt].m_subWordTypeList.count()-1].m_specialType = specialType; - d->m_wordTypeList[mt].m_subWordTypeList[d->m_wordTypeList[mt].m_subWordTypeList.count()-1].m_specialTypeExplanation = specialTypeExplanation; } void KEduVocWordType::renameType( const QString & oldTypeName, const QString & newTypeName ) @@ -360,7 +323,6 @@ QString KEduVocWordType::specialType( const QString & typeName ) { int index = mainTypeIndex( typeName ); if ( index >= 0 ) { -kDebug() << "special for " << typeName << ":" << d->m_wordTypeList[index].m_specialType; return d->m_wordTypeList[index].m_specialType; } return QString(); @@ -381,35 +343,35 @@ QString KEduVocWordType::specialSubType( const QString & mainTypeName, const QSt QString KEduVocWordType::specialTypeNoun() const { - return d->WORDTYPE_NOUN; + return d->WORDTYPE_SPECIAL_NOUN; } QString KEduVocWordType::specialTypeNounMale() const { - return d->WORDTYPE_NOUN_MALE; + return d->WORDTYPE_SPECIAL_NOUN_MALE; } QString KEduVocWordType::specialTypeNounFemale() const { - return d->WORDTYPE_NOUN_FEMALE; + return d->WORDTYPE_SPECIAL_NOUN_FEMALE; } QString KEduVocWordType::specialTypeNounNeutral() const { - return d->WORDTYPE_NOUN_NEUTRAL; + return d->WORDTYPE_SPECIAL_NOUN_NEUTRAL; } QString KEduVocWordType::specialTypeVerb() const { - return d->WORDTYPE_VERB; + return d->WORDTYPE_SPECIAL_VERB; } QString KEduVocWordType::specialTypeAdjective() const { - return d->WORDTYPE_ADJECTIVE; + return d->WORDTYPE_SPECIAL_ADJECTIVE; } QString KEduVocWordType::specialTypeAdverb() const { - return d->WORDTYPE_ADVERB; + return d->WORDTYPE_SPECIAL_ADVERB; } void KEduVocWordType::setSpecialType(const QString & typeName, const QString & newSpecialType) @@ -417,9 +379,7 @@ void KEduVocWordType::setSpecialType(const QString & typeName, const QString & n int mainIndex = mainTypeIndex( typeName ); if ( mainIndex >= 0 ) { d->m_wordTypeList[mainIndex].m_specialType = newSpecialType; -kDebug() << "set special type" << typeName << ": " << d->m_wordTypeList[mainIndex].m_specialType; } - } void KEduVocWordType::setSpecialSubType(const QString & mainTypeName, const QString & subTypeName, const QString & newSpecialType) @@ -429,7 +389,6 @@ void KEduVocWordType::setSpecialSubType(const QString & mainTypeName, const QStr int subIndex = subTypeIndex( mainTypeName, subTypeName ); if ( subIndex >= 0 ) { d->m_wordTypeList[mainIndex].m_subWordTypeList[subIndex].m_specialType = newSpecialType; -kDebug() << "set special sub type" << subTypeName << ": " << d->m_wordTypeList[mainIndex].m_subWordTypeList[subIndex].m_specialType; } } } diff --git a/keduvocdocument/keduvocwordtype.h b/keduvocdocument/keduvocwordtype.h index 1d8842f..79cb26c 100644 --- a/keduvocdocument/keduvocwordtype.h +++ b/keduvocdocument/keduvocwordtype.h @@ -58,9 +58,8 @@ public: * Create a new word type in the list of known types * @param typeName Name of the word type * @param specialType Name of the special type - this is used internally to identify which types are use for special queries - verb query needs special == "verb" for example. - * @param specialTypeExplanation An explanation which can be shown to the user. Since the type can be renamed if it's special, but not deleted this is necessary. */ - void addType( const QString& typeName, const QString& specialType = QString(), const QString& specialTypeExplanation = QString() ); + void addType( const QString& typeName, const QString& specialType = QString() ); /** @@ -68,9 +67,8 @@ public: * @param mainType The word type to which the subtype belongs. * @param typeName Sub type name * @param specialType See above - * @param specialTypeExplanation See above */ - void addSubType( const QString& mainType, const QString& typeName, const QString& specialType = QString(), const QString& specialTypeExplanation = QString() ); + void addSubType( const QString& mainType, const QString& typeName, const QString& specialType = QString() ); /** * Get a list of all known main word types. diff --git a/keduvocdocument/kvtml2defs.h b/keduvocdocument/kvtml2defs.h index dc9d347..04abd5f 100644 --- a/keduvocdocument/kvtml2defs.h +++ b/keduvocdocument/kvtml2defs.h @@ -58,13 +58,13 @@ #define KVTML_2NDPERSON "secondperson" #define KVTML_THIRD_MALE "thirdpersonmale" #define KVTML_THIRD_FEMALE "thirdpersonfemale" -#define KVTML_THIRD_NEUTER_COMMON "thirdpersonneutercommon" +#define KVTML_THIRD_NEUTRAL_COMMON "thirdpersonneutralcommon" // for the personal pronuns: // if this tag exists, in a conjugation male/female are different #define KVTML_THIRD_PERSON_MALE_FEMALE_DIFFERENT "malefemaledifferent" -// if this tag exists conjugations even have a neuter form for the third person -#define KVTML_THIRD_PERSON_NEUTER_EXISTS "neuterexists" +// if this tag exists conjugations even have a neutral form for the third person +#define KVTML_THIRD_PERSON_NEUTRAL_EXISTS "neutralexists" #define KVTML_DUAL_EXISTS "dualexists" // word types @@ -75,7 +75,16 @@ #define KVTML_WORDTYPE "wordtype" #define KVTML_TYPENAME "typename" #define KVTML_SUBTYPENAME "subtypename" + +// these are necessary to enable practices based on word types. users can give types arbitrary names, but these few are hardcoded. #define KVTML_SPECIALWORDTYPE "specialwordtype" +#define KVTML_SPECIALWORDTYPE_NOUN "noun" +#define KVTML_SPECIALWORDTYPE_NOUN_MALE "male" +#define KVTML_SPECIALWORDTYPE_NOUN_FEMALE "female" +#define KVTML_SPECIALWORDTYPE_NOUN_NEUTRAL "neutral" +#define KVTML_SPECIALWORDTYPE_VERB "verb" +#define KVTML_SPECIALWORDTYPE_ADJECTIVE "adjective" +#define KVTML_SPECIALWORDTYPE_ADVERB "adverb" #define KVTML_TENSES "tenses" #define KVTML_TENSE "tense" -- 2.47.3