]> gitweb.hamatoma.de Git - gadeku.git/commitdiff
V 0.1.1 Verb improvements
authorHamatoma <author@hamatoma.de>
Wed, 3 Apr 2024 17:58:52 +0000 (19:58 +0200)
committerHamatoma <author@hamatoma.de>
Wed, 3 Apr 2024 17:58:52 +0000 (19:58 +0200)
- GermanGrammar

- only entry of infinitive on verbs

CHANGELOG.md
app/Helpers/GermanGrammar.php [new file with mode: 0644]
app/Http/Controllers/VerbController.php
composer.lock
resources/views/verb/create.blade.php

index 0593f5f42b238a0c45fffb17d1ff9c219ed25b4f..b47c180bfbe56a9833723a150a3c1148ba0f65cd 100644 (file)
@@ -1 +1,9 @@
+# V 0.1.1 Verb improvements
+
+# Added
+- GermanGrammar
+
+# Changed
+- only entry of infinitive on verbs
+
 # V 0.1.0 Initial commit
diff --git a/app/Helpers/GermanGrammar.php b/app/Helpers/GermanGrammar.php
new file mode 100644 (file)
index 0000000..febc372
--- /dev/null
@@ -0,0 +1,86 @@
+<?php
+namespace App\Helpers;
+
+class GermanGrammar
+{
+    public static function verbImperfect(string $infinitive, int $person, bool $singular)
+    {
+        $base = substr($infinitive, 0, strlen($infinitive) - 2);
+        if ($singular) {
+            $end1 = 'te';
+            $end2 = 'test';
+            if (str_ends_with($base, 't')) {
+                // rosten
+                $between = 'e';
+            } else {
+                // kaufen
+                $between = '';
+            }
+                switch ($person) {
+                case 1:
+                default:
+                    $rc = "$base$between$end1";
+                    break;
+                case 2:
+                    $rc = "$base$between$end2";
+                    break;
+            }
+        } else {
+            $end1 = 'ten';
+            $end2 = 'test';
+            if (str_ends_with($base, 't')) {
+                // rosten
+                $between = 'e';
+            } else {
+                // kaufen
+                $between = '';
+            }
+                switch ($person) {
+                default:
+                case 1:
+                    $rc = "$base$between$end1";
+                    break;
+                case 2:
+                    $rc = "$base$between$end2";
+                    break;
+            }
+        }
+        return $rc;
+    }
+    public static function verbParticipe(string $infinitive): string{
+        $base = substr($infinitive, 0, strlen($infinitive) - 2);
+        $rc = str_ends_with($base, 't') ? "ge$base" . 'tet' : "ge$base" . "t"; 
+        return $rc;
+    }
+    public static function verbPresent(string $infinitive, int $person, bool $singular)
+    {
+        $base = substr($infinitive, 0, strlen($infinitive) - 2);
+        if (str_ends_with($base, 's')) {
+            $end2 = 't';
+        } else {
+            $end2 = 'st';
+        }
+        if ($singular) {
+            switch ($person) {
+                case 1:
+                    $rc = $base . 'e';
+                    break;
+                case 2:
+                default:
+                    $rc = $base . $end2;
+                    break;
+            }
+        } else {
+            switch ($person) {
+                default:
+                case 1:
+                    $rc = $base . 'en';
+                    break;
+                case 2:
+                    $rc = $base . $end2;
+                    break;
+            }
+        }
+        return $rc;
+    }
+}
\ No newline at end of file
index 320265210bd831bf8f0232234438ccb6fc699e19..98b6b741463a919a3d2aa976eb8163403f5473d9 100644 (file)
@@ -7,6 +7,7 @@ use App\Models\Word;
 use App\Models\Phrase;
 use App\Helpers\Helper;
 use App\Helpers\DbHelper;
+use App\Helpers\GermanGrammar;
 use App\Models\SProperty;
 use App\Helpers\Pagination;
 use App\Helpers\ViewHelper;
