Kaynağa Gözat

Merge pull request #2245 from visuddhinanda/development

精审字典更新
visuddhinanda 1 yıl önce
ebeveyn
işleme
fa91b544bf

+ 27 - 7
api-v8/app/Http/Resources/SearchBookResource.php

@@ -5,6 +5,8 @@ namespace App\Http\Resources;
 use Illuminate\Http\Resources\Json\JsonResource;
 use Illuminate\Http\Resources\Json\JsonResource;
 use App\Models\BookTitle;
 use App\Models\BookTitle;
 use App\Models\PaliText;
 use App\Models\PaliText;
+use App\Models\TagMap;
+
 use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Facades\Log;
 
 
 class SearchBookResource extends JsonResource
 class SearchBookResource extends JsonResource
@@ -17,22 +19,40 @@ class SearchBookResource extends JsonResource
      */
      */
     public function toArray($request)
     public function toArray($request)
     {
     {
-        $book = BookTitle::where('sn',$this->pcd_book_id)->first();
+        $book = BookTitle::where('sn', $this->pcd_book_id)->first();
         $data = [
         $data = [
-            'pcdBookId'=>$this->pcd_book_id,
-            "count"=>$this->co,
+            'pcdBookId' => $this->pcd_book_id,
+            "count" => $this->co,
         ];
         ];
-        if($book){
-            $toc = PaliText::where('book',$book->book)->where("paragraph",$book->paragraph)->value('toc');
+        if ($book) {
+            $toc = PaliText::where('book', $book->book)
+                ->where("paragraph", $book->paragraph)
+                ->value('toc');
             $data["book"] = $book->book;
             $data["book"] = $book->book;
             $data["paragraph"] = $book->paragraph;
             $data["paragraph"] = $book->paragraph;
             $data["paliTitle"] = $toc;
             $data["paliTitle"] = $toc;
-        }else{
-            Log::error('book title is null pcd_book_id='.$this->pcd_book_id);
+            //tags
+            $data["tags"] = $this->getTags($book->book, $book->paragraph);
+        } else {
+            Log::error('book title is null pcd_book_id=' . $this->pcd_book_id);
             $data["book"] = 0;
             $data["book"] = 0;
             $data["paragraph"] = 0;
             $data["paragraph"] = 0;
             $data["paliTitle"] = '';
             $data["paliTitle"] = '';
         }
         }
+
         return $data;
         return $data;
     }
     }
+
+    private function getTags(string $book, string $para)
+    {
+        $uid = PaliText::where('book', $book)->where('paragraph', $para)->first()->uid;
+        $tagsName = TagMap::where('table_name', 'pali_texts')
+            ->where('anchor_id', $uid)
+            ->join('tags', 'tag_maps.tag_id', '=', 'tags.id')
+            ->select('tags.name')
+            ->get();
+
+        Log::info('tag name', ['data' => $tagsName]);
+        return $tagsName;
+    }
 }
 }

+ 12 - 2
api-v8/app/Models/Tag.php

@@ -8,13 +8,23 @@ use Illuminate\Database\Eloquent\Model;
 class Tag extends Model
 class Tag extends Model
 {
 {
 
 
+    protected $primaryKey = 'id';
     protected $keyType = 'string';
     protected $keyType = 'string';
-	protected $fillable = ['name' , 'owner_id'];
+    protected $casts = [
+        'id' => 'string'
+    ];
+    protected $fillable = ['name', 'owner_id'];
 
 
     use HasFactory;
     use HasFactory;
 
 
     public function chapters()
     public function chapters()
     {
     {
-        return $this->belongsToMany('App\Models\ProgressChapter','tag_maps','tag_id','anchor_id');
+        return $this->belongsToMany('App\Models\ProgressChapter', 'tag_maps', 'tag_id', 'anchor_id');
+    }
+
+    // 定义与 TagMap 模型的一对多关系
+    public function tag_maps()
+    {
+        return $this->hasMany(TagMap::class);
     }
     }
 }
 }

+ 1 - 1
api-v8/public/dicttext/en/critical/index.csv → api-v8/public/dicttext/en/critical-1/index copy.csv

