TipitakaWordBookResource.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Http\Resources\V3;
  3. use Illuminate\Http\Request;
  4. /**
  5. * 按词形检索的一本书的命中统计。
  6. *
  7. * `book_id` 是 `pcd_book_id`(`book_titles.sn`),也是列表端点 `book_id` 过滤用的值;
  8. * `book` / `para` 是书名所在段的坐标。`paragraphs` 是命中段落数,`occurrences` 是词次
  9. * (同一段出现多次算多次)。`layer` 取自书的 tag(mula / atthakatha / tika / anna),没有则为 null。
  10. */
  11. class TipitakaWordBookResource extends BaseResource
  12. {
  13. /**
  14. * @return array{
  15. * book_id: int,
  16. * book: int,
  17. * para: int,
  18. * title: string,
  19. * layer: string|null,
  20. * tags: list<string>,
  21. * paragraphs: int,
  22. * occurrences: int
  23. * }
  24. */
  25. public function toArray(Request $request): array
  26. {
  27. return [
  28. 'book_id' => $this['book_id'],
  29. 'book' => $this['book'],
  30. 'para' => $this['para'],
  31. 'title' => $this['title'],
  32. 'layer' => $this['layer'],
  33. 'tags' => $this['tags'],
  34. 'paragraphs' => $this['paragraphs'],
  35. 'occurrences' => $this['occurrences'],
  36. ];
  37. }
  38. }