@@ -140,8 +141,7 @@ class VerbController extends Controller
     {
          if ($isCreate){
             $rc = [
-                'imperfect1s' => 'required',
-                'participle' => 'required',
+                'verb' => 'required',
                 'separablepart' => '',
                 'transitive' => 'required',
                 'usage' => 'required',
@@ -218,24 +218,20 @@ class VerbController extends Controller
                 $rc = back()->withErrors($validator)->withInput();
             } else {
                 $validated = $validator->validated();
-                $base = $fields['verb'];
-                $base = substr($base, 0, strlen($base) - 2);
-                $tail1 = str_ends_with($base, 's') ? 't' : 'st';
-                $tail2 = 'en';
-                $tail0 = 'e';
-                $validated ['presence1s'] = $base . $tail0;
-                $validated ['presence2s'] = $base . $tail1;
-                $validated ['presence3s'] =  $base . $tail1;
-                $validated ['presence1p'] =  $base . $tail2;
-                $validated ['presence2p'] = $base . $tail1;
-                $validated ['presence3p'] = $base . $tail2;
-                $base = $validated['imperfect1s'];
-                $base = substr($base, 0, strlen($base) - 1);
-                $validated ['imperfect2s'] = $base . $tail1;
-                $validated ['imperfect3s'] = $base . $tail1;
-                $validated ['imperfect1p'] = $base . $tail2;
-                $validated ['imperfect2p'] = $base . $tail1;
-                $validated ['imperfect3p'] = $base . $tail2;
+                $verb = $fields['verb'];
+                $validated ['participle'] = GermanGrammar::verbParticipe($verb);
+                $validated ['presence1s'] = GermanGrammar::verbPresent($verb, 1, true);
+                $validated ['presence2s'] = GermanGrammar::verbPresent($verb, 2, true);
+                $validated ['presence3s'] = GermanGrammar::verbPresent($verb, 3, true);
+                $validated ['presence1p'] = GermanGrammar::verbPresent($verb, 1, false);
+                $validated ['presence2p'] = GermanGrammar::verbPresent($verb, 2, false);
+                $validated ['presence3p'] = GermanGrammar::verbPresent($verb, 3, false);
+                $validated ['imperfect1s'] = GermanGrammar::verbImperfect($verb, 1, true);
+                $validated ['imperfect2s'] = GermanGrammar::verbImperfect($verb, 2, true);
+                $validated ['imperfect3s'] = GermanGrammar::verbImperfect($verb, 3, true);
+                $validated ['imperfect1p'] = GermanGrammar::verbImperfect($verb, 1, false);
+                $validated ['imperfect2p'] = GermanGrammar::verbImperfect($verb, 2, false);
+                $validated ['imperfect3p'] = GermanGrammar::verbImperfect($verb, 3, false);
                 $word = Word::create([
                     'word' => $fields['verb'],
                     'wordtype_scope' => 2002,
index 2adec0d6d2e51ff9f5e76679ee582a4680a97b55..8d2875ed77bc77b134b5c0f9130b8f22b3d050cb 100644 (file)
         },
         {
             "name": "symfony/console",
-            "version": "v7.0.4",
+            "version": "v7.0.6",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/console.git",
-                "reference": "6b099f3306f7c9c2d2786ed736d0026b2903205f"
+                "reference": "fde915cd8e7eb99b3d531d3d5c09531429c3f9e5"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/console/zipball/6b099f3306f7c9c2d2786ed736d0026b2903205f",
-                "reference": "6b099f3306f7c9c2d2786ed736d0026b2903205f",
+                "url": "https://api.github.com/repos/symfony/console/zipball/fde915cd8e7eb99b3d531d3d5c09531429c3f9e5",
+                "reference": "fde915cd8e7eb99b3d531d3d5c09531429c3f9e5",
                 "shasum": ""
             },
             "require": {
                 "terminal"
             ],
             "support": {
-                "source": "https://github.com/symfony/console/tree/v7.0.4"
+                "source": "https://github.com/symfony/console/tree/v7.0.6"
             },
             "funding": [
                 {
                     "type": "tidelift"
                 }
             ],
-            "time": "2024-02-22T20:27:20+00:00"
+            "time": "2024-04-01T11:04:53+00:00"
         },
         {
             "name": "symfony/css-selector",
         },
         {
             "name": "symfony/error-handler",
-            "version": "v7.0.4",
+            "version": "v7.0.6",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/error-handler.git",
-                "reference": "677b24759decff69e65b1e9d1471d90f95ced880"
+                "reference": "46a4cc138f799886d4bd70477c55c699d3e9dfc8"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/error-handler/zipball/677b24759decff69e65b1e9d1471d90f95ced880",
-                "reference": "677b24759decff69e65b1e9d1471d90f95ced880",
+                "url": "https://api.github.com/repos/symfony/error-handler/zipball/46a4cc138f799886d4bd70477c55c699d3e9dfc8",
+                "reference": "46a4cc138f799886d4bd70477c55c699d3e9dfc8",
                 "shasum": ""
             },
             "require": {
             "description": "Provides tools to manage errors and ease debugging PHP code",
             "homepage": "https://symfony.com",
             "support": {
-                "source": "https://github.com/symfony/error-handler/tree/v7.0.4"
+                "source": "https://github.com/symfony/error-handler/tree/v7.0.6"
             },
             "funding": [
                 {
                     "type": "tidelift"
                 }
             ],
-            "time": "2024-02-22T20:27:20+00:00"
+            "time": "2024-03-19T11:57:22+00:00"
         },
         {
             "name": "symfony/event-dispatcher",
         },
         {
             "name": "symfony/event-dispatcher-contracts",
-            "version": "v3.4.0",
+            "version": "v3.4.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/event-dispatcher-contracts.git",
-                "reference": "a76aed96a42d2b521153fb382d418e30d18b59df"
+                "reference": "4e64b49bf370ade88e567de29465762e316e4224"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/a76aed96a42d2b521153fb382d418e30d18b59df",
-                "reference": "a76aed96a42d2b521153fb382d418e30d18b59df",
+                "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/4e64b49bf370ade88e567de29465762e316e4224",
+                "reference": "4e64b49bf370ade88e567de29465762e316e4224",
                 "shasum": ""
             },
             "require": {
                 "standards"
             ],
             "support": {
-                "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.4.0"
+                "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.4.2"
             },
             "funding": [
                 {
                     "type": "tidelift"
                 }
             ],
-            "time": "2023-05-23T14:45:45+00:00"
+            "time": "2024-01-23T14:51:35+00:00"
         },
         {
             "name": "symfony/finder",
         },
         {
             "name": "symfony/http-foundation",
-            "version": "v7.0.4",
+            "version": "v7.0.6",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/http-foundation.git",
-                "reference": "439fdfdd344943254b1ef6278613e79040548045"
+                "reference": "8789625dcf36e5fbf753014678a1e090f1bc759c"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/http-foundation/zipball/439fdfdd344943254b1ef6278613e79040548045",
-                "reference": "439fdfdd344943254b1ef6278613e79040548045",
+                "url": "https://api.github.com/repos/symfony/http-foundation/zipball/8789625dcf36e5fbf753014678a1e090f1bc759c",
+                "reference": "8789625dcf36e5fbf753014678a1e090f1bc759c",
                 "shasum": ""
             },
             "require": {
             "description": "Defines an object-oriented layer for the HTTP specification",
             "homepage": "https://symfony.com",
             "support": {
-                "source": "https://github.com/symfony/http-foundation/tree/v7.0.4"
+                "source": "https://github.com/symfony/http-foundation/tree/v7.0.6"
             },
             "funding": [
                 {
                     "type": "tidelift"
                 }
             ],
-            "time": "2024-02-08T19:22:56+00:00"
+            "time": "2024-03-19T11:46:48+00:00"
         },
         {
             "name": "symfony/http-kernel",
-            "version": "v7.0.5",
+            "version": "v7.0.6",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/http-kernel.git",
-                "reference": "37c24ca28f65e3121a68f3dd4daeb36fb1fa2a72"
+                "reference": "34c872391046d59af804af62d4573b829cfe4824"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/http-kernel/zipball/37c24ca28f65e3121a68f3dd4daeb36fb1fa2a72",
-                "reference": "37c24ca28f65e3121a68f3dd4daeb36fb1fa2a72",
+                "url": "https://api.github.com/repos/symfony/http-kernel/zipball/34c872391046d59af804af62d4573b829cfe4824",
+                "reference": "34c872391046d59af804af62d4573b829cfe4824",
                 "shasum": ""
             },
             "require": {
             "description": "Provides a structured process for converting a Request into a Response",
             "homepage": "https://symfony.com",
             "support": {
-                "source": "https://github.com/symfony/http-kernel/tree/v7.0.5"
+                "source": "https://github.com/symfony/http-kernel/tree/v7.0.6"
             },
             "funding": [
                 {
                     "type": "tidelift"
                 }
             ],
-            "time": "2024-03-04T21:05:24+00:00"
+            "time": "2024-04-03T06:12:25+00:00"
         },
         {
             "name": "symfony/mailer",
-            "version": "v7.0.4",
+            "version": "v7.0.6",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/mailer.git",
-                "reference": "72e16d87bf50a3ce195b9470c06bb9d7b816ea85"
+                "reference": "eb0c3187c7ddfde12d8aa0e1fa5fb29e730a41e0"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/mailer/zipball/72e16d87bf50a3ce195b9470c06bb9d7b816ea85",
-                "reference": "72e16d87bf50a3ce195b9470c06bb9d7b816ea85",
+                "url": "https://api.github.com/repos/symfony/mailer/zipball/eb0c3187c7ddfde12d8aa0e1fa5fb29e730a41e0",
+                "reference": "eb0c3187c7ddfde12d8aa0e1fa5fb29e730a41e0",
                 "shasum": ""
             },
             "require": {
             "description": "Helps sending emails",
             "homepage": "https://symfony.com",
             "support": {
-                "source": "https://github.com/symfony/mailer/tree/v7.0.4"
+                "source": "https://github.com/symfony/mailer/tree/v7.0.6"
             },
             "funding": [
                 {
                     "type": "tidelift"
                 }
             ],
-            "time": "2024-02-03T21:34:19+00:00"
+            "time": "2024-03-28T09:20:36+00:00"
         },
         {
             "name": "symfony/mime",
-            "version": "v7.0.3",
+            "version": "v7.0.6",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/mime.git",
-                "reference": "c1ffe24ba6fdc3e3f0f3fcb93519103b326a3716"
+                "reference": "99362408c9abdf8c7cadcf0529b6fc8b16f5ace2"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/mime/zipball/c1ffe24ba6fdc3e3f0f3fcb93519103b326a3716",
-                "reference": "c1ffe24ba6fdc3e3f0f3fcb93519103b326a3716",
+                "url": "https://api.github.com/repos/symfony/mime/zipball/99362408c9abdf8c7cadcf0529b6fc8b16f5ace2",
+                "reference": "99362408c9abdf8c7cadcf0529b6fc8b16f5ace2",
                 "shasum": ""
             },
             "require": {
                 "league/html-to-markdown": "^5.0",
                 "phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0",
                 "symfony/dependency-injection": "^6.4|^7.0",
+                "symfony/process": "^6.4|^7.0",
                 "symfony/property-access": "^6.4|^7.0",
                 "symfony/property-info": "^6.4|^7.0",
                 "symfony/serializer": "^6.4|^7.0"
                 "mime-type"
             ],
             "support": {
-                "source": "https://github.com/symfony/mime/tree/v7.0.3"
+                "source": "https://github.com/symfony/mime/tree/v7.0.6"
             },
             "funding": [
                 {
                     "type": "tidelift"
                 }
             ],
-            "time": "2024-01-30T08:34:29+00:00"
+            "time": "2024-03-21T19:37:36+00:00"
         },
         {
             "name": "symfony/polyfill-ctype",
         },
         {
             "name": "symfony/routing",
-            "version": "v7.0.5",
+            "version": "v7.0.6",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/routing.git",
-                "reference": "ba6bf07d43289c6a4b4591ddb75bc3bc5f069c19"
+                "reference": "cded64e5bbf9f31786f1055fcc76718fdd77519c"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/routing/zipball/ba6bf07d43289c6a4b4591ddb75bc3bc5f069c19",
-                "reference": "ba6bf07d43289c6a4b4591ddb75bc3bc5f069c19",
+                "url": "https://api.github.com/repos/symfony/routing/zipball/cded64e5bbf9f31786f1055fcc76718fdd77519c",
+                "reference": "cded64e5bbf9f31786f1055fcc76718fdd77519c",
                 "shasum": ""
             },
             "require": {
                 "url"
             ],
             "support": {
-                "source": "https://github.com/symfony/routing/tree/v7.0.5"
+                "source": "https://github.com/symfony/routing/tree/v7.0.6"
             },
             "funding": [
                 {
                     "type": "tidelift"
                 }
             ],
-            "time": "2024-02-27T12:34:35+00:00"
+            "time": "2024-03-28T21:02:11+00:00"
         },
         {
             "name": "symfony/service-contracts",
-            "version": "v3.4.1",
+            "version": "v3.4.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/service-contracts.git",
-                "reference": "fe07cbc8d837f60caf7018068e350cc5163681a0"
+                "reference": "11bbf19a0fb7b36345861e85c5768844c552906e"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/service-contracts/zipball/fe07cbc8d837f60caf7018068e350cc5163681a0",
-                "reference": "fe07cbc8d837f60caf7018068e350cc5163681a0",
+                "url": "https://api.github.com/repos/symfony/service-contracts/zipball/11bbf19a0fb7b36345861e85c5768844c552906e",
+                "reference": "11bbf19a0fb7b36345861e85c5768844c552906e",
                 "shasum": ""
             },
             "require": {
                 "standards"
             ],
             "support": {
-                "source": "https://github.com/symfony/service-contracts/tree/v3.4.1"
+                "source": "https://github.com/symfony/service-contracts/tree/v3.4.2"
             },
             "funding": [
                 {
                     "type": "tidelift"
                 }
             ],