@@ -1,4 +1,4 @@
-id,lang,sn,word_en,word,word2,note
+id,lang,sn,word_en,word,word2,note
 677325,en,29,karaphala,kāraphala,kāraphala,"<article data-id=""27325""><h2><b>kāra-phala</b></h2><i>, n., the fruit of the</i> <sup>4</sup>kāra <i>tree;</i> kāsu­māriyo ti evaṁnāmakāni phalāni ~āni vā, Ja IV 434,<span class=""smalltext"">15</span>’.</article>"
 677325,en,29,karaphala,kāraphala,kāraphala,"<article data-id=""27325""><h2><b>kāra-phala</b></h2><i>, n., the fruit of the</i> <sup>4</sup>kāra <i>tree;</i> kāsu­māriyo ti evaṁnāmakāni phalāni ~āni vā, Ja IV 434,<span class=""smalltext"">15</span>’.</article>"
 677621,en,29,karandiya,kāraṇḍiya,kāraṇḍiya,"<article data-id=""27319""><h2><b>Kāraṇḍiya,</b></h2> <i>m., NPr.; name of a brahmin;</i> ~a, Ja III 172,<span class=""smalltext"">9</span><span class=""smalltext"">*</span>, <span class=""smalltext"">24</span><span class=""smalltext"">*</span> (<i>so Ee, Ce</i> [<i>SHB</i>]<i>; MSS. Bdi, Be</i> Ko°; <i>Se</i> Karand°, <i>v.l.</i> Kāraṇḍ°); ~o, 173,<span class=""smalltext"">17</span> (<i>Ee</i> °ko); — <b>°‑jātaka,</b> <i>n., title of</i> Jātaka <i>no. 356</i> = III 170–174; ~aṁ, Ja III 174,<span class=""smalltext"">3</span> (<i>v.l. = prec.</i>); — <b>°‑mānava,</b> <i>m., the young brahmin</i> K.; ~o, 174,<span class=""smalltext"">2</span> (<i>v.l.</i> = <i>prec.</i>).</article>"
 677621,en,29,karandiya,kāraṇḍiya,kāraṇḍiya,"<article data-id=""27319""><h2><b>Kāraṇḍiya,</b></h2> <i>m., NPr.; name of a brahmin;</i> ~a, Ja III 172,<span class=""smalltext"">9</span><span class=""smalltext"">*</span>, <span class=""smalltext"">24</span><span class=""smalltext"">*</span> (<i>so Ee, Ce</i> [<i>SHB</i>]<i>; MSS. Bdi, Be</i> Ko°; <i>Se</i> Karand°, <i>v.l.</i> Kāraṇḍ°); ~o, 173,<span class=""smalltext"">17</span> (<i>Ee</i> °ko); — <b>°‑jātaka,</b> <i>n., title of</i> Jātaka <i>no. 356</i> = III 170–174; ~aṁ, Ja III 174,<span class=""smalltext"">3</span> (<i>v.l. = prec.</i>); — <b>°‑mānava,</b> <i>m., the young brahmin</i> K.; ~o, 174,<span class=""smalltext"">2</span> (<i>v.l.</i> = <i>prec.</i>).</article>"
 677622,en,29,karandavasutta,kāraṇḍavasutta,kāraṇḍavasutta,"<article data-id=""27318""><h2><b>Kāraṇḍava-sutta,</b></h2> <i>n., (modern) title of</i> A IV 168,<span class=""smalltext"">21–</span>172,<span class=""smalltext"">11</span>, <i>cf.</i> kāraṇḍavena, A IV 172,<span class=""smalltext"">15</span><span class=""smalltext"">*</span> (uddāna); — <b>°‑sut­ta-vaṇṇanā,</b> <i>f., ct. on prec., title of</i> Mp IV 74,<span class=""smalltext"">11–</span>75,<span class=""smalltext"">15</span>; ~ā niṭṭhitā, Mp-ṭ <i>Be</i> III 208,<span class=""smalltext"">15</span>.</article>"
 677622,en,29,karandavasutta,kāraṇḍavasutta,kāraṇḍavasutta,"<article data-id=""27318""><h2><b>Kāraṇḍava-sutta,</b></h2> <i>n., (modern) title of</i> A IV 168,<span class=""smalltext"">21–</span>172,<span class=""smalltext"">11</span>, <i>cf.</i> kāraṇḍavena, A IV 172,<span class=""smalltext"">15</span><span class=""smalltext"">*</span> (uddāna); — <b>°‑sut­ta-vaṇṇanā,</b> <i>f., ct. on prec., title of</i> Mp IV 74,<span class=""smalltext"">11–</span>75,<span class=""smalltext"">15</span>; ~ā niṭṭhitā, Mp-ṭ <i>Be</i> III 208,<span class=""smalltext"">15</span>.</article>"

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 0
api-v8/public/dicttext/en/critical-1/index.csv


