Skip to content

Commit

Permalink
🐛 fix(WordsData.json): add missing 'comparison' property for adverbs
Browse files Browse the repository at this point in the history
🔧 chore(WordsData.json): update 'comparison' property for adverbs
🔧 chore(project.pbxproj): update project version and marketing version to 2.0.4

🐛 fix(Word.swift): fix typo in CodingKeys enum, change 'comparative' to 'comparison'
✨ feat(Word.swift): add functions to generate comparison forms of adjectives

🐛 fix(WordService.swift): add support for generating comparison forms of words
✨ feat(WordService.swift): add support for generating comparison weak and strong adjective forms of words

🔨 refactor(DynamicTable.swift): Add comparison table for strong and weak adjectives
🔨 refactor(DynamicTableVerbs.swift): Add comparison table for strong and weak verbs
🔨 refactor(WordDetailView.swift): Add display of comparison for words with comparison
  • Loading branch information
andskur committed Jan 16, 2024
1 parent 148a40c commit 34b86dd
Show file tree
Hide file tree
Showing 7 changed files with 411 additions and 15 deletions.
20 changes: 18 additions & 2 deletions Assets/WordsData.json
Original file line number Diff line number Diff line change
Expand Up @@ -6573,6 +6573,7 @@
"russianTranslation": "очень, весьма",
"type": "adverb",
"comparative": "meirr",
"comparison": "mest",
"definition": "To a great extent; much.",
"examples": [
"Hann er mjök fróðr. (He is very learned.)"
Expand All @@ -6594,6 +6595,7 @@
"russianTranslation": "скоро, вскоре",
"type": "adverb",
"comparative": "bráðarr",
"comparison": "bráðast",
"definition": "In or within a short time; quickly; shortly.",
"examples": [
"Vetur kemur brátt. (Winter is coming soon.)"
Expand All @@ -6605,6 +6607,7 @@
"russianTranslation": "часто, неоднократно",
"type": "adverb",
"comparative": "oftarr",
"comparison": "oftast",
"definition": "Frequently; many times; on many occasions.",
"examples": [
"Oft hann fer til borgarinnar. (He often goes to the city.)",
Expand All @@ -6627,6 +6630,7 @@
"russianTranslation": "скорее, лучше",
"type": "adverb",
"comparative": "heldr",
"comparison": "helzt",
"definition": "To a greater degree; more preferable or suitable.",
"examples": [
"Hann hjálpar þér gjarna. (He will help you gladly.)",
Expand Down Expand Up @@ -6665,14 +6669,16 @@
"Hann syngur vel. (He sings well.)",
"Hún samþykkti vel. (She agreed willingly.)"
],
"comparative": "betr"
"comparative": "betr",
"comparison": "bezt"
},
{
"oldNorseWord": "aftr",
"englishTranslation": "back, again",
"russianTranslation": "назад, снова",
"type": "adverb",
"comparative": "aftarr",
"comparison": "aftast",
"definition": "In a direction or manner that returns to a previous position or condition; once more.",
"examples": [
"Hann fer aftr heim. (He goes back home.)"
Expand Down Expand Up @@ -6724,6 +6730,7 @@
"russianTranslation": "далеко, издалека",
"type": "adverb",
"comparative": "lengra",
"comparison": "lengst",
"definition": "Over a great distance; from a distant place.",
"examples": [
"Hann kom langt í burtu. (He came from far away.)"
Expand All @@ -6735,6 +6742,7 @@
"russianTranslation": "долго, долгое время",
"type": "adverb",
"comparative": "lengr",
"comparison": "lengst",
"definition": "For a considerable duration; for an extended period.",
"examples": [
"Hann bíðaði lengi. (He waited for a long time.)"
Expand All @@ -6746,6 +6754,7 @@
"russianTranslation": "на север, на севере",
"type": "adverb",
"comparative": "norðarr",
"comparison": "norðarst",
"definition": "Toward or in the northern part or direction.",
"examples": [
"Hann fer norðr. (He goes northward.)"
Expand All @@ -6757,6 +6766,7 @@
"russianTranslation": "на запад, на западе",
"type": "adverb",
"comparative": "vestarr",
"comparison": "vestarst",
"definition": "Toward or in the western part or direction.",
"examples": [
"Sólin setur vestr. (The sun sets in the west.)"
Expand Down Expand Up @@ -6789,6 +6799,7 @@
"russianTranslation": "широко, повсюду",
"type": "adverb",
"comparative": "víðarr",
"comparison": "víðast",
"definition": "Over or in a wide area; in or to many places.",
"examples": [
"Fréttirnar dreifðust víða. (The news spread widely.)",
Expand All @@ -6801,6 +6812,7 @@
"russianTranslation": "громко",
"type": "adverb",
"comparative": "hærra",
"comparison": "hæst",
"definition": "With a high volume or intensity of sound; at a high decibel level.",
"examples": [
"Hann talar hátt. (He speaks loudly.)",
Expand Down Expand Up @@ -6845,6 +6857,7 @@
"russianTranslation": "вверх, наверх",
"type": "adverb",
"comparative": "ofarr",
"comparison": "ofarst",
"definition": "Towards a higher place or position; upwards.",
"examples": [
"Hann gengur upp fjallið. (He walks up the mountain.)",
Expand All @@ -6861,7 +6874,8 @@
"Þeir sigldu suðr. (They sailed southward.)",
"Suðr er landið hlýrra. (In the south, the land is warmer.)"
],
"comparative": "sunnarr"
"comparative": "sunnarr",
"comparison": "sunnarst"
},
{
"oldNorseWord": "út",
Expand Down Expand Up @@ -6914,6 +6928,7 @@
"russianTranslation": "внутри, в глубине",
"type": "adverb",
"comparative": "innarr",
"comparison": "innst",
"definition": "Within an enclosed space; in the innermost part.",
"examples": [
"Þau bjuggu inni í skóginum. (They lived inside the forest.)",
Expand Down Expand Up @@ -7014,6 +7029,7 @@
"russianTranslation": "мало, немного",
"type": "adverb",
"comparative": "minnr",
"comparison": "minzt",
"definition": "Not much; scarcely; only a small amount or degree.",
"examples": [
"Example sentence in Old Norse using 'lítt'. (Translation of the sentence.)",
Expand Down
16 changes: 8 additions & 8 deletions OldNorseDictionary.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@
CODE_SIGN_ENTITLEMENTS = Source/OldNorseDictionary.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2.0.3;
CURRENT_PROJECT_VERSION = 2.0.4;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 4V482C5WA8;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -596,7 +596,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 13.3;
MARKETING_VERSION = 2.0.3;
MARKETING_VERSION = 2.0.4;
PRODUCT_BUNDLE_IDENTIFIER = Andskur.OldNorseDictionary;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -618,7 +618,7 @@
CODE_SIGN_ENTITLEMENTS = Source/OldNorseDictionary.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2.0.3;
CURRENT_PROJECT_VERSION = 2.0.4;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 4V482C5WA8;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -639,7 +639,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 13.3;
MARKETING_VERSION = 2.0.3;
MARKETING_VERSION = 2.0.4;
PRODUCT_BUNDLE_IDENTIFIER = Andskur.OldNorseDictionary;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -701,7 +701,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2.0.3;
CURRENT_PROJECT_VERSION = 2.0.4;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 4V482C5WA8;
ENABLE_PREVIEWS = YES;
Expand All @@ -713,7 +713,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.0.3;
MARKETING_VERSION = 2.0.4;
PRODUCT_BUNDLE_IDENTIFIER = Andskur.OldNorseDictionary.watchkitapp;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = watchos;
Expand All @@ -731,7 +731,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2.0.3;
CURRENT_PROJECT_VERSION = 2.0.4;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 4V482C5WA8;
ENABLE_PREVIEWS = YES;
Expand All @@ -743,7 +743,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.0.3;
MARKETING_VERSION = 2.0.4;
PRODUCT_BUNDLE_IDENTIFIER = Andskur.OldNorseDictionary.watchkitapp;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = watchos;
Expand Down
161 changes: 160 additions & 1 deletion Source/Models/Word.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct VerbForms: Codable {

struct Word: Codable, Identifiable {
private enum CodingKeys : String, CodingKey {
case oldNorseWord, base, declension, englishTranslation, comparative, russianTranslation, definition, examples, type, cases, gendersCases, numbers, conjugation, gender, nounForms, verbForms
case oldNorseWord, base, declension, englishTranslation, comparative, comparison, russianTranslation, definition, examples, type, cases, gendersCases, numbers, conjugation, gender, nounForms, verbForms
}

var oldNorseWord: String
Expand All @@ -60,9 +60,161 @@ struct Word: Codable, Identifiable {
let nounForms: NounForms?

let comparative: String?
let comparison: String?

var id = UUID()

func generateComparisonStrongAdjective(number: Number, gender: Gender, caseStrong: Case) -> String? {
if type != .adjective {
return nil
}


switch caseStrong {
case .nominative:
switch number {
case .singular:
switch gender {
case .masculine:
return base! + "astr"
case .neuter:
return base! + "ast"
case .feminine:
return base! + "ust"
default:
return base
}
case .dual, .plural:
switch gender {
case .masculine:
return base! + "astir"
case .neuter:
return base! + "ust"
case .feminine:
return base! + "astar"
default:
return base
}
}
case .accusative:
switch number {
case .singular:
switch gender {
case .masculine:
return base! + "astan"
case .neuter:
return base! + "ast"
case .feminine:
return base! + "asta"
default:
return base
}
case .dual, .plural:
switch gender {
case .masculine:
return base! + "asta"
case .neuter:
return base! + "ust"
case .feminine:
return base! + "astar"
default:
return base
}
}
case .dative:
switch number {
case .singular:
switch gender {
case .masculine:
return base! + "ustum"
case .neuter:
return base! + "ustu"
case .feminine:
return base! + "astri"
default:
return base
}
case .dual, .plural:
return base! + "ustum"
}
case .genitive:
switch number {
case .singular:
switch gender {
case .feminine:
return base! + "astrar"
default:
return base! + "asts"
}
case .dual, .plural:
return base! + "astra"
}
}
}

func generateComparisonWeakAdjective(number: Number, gender: Gender, caseWeak: Case) -> String? {
if type != .adjective {
return nil
}

var weak = base

switch caseWeak {
case .nominative:
switch number {
case .singular:
switch gender {
case .masculine:
return base! + "asti"
default:
return weak! + "asta"
}
case .dual, .plural:
return weak! + "ustu"
}
case .accusative:
switch number {
case .singular:
switch gender {
case .feminine:
return weak! + "ustu"
default:
return weak! + "asta"
}
case .dual, .plural:
return weak! + "ustu"
}
case .dative:
switch number {
case .singular:
switch gender {
case .feminine:
return weak! + "ustu"
default:
return weak! + "asta"
}
case .dual, .plural:
if base?.last == "v" {
weak?.removeLast()
}
return weak! + "ustum"
}
case .genitive:
switch number {
case .singular:
switch gender {
case .feminine:
return weak! + "ustu"
default:
return weak! + "asta"
}
case .dual, .plural:
return weak! + "ustu"
}
}
}
func generateComparativeAdjective(number: Number, gender: Gender, caseWeak: Case) -> String? {
if type != .adjective {
return nil
Expand Down Expand Up @@ -510,6 +662,13 @@ struct Word: Codable, Identifiable {
return nil
}

func generateComparison() -> String? {
if comparison != nil {
return comparison
}
return nil
}

func generateCase(wordCase: Case, number: Number, gender: Gender) -> String? {
switch wordCase {
case .nominative:
Expand Down
Loading

0 comments on commit 34b86dd

Please sign in to comment.