-            "time": "2023-12-26T14:02:43+00:00"
+            "time": "2023-12-19T21:51:00+00:00"
         },
         {
             "name": "symfony/string",
         },
         {
             "name": "symfony/translation-contracts",
-            "version": "v3.4.1",
+            "version": "v3.4.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/translation-contracts.git",
-                "reference": "06450585bf65e978026bda220cdebca3f867fde7"
+                "reference": "43810bdb2ddb5400e5c5e778e27b210a0ca83b6b"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/06450585bf65e978026bda220cdebca3f867fde7",
-                "reference": "06450585bf65e978026bda220cdebca3f867fde7",
+                "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/43810bdb2ddb5400e5c5e778e27b210a0ca83b6b",
+                "reference": "43810bdb2ddb5400e5c5e778e27b210a0ca83b6b",
                 "shasum": ""
             },
             "require": {
                 "standards"
             ],
             "support": {
-                "source": "https://github.com/symfony/translation-contracts/tree/v3.4.1"
+                "source": "https://github.com/symfony/translation-contracts/tree/v3.4.2"
             },
             "funding": [
                 {
                     "type": "tidelift"
                 }
             ],
-            "time": "2023-12-26T14:02:43+00:00"
+            "time": "2024-01-23T14:51:35+00:00"
         },
         {
             "name": "symfony/uid",
         },
         {
             "name": "symfony/var-dumper",
-            "version": "v7.0.4",
+            "version": "v7.0.6",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/var-dumper.git",
-                "reference": "e03ad7c1535e623edbb94c22cc42353e488c6670"
+                "reference": "66d13dc207d5dab6b4f4c2b5460efe1bea29dbfb"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/var-dumper/zipball/e03ad7c1535e623edbb94c22cc42353e488c6670",
-                "reference": "e03ad7c1535e623edbb94c22cc42353e488c6670",
+                "url": "https://api.github.com/repos/symfony/var-dumper/zipball/66d13dc207d5dab6b4f4c2b5460efe1bea29dbfb",
+                "reference": "66d13dc207d5dab6b4f4c2b5460efe1bea29dbfb",
                 "shasum": ""
             },
             "require": {
                 "dump"
             ],
             "support": {
-                "source": "https://github.com/symfony/var-dumper/tree/v7.0.4"
+                "source": "https://github.com/symfony/var-dumper/tree/v7.0.6"
             },
             "funding": [
                 {
                     "type": "tidelift"
                 }
             ],
-            "time": "2024-02-15T11:33:06+00:00"
+            "time": "2024-03-19T11:57:22+00:00"
         },
         {
             "name": "tijsverkoyen/css-to-inline-styles",
index aa33c9220f9b4c7eee78ebf3ed86d371d43c24c1..1954de3b82ecc9520cf1a5bb46f31108b7ca724a 100644 (file)
@@ -7,14 +7,10 @@
         <x-laraknife.panels.create title="{{ __('Creation of a Verb') }}">
             <x-laraknife.forms.string position="first" name="verb" label="Verb" value="{{ $context->valueOf('verb') }}"
                 width2="2" />
-            <x-laraknife.forms.string position="middle" name="participle" label="Partizip"
-                value="{{ $context->valueOf('participle') }}" width1="1" width2="2" />
             <x-laraknife.forms.string position="middle" name="separablepart" label="Trennteil"
                 value="{{ $context->valueOf('separablepart') }}" width1="1" width2="2" />
             <x-laraknife.forms.checkbox position="last" name="transitive" label="Transitive"
                 value="{{ $context->valueOf('transitive') }}" width1="1" width2="1" />
-            <x-laraknife.forms.string position="alone" name="imperfect1s" label="Imperfekt Ich"
-                value="{{ $context->valueOf('imperfect1s') }}" width2="2" />
             <x-laraknife.forms.text position="alone" name="usage" label="Usage"
                 value="{{ $context->valueOf('usage') }}" width2="10" rows="3" />
         </x-laraknife.panels.create>