+ 18 - 0
api-v8/public/dicttext/en/critical-1/index.ini

@@ -0,0 +1,18 @@
+[meta]
+dictname = "A Critical Pāli Dictionary Vol I"
+shortname = "Critical Vol I"
+description = "Critical Pāli Dictionary"
+src_lang = "pa"
+dest_lang = "en"
+isbn = ""
+publisher = "THE ROYAL DANISH ACADEMY OF SCIENCES AND LETTERS"
+published_at = 2011
+url = "https://cpd.uni-koeln.de/"
+author = "V. TRENCKNER"
+uuid = "076a5256-3df0-42aa-bcf1-b8ccfd05b0eb"
+rows = 11985
+[cols]
+source = "_PAPER_"
+language = "en"
+status = 30
+confidence = 100

Dosya farkı çok büyük olduğundan ihmal edildi
+ 8 - 0
api-v8/public/dicttext/en/critical-2/index.csv


+ 19 - 0
api-v8/public/dicttext/en/critical-2/index.ini

@@ -0,0 +1,19 @@
+[meta]
+dictname = "A Critical Pāli Dictionary Vol II"
+shortname = "Critical Vol II"
+description = "A Critical Pāli Dictionary, a project of the Royal Danish Academy of Sciences and Letters, was planned as an exhaustive Pali-English dictionary but was never completed; the project was discontinued in 2011.
+Three volumes were published in a series of between 1925 and 2011 covering a–kāreti, about one third of the Pali lexicon."
+src_lang = "pa"
+dest_lang = "en"
+isbn = ""
+publisher = ""
+published_at = 2011
+url = "https://cpd.uni-koeln.de/"
+author = ""
+uuid = "7e1da02e-9d2d-4937-8a7e-3a34beeb9503"
+rows = 10518
+[cols]
+source = "_PAPER_"
+language = "en"
+status = 30
+confidence = 99

Dosya farkı çok büyük olduğundan ihmal edildi
+ 3 - 0
api-v8/public/dicttext/en/critical-3/index.csv


+ 4 - 4
api-v8/public/dicttext/en/critical/index.ini → api-v8/public/dicttext/en/critical-3/index.ini

@@ -1,16 +1,16 @@
 [meta]
 [meta]
-dictname = "Critical Pāli Dictionary"
-shortname = "Critical"
+dictname = "A Critical Pāli Dictionary Vol III"
+shortname = "Critical Vol III"
 description = "Critical Pāli Dictionary"
 description = "Critical Pāli Dictionary"
 src_lang = "pa"
 src_lang = "pa"
 dest_lang = "en"
 dest_lang = "en"
 isbn = ""
 isbn = ""
 publisher = ""
 publisher = ""
-year = 1980
+published_at = 1980
 url = ""
 url = ""
 author = ""
 author = ""
 uuid = "5718cbcf-684c-44d4-bbf2-4fa12f2588a4"
 uuid = "5718cbcf-684c-44d4-bbf2-4fa12f2588a4"
-rows = 29268
+rows = 6766
 [cols]
 [cols]
 source = "_PAPER_"
 source = "_PAPER_"
 language = "en"
 language = "en"

+ 9 - 1
dashboard-v4/dashboard/src/components/api/Tag.ts

@@ -16,7 +16,15 @@ export interface ITagRequest {
   created_at?: string;
   created_at?: string;
   updated_at?: string;
   updated_at?: string;
 }
 }
-
+export interface ITag {
+  id?: string;
+  name?: string;
+  description?: string | null;
+  color?: number;
+  owner?: IStudio;
+  created_at?: string;
+  updated_at?: string;
+}
 export interface ITagData {
 export interface ITagData {
   id: string;
   id: string;
   name: string;
   name: string;

+ 22 - 2
dashboard-v4/dashboard/src/components/corpus/BookTree.tsx

@@ -1,7 +1,7 @@
 import { useIntl } from "react-intl";
 import { useIntl } from "react-intl";
 import { useState, useEffect, Key } from "react";
 import { useState, useEffect, Key } from "react";
 import { DownOutlined } from "@ant-design/icons";
 import { DownOutlined } from "@ant-design/icons";
-import { Button, Space, Switch, Tree } from "antd";
+import { Badge, Button, Space, Switch, Tree } from "antd";
 import { Typography } from "antd";
 import { Typography } from "antd";
 
 
 import { get } from "../../request";
 import { get } from "../../request";
@@ -10,6 +10,8 @@ import { IPaliBookListResponse } from "../api/Corpus";
 import { ITocTree } from "./BookTreeList";
 import { ITocTree } from "./BookTreeList";
 import { PaliToEn } from "../../utils";
 import { PaliToEn } from "../../utils";
 import PaliText from "../template/Wbw/PaliText";
 import PaliText from "../template/Wbw/PaliText";
+import { ITagCount } from "./BookTreeWithTags";
+import { IFtsData } from "../fts/FtsBookList";
 
 
 const { Text } = Typography;
 const { Text } = Typography;
 
 
@@ -18,6 +20,7 @@ interface IWidgetBookTree {
   path?: string[];
   path?: string[];
   multiSelect?: boolean;
   multiSelect?: boolean;
   multiSelectable?: boolean;
   multiSelectable?: boolean;
+  books?: IFtsData[];
   onChange?: Function;
   onChange?: Function;
   onSelect?: Function;
   onSelect?: Function;
   onRootChange?: Function;
   onRootChange?: Function;
@@ -27,6 +30,7 @@ const BookTreeWidget = ({
   path,
   path,
   multiSelect = false,
   multiSelect = false,
   multiSelectable = true,
   multiSelectable = true,
+  books,
   onChange,
   onChange,
   onSelect,
   onSelect,
   onRootChange,
   onRootChange,
@@ -157,7 +161,23 @@ const BookTreeWidget = ({
         }}
         }}
         treeData={treeData}
         treeData={treeData}
         titleRender={(node: ITocTree) => {
         titleRender={(node: ITocTree) => {
-          return <PaliText text={node.title} />;
+          //标签数量
+          const tags = books?.filter((book) => {
+            return node.tag.every((el) => {
+              return book.tags?.map((item) => item.name).includes(el);
+            });
+          });
+          const count = tags?.length;
+          return (
+            <Space>
+              <PaliText text={node.title} />
+              {count ? (
+                <Badge size="small" color="gray" count={count} dot={false} />
+              ) : (
+                <></>
+              )}
+            </Space>
+          );
         }}
         }}
       />
       />
     </Space>
     </Space>

+ 65 - 0
dashboard-v4/dashboard/src/components/corpus/BookTreeWithTags.tsx

@@ -0,0 +1,65 @@
+import { useEffect, useState } from "react";
+import BookTree from "./BookTree";
+import { get } from "../../request";
+import { IFtsData, IFtsResponse } from "../fts/FtsBookList";
+import { ISearchView } from "../fts/FullTextSearchResult";
+
+export interface ITagCount {
+  name: string;
+  count: number;
+}
+
+interface IWidget {
+  keyWord?: string;
+  keyWords?: string[];
+  root?: string;
+  path?: string[];
+  view?: ISearchView;
+  multiSelect?: boolean;
+  multiSelectable?: boolean;
+  onChange?: (key: string[], path: string[]) => void;
+}
+const BookTreeWithTags = ({
+  keyWord,
+  keyWords,
+  root = "default",
+  path,
+  view,
+  multiSelect = false,
+  multiSelectable = true,
+  onChange,
+}: IWidget) => {
+  const [books, setBooks] = useState<IFtsData[]>();
+  useEffect(() => {
+    let words;
+    let api = "";
+    if (keyWord?.trim().includes(" ")) {
+      api = "search-book-list";
+      words = keyWord;
+    } else {
+      api = "search-pali-wbw-books";
+      words = keyWords?.join();
+    }
+
+    let url = `/v2/${api}?view=${view}&key=${words}`;
+    console.info("api request", url);
+    get<IFtsResponse>(url).then((json) => {
+      console.info("api response", json);
+      if (json.ok) {
+        setBooks(json.data.rows);
+      }
+    });
+  }, [keyWord, keyWords, view]);
+  return (
+    <BookTree
+      multiSelect={multiSelect}
+      multiSelectable={multiSelectable}
+      root={root}
+      path={path}
+      books={books}
+      onChange={onChange}
+    />
+  );
+};
+
+export default BookTreeWithTags;

+ 10 - 12
dashboard-v4/dashboard/src/components/fts/FtsBookList.tsx

@@ -4,16 +4,20 @@ import { useEffect, useState } from "react";
 import { get } from "../../request";
 import { get } from "../../request";
 import { Key } from "antd/es/table/interface";
 import { Key } from "antd/es/table/interface";
 import { DataNode } from "antd/es/tree";
 import { DataNode } from "antd/es/tree";
+import { ISearchView } from "./FullTextSearchResult";
+import { ITag } from "../api/Tag";
+
 const { Text } = Typography;
 const { Text } = Typography;
-interface IFtsData {
+export interface IFtsData {
   book: number;
   book: number;
   paragraph: number;
   paragraph: number;
   title?: string;
   title?: string;
   paliTitle: string;
   paliTitle: string;
   pcdBookId: number;
   pcdBookId: number;
   count: number;
   count: number;
+  tags?: ITag[];
 }
 }
-interface IFtsResponse {
+export interface IFtsResponse {
   ok: boolean;
   ok: boolean;
   string: string;
   string: string;
   data: {
   data: {
@@ -21,14 +25,7 @@ interface IFtsResponse {
     count: number;
     count: number;
   };
   };
 }
 }
-interface IFtsItem {
-  book: number;
-  paragraph: number;
-  title?: string;
-  paliTitle?: string;
-  pcdBookId: number;
-  count: number;
-}
+
 interface IWidget {
 interface IWidget {
   keyWord?: string;
   keyWord?: string;
   keyWords?: string[];
   keyWords?: string[];
@@ -39,7 +36,7 @@ interface IWidget {
   para?: number;
   para?: number;
   match?: string | null;
   match?: string | null;
   keyWord2?: string;
   keyWord2?: string;
-  view?: string;
+  view?: ISearchView;
   onSelect?: Function;
   onSelect?: Function;
 }
 }
 
 
@@ -99,8 +96,9 @@ const FtsBookListWidget = ({
     if (match) {
     if (match) {
       url += `&match=${match}`;
       url += `&match=${match}`;
     }
     }
-    console.log("url", url);
+    console.info("api request", url);
     get<IFtsResponse>(url).then((json) => {
     get<IFtsResponse>(url).then((json) => {
+      console.info("api response", json);
       if (json.ok) {
       if (json.ok) {
         console.log("data", json.data.rows);
         console.log("data", json.data.rows);
         let totalResult = 0;
         let totalResult = 0;

+ 7 - 3
dashboard-v4/dashboard/src/pages/library/search/search.tsx

@@ -2,7 +2,6 @@ import { useNavigate, useParams, useSearchParams } from "react-router-dom";
 import { useEffect, useState } from "react";
 import { useEffect, useState } from "react";
 import { Row, Col, Breadcrumb, Space, Tabs, Select } from "antd";
 import { Row, Col, Breadcrumb, Space, Tabs, Select } from "antd";
 import FullSearchInput from "../../../components/fts/FullSearchInput";
 import FullSearchInput from "../../../components/fts/FullSearchInput";
-import BookTree from "../../../components/corpus/BookTree";
 import FullTextSearchResult, {
 import FullTextSearchResult, {
   ISearchView,
   ISearchView,
 } from "../../../components/fts/FullTextSearchResult";
 } from "../../../components/fts/FullTextSearchResult";
@@ -12,6 +11,8 @@ import CaseList from "../../../components/dict/CaseList";
 import PageNumberList from "../../../components/fts/PageNumberList";
 import PageNumberList from "../../../components/fts/PageNumberList";
 import { Key } from "antd/es/table/interface";
 import { Key } from "antd/es/table/interface";
 
 
+import BookTreeWithTags from "../../../components/corpus/BookTreeWithTags";
+
 const Widget = () => {
 const Widget = () => {
   const { key } = useParams();
   const { key } = useParams();
   const [searchParams, setSearchParams] = useSearchParams();
   const [searchParams, setSearchParams] = useSearchParams();
@@ -44,12 +45,15 @@ const Widget = () => {
         <Col flex="1440px">
         <Col flex="1440px">
           <Row>
           <Row>
             <Col xs={0} sm={6} md={5}>
             <Col xs={0} sm={6} md={5}>
-              <BookTree
+              <BookTreeWithTags
+                view={view}
+                keyWord={key}
+                keyWords={caseWord}
                 multiSelect={false}
                 multiSelect={false}
                 root={bookRoot}
                 root={bookRoot}
                 path={bookPath}
                 path={bookPath}
                 onChange={(key: string[], path: string[]) => {
                 onChange={(key: string[], path: string[]) => {
-                  console.log("key", key);
+                  console.debug("key", key);
                   if (key.length === 0) {
                   if (key.length === 0) {
                     searchParams.delete("tags");
                     searchParams.delete("tags");
                   } else {
                   } else {

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor