| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  | 'use client' | 
					
						
							|  |  |  | import { useTranslation } from 'react-i18next' | 
					
						
							|  |  |  | import dayjs from 'dayjs' | 
					
						
							|  |  |  | import { formatFileSize, formatNumber, formatTime } from '@/utils/format' | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | import type { DocType } from '@/models/datasets' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type inputType = 'input' | 'select' | 'textarea' | 
					
						
							|  |  |  | export type metadataType = DocType | 'originInfo' | 'technicalParameters' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  | type MetadataMap = | 
					
						
							|  |  |  |     Record< | 
					
						
							|  |  |  |     metadataType, | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       text: string | 
					
						
							|  |  |  |       allowEdit?: boolean | 
					
						
							|  |  |  |       icon?: React.ReactNode | 
					
						
							|  |  |  |       iconName?: string | 
					
						
							|  |  |  |       subFieldsMap: Record< | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |       string, | 
					
						
							|  |  |  |       { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         label: string | 
					
						
							|  |  |  |         inputType?: inputType | 
					
						
							|  |  |  |         field?: string | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |         render?: (value: any, total?: number) => React.ReactNode | string | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |       > | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     > | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  | const fieldPrefix = 'datasetDocuments.metadata.field' | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | export const useMetadataMap = (): MetadataMap => { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |   const { t } = useTranslation() | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |   return { | 
					
						
							|  |  |  |     book: { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |       text: t('datasetDocuments.metadata.type.book'), | 
					
						
							|  |  |  |       iconName: 'bookOpen', | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |       subFieldsMap: { | 
					
						
							|  |  |  |         title: { label: t(`${fieldPrefix}.book.title`) }, | 
					
						
							|  |  |  |         language: { | 
					
						
							|  |  |  |           label: t(`${fieldPrefix}.book.language`), | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |           inputType: 'select', | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |         }, | 
					
						
							|  |  |  |         author: { label: t(`${fieldPrefix}.book.author`) }, | 
					
						
							|  |  |  |         publisher: { label: t(`${fieldPrefix}.book.publisher`) }, | 
					
						
							|  |  |  |         publication_date: { label: t(`${fieldPrefix}.book.publicationDate`) }, | 
					
						
							|  |  |  |         isbn: { label: t(`${fieldPrefix}.book.ISBN`) }, | 
					
						
							|  |  |  |         category: { | 
					
						
							|  |  |  |           label: t(`${fieldPrefix}.book.category`), | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |           inputType: 'select', | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |         }, | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     web_page: { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |       text: t('datasetDocuments.metadata.type.webPage'), | 
					
						
							|  |  |  |       iconName: 'globe', | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |       subFieldsMap: { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'title': { label: t(`${fieldPrefix}.webPage.title`) }, | 
					
						
							|  |  |  |         'url': { label: t(`${fieldPrefix}.webPage.url`) }, | 
					
						
							|  |  |  |         'language': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.webPage.language`), | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |           inputType: 'select', | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'author/publisher': { label: t(`${fieldPrefix}.webPage.authorPublisher`) }, | 
					
						
							|  |  |  |         'publish_date': { label: t(`${fieldPrefix}.webPage.publishDate`) }, | 
					
						
							|  |  |  |         'topics/keywords': { label: t(`${fieldPrefix}.webPage.topicsKeywords`) }, | 
					
						
							|  |  |  |         'description': { label: t(`${fieldPrefix}.webPage.description`) }, | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |       }, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     paper: { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |       text: t('datasetDocuments.metadata.type.paper'), | 
					
						
							|  |  |  |       iconName: 'graduationHat', | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |       subFieldsMap: { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'title': { label: t(`${fieldPrefix}.paper.title`) }, | 
					
						
							|  |  |  |         'language': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.paper.language`), | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |           inputType: 'select', | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'author': { label: t(`${fieldPrefix}.paper.author`) }, | 
					
						
							|  |  |  |         'publish_date': { label: t(`${fieldPrefix}.paper.publishDate`) }, | 
					
						
							|  |  |  |         'journal/conference_name': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.paper.journalConferenceName`), | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'volume/issue/page_numbers': { label: t(`${fieldPrefix}.paper.volumeIssuePage`) }, | 
					
						
							|  |  |  |         'doi': { label: t(`${fieldPrefix}.paper.DOI`) }, | 
					
						
							|  |  |  |         'topics/keywords': { label: t(`${fieldPrefix}.paper.topicsKeywords`) }, | 
					
						
							|  |  |  |         'abstract': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.paper.abstract`), | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |           inputType: 'textarea', | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |         }, | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     social_media_post: { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |       text: t('datasetDocuments.metadata.type.socialMediaPost'), | 
					
						
							|  |  |  |       iconName: 'atSign', | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |       subFieldsMap: { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'platform': { label: t(`${fieldPrefix}.socialMediaPost.platform`) }, | 
					
						
							|  |  |  |         'author/username': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.socialMediaPost.authorUsername`), | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'publish_date': { label: t(`${fieldPrefix}.socialMediaPost.publishDate`) }, | 
					
						
							|  |  |  |         'post_url': { label: t(`${fieldPrefix}.socialMediaPost.postURL`) }, | 
					
						
							|  |  |  |         'topics/tags': { label: t(`${fieldPrefix}.socialMediaPost.topicsTags`) }, | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |       }, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     personal_document: { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |       text: t('datasetDocuments.metadata.type.personalDocument'), | 
					
						
							|  |  |  |       iconName: 'file', | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |       subFieldsMap: { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'title': { label: t(`${fieldPrefix}.personalDocument.title`) }, | 
					
						
							|  |  |  |         'author': { label: t(`${fieldPrefix}.personalDocument.author`) }, | 
					
						
							|  |  |  |         'creation_date': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.personalDocument.creationDate`), | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'last_modified_date': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.personalDocument.lastModifiedDate`), | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'document_type': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.personalDocument.documentType`), | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |           inputType: 'select', | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'tags/category': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.personalDocument.tagsCategory`), | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     business_document: { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |       text: t('datasetDocuments.metadata.type.businessDocument'), | 
					
						
							|  |  |  |       iconName: 'briefcase', | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |       subFieldsMap: { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'title': { label: t(`${fieldPrefix}.businessDocument.title`) }, | 
					
						
							|  |  |  |         'author': { label: t(`${fieldPrefix}.businessDocument.author`) }, | 
					
						
							|  |  |  |         'creation_date': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.businessDocument.creationDate`), | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'last_modified_date': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.businessDocument.lastModifiedDate`), | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'document_type': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.businessDocument.documentType`), | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |           inputType: 'select', | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'department/team': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.businessDocument.departmentTeam`), | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     im_chat_log: { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |       text: t('datasetDocuments.metadata.type.IMChat'), | 
					
						
							|  |  |  |       iconName: 'messageTextCircle', | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |       subFieldsMap: { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'chat_platform': { label: t(`${fieldPrefix}.IMChat.chatPlatform`) }, | 
					
						
							|  |  |  |         'chat_participants/group_name': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.IMChat.chatPartiesGroupName`), | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'start_date': { label: t(`${fieldPrefix}.IMChat.startDate`) }, | 
					
						
							|  |  |  |         'end_date': { label: t(`${fieldPrefix}.IMChat.endDate`) }, | 
					
						
							|  |  |  |         'participants': { label: t(`${fieldPrefix}.IMChat.participants`) }, | 
					
						
							|  |  |  |         'topicsKeywords': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.IMChat.topicsKeywords`), | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |           inputType: 'textarea', | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'fileType': { label: t(`${fieldPrefix}.IMChat.fileType`) }, | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |       }, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     wikipedia_entry: { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |       text: t('datasetDocuments.metadata.type.wikipediaEntry'), | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |       allowEdit: false, | 
					
						
							|  |  |  |       subFieldsMap: { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'title': { label: t(`${fieldPrefix}.wikipediaEntry.title`) }, | 
					
						
							|  |  |  |         'language': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.wikipediaEntry.language`), | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |           inputType: 'select', | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'web_page_url': { label: t(`${fieldPrefix}.wikipediaEntry.webpageURL`) }, | 
					
						
							|  |  |  |         'editor/contributor': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.wikipediaEntry.editorContributor`), | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'last_edit_date': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.wikipediaEntry.lastEditDate`), | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'summary/introduction': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.wikipediaEntry.summaryIntroduction`), | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |           inputType: 'textarea', | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |         }, | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     synced_from_notion: { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |       text: t('datasetDocuments.metadata.type.notion'), | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |       allowEdit: false, | 
					
						
							|  |  |  |       subFieldsMap: { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'title': { label: t(`${fieldPrefix}.notion.title`) }, | 
					
						
							|  |  |  |         'language': { label: t(`${fieldPrefix}.notion.lang`), inputType: 'select' }, | 
					
						
							|  |  |  |         'author/creator': { label: t(`${fieldPrefix}.notion.author`) }, | 
					
						
							|  |  |  |         'creation_date': { label: t(`${fieldPrefix}.notion.createdTime`) }, | 
					
						
							|  |  |  |         'last_modified_date': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.notion.lastModifiedTime`), | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'notion_page_link': { label: t(`${fieldPrefix}.notion.url`) }, | 
					
						
							|  |  |  |         'category/tags': { label: t(`${fieldPrefix}.notion.tag`) }, | 
					
						
							|  |  |  |         'description': { label: t(`${fieldPrefix}.notion.desc`) }, | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |       }, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     synced_from_github: { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |       text: t('datasetDocuments.metadata.type.github'), | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |       allowEdit: false, | 
					
						
							|  |  |  |       subFieldsMap: { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'repository_name': { label: t(`${fieldPrefix}.github.repoName`) }, | 
					
						
							|  |  |  |         'repository_description': { label: t(`${fieldPrefix}.github.repoDesc`) }, | 
					
						
							|  |  |  |         'repository_owner/organization': { label: t(`${fieldPrefix}.github.repoOwner`) }, | 
					
						
							|  |  |  |         'code_filename': { label: t(`${fieldPrefix}.github.fileName`) }, | 
					
						
							|  |  |  |         'code_file_path': { label: t(`${fieldPrefix}.github.filePath`) }, | 
					
						
							|  |  |  |         'programming_language': { label: t(`${fieldPrefix}.github.programmingLang`) }, | 
					
						
							|  |  |  |         'github_link': { label: t(`${fieldPrefix}.github.url`) }, | 
					
						
							|  |  |  |         'open_source_license': { label: t(`${fieldPrefix}.github.license`) }, | 
					
						
							|  |  |  |         'commit_date': { label: t(`${fieldPrefix}.github.lastCommitTime`) }, | 
					
						
							|  |  |  |         'commit_author': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.github.lastCommitAuthor`), | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     originInfo: { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |       text: '', | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |       allowEdit: false, | 
					
						
							|  |  |  |       subFieldsMap: { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'name': { label: t(`${fieldPrefix}.originInfo.originalFilename`) }, | 
					
						
							|  |  |  |         'data_source_info.upload_file.size': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.originInfo.originalFileSize`), | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |           render: value => formatFileSize(value), | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'created_at': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.originInfo.uploadDate`), | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |           render: value => dayjs.unix(value).format(t('datasetDocuments.metadata.dateTimeFormat') as string), | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'completed_at': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.originInfo.lastUpdateDate`), | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |           render: value => dayjs.unix(value).format(t('datasetDocuments.metadata.dateTimeFormat') as string), | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'data_source_type': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.originInfo.source`), | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |           render: value => t(`datasetDocuments.metadata.source.${value}`), | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |       }, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     technicalParameters: { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |       text: t('datasetDocuments.metadata.type.technicalParameters'), | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |       allowEdit: false, | 
					
						
							|  |  |  |       subFieldsMap: { | 
					
						
							|  |  |  |         'dataset_process_rule.mode': { | 
					
						
							|  |  |  |           label: t(`${fieldPrefix}.technicalParameters.segmentSpecification`), | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |           render: value => value === 'automatic' ? (t('datasetDocuments.embedding.automatic') as string) : (t('datasetDocuments.embedding.custom') as string), | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |         }, | 
					
						
							|  |  |  |         'dataset_process_rule.rules.segmentation.max_tokens': { | 
					
						
							|  |  |  |           label: t(`${fieldPrefix}.technicalParameters.segmentLength`), | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |           render: value => formatNumber(value), | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'average_segment_length': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.technicalParameters.avgParagraphLength`), | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |           render: value => `${formatNumber(value)} characters`, | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'segment_count': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.technicalParameters.paragraphs`), | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |           render: value => `${formatNumber(value)} paragraphs`, | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'hit_count': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.technicalParameters.hitCount`), | 
					
						
							|  |  |  |           render: (value, total) => { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |             const v = value || 0 | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |             return `${!total ? 0 : ((v / total) * 100).toFixed(2)}% (${v}/${total})` | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |           }, | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'indexing_latency': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.technicalParameters.embeddingTime`), | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |           render: value => formatTime(value), | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |         'tokens': { | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |           label: t(`${fieldPrefix}.technicalParameters.embeddedSpend`), | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |           render: value => `${formatNumber(value)} tokens`, | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |         }, | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  | const langPrefix = 'datasetDocuments.metadata.languageMap.' | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | export const useLanguages = () => { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |   const { t } = useTranslation() | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |   return { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |     zh: t(`${langPrefix}zh`), | 
					
						
							|  |  |  |     en: t(`${langPrefix}en`), | 
					
						
							|  |  |  |     es: t(`${langPrefix}es`), | 
					
						
							|  |  |  |     fr: t(`${langPrefix}fr`), | 
					
						
							|  |  |  |     de: t(`${langPrefix}de`), | 
					
						
							|  |  |  |     ja: t(`${langPrefix}ja`), | 
					
						
							|  |  |  |     ko: t(`${langPrefix}ko`), | 
					
						
							|  |  |  |     ru: t(`${langPrefix}ru`), | 
					
						
							|  |  |  |     ar: t(`${langPrefix}ar`), | 
					
						
							|  |  |  |     pt: t(`${langPrefix}pt`), | 
					
						
							|  |  |  |     it: t(`${langPrefix}it`), | 
					
						
							|  |  |  |     nl: t(`${langPrefix}nl`), | 
					
						
							|  |  |  |     pl: t(`${langPrefix}pl`), | 
					
						
							|  |  |  |     sv: t(`${langPrefix}sv`), | 
					
						
							|  |  |  |     tr: t(`${langPrefix}tr`), | 
					
						
							|  |  |  |     he: t(`${langPrefix}he`), | 
					
						
							|  |  |  |     hi: t(`${langPrefix}hi`), | 
					
						
							|  |  |  |     da: t(`${langPrefix}da`), | 
					
						
							|  |  |  |     fi: t(`${langPrefix}fi`), | 
					
						
							|  |  |  |     no: t(`${langPrefix}no`), | 
					
						
							|  |  |  |     hu: t(`${langPrefix}hu`), | 
					
						
							|  |  |  |     el: t(`${langPrefix}el`), | 
					
						
							|  |  |  |     cs: t(`${langPrefix}cs`), | 
					
						
							|  |  |  |     th: t(`${langPrefix}th`), | 
					
						
							|  |  |  |     id: t(`${langPrefix}id`), | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  | const bookCategoryPrefix = 'datasetDocuments.metadata.categoryMap.book.' | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | export const useBookCategories = () => { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |   const { t } = useTranslation() | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |   return { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |     fiction: t(`${bookCategoryPrefix}fiction`), | 
					
						
							|  |  |  |     biography: t(`${bookCategoryPrefix}biography`), | 
					
						
							|  |  |  |     history: t(`${bookCategoryPrefix}history`), | 
					
						
							|  |  |  |     science: t(`${bookCategoryPrefix}science`), | 
					
						
							|  |  |  |     technology: t(`${bookCategoryPrefix}technology`), | 
					
						
							|  |  |  |     education: t(`${bookCategoryPrefix}education`), | 
					
						
							|  |  |  |     philosophy: t(`${bookCategoryPrefix}philosophy`), | 
					
						
							|  |  |  |     religion: t(`${bookCategoryPrefix}religion`), | 
					
						
							|  |  |  |     socialSciences: t(`${bookCategoryPrefix}socialSciences`), | 
					
						
							|  |  |  |     art: t(`${bookCategoryPrefix}art`), | 
					
						
							|  |  |  |     travel: t(`${bookCategoryPrefix}travel`), | 
					
						
							|  |  |  |     health: t(`${bookCategoryPrefix}health`), | 
					
						
							|  |  |  |     selfHelp: t(`${bookCategoryPrefix}selfHelp`), | 
					
						
							|  |  |  |     businessEconomics: t(`${bookCategoryPrefix}businessEconomics`), | 
					
						
							|  |  |  |     cooking: t(`${bookCategoryPrefix}cooking`), | 
					
						
							|  |  |  |     childrenYoungAdults: t(`${bookCategoryPrefix}childrenYoungAdults`), | 
					
						
							|  |  |  |     comicsGraphicNovels: t(`${bookCategoryPrefix}comicsGraphicNovels`), | 
					
						
							|  |  |  |     poetry: t(`${bookCategoryPrefix}poetry`), | 
					
						
							|  |  |  |     drama: t(`${bookCategoryPrefix}drama`), | 
					
						
							|  |  |  |     other: t(`${bookCategoryPrefix}other`), | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  | const personalDocCategoryPrefix | 
					
						
							|  |  |  |   = 'datasetDocuments.metadata.categoryMap.personalDoc.' | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | export const usePersonalDocCategories = () => { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |   const { t } = useTranslation() | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |   return { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |     notes: t(`${personalDocCategoryPrefix}notes`), | 
					
						
							|  |  |  |     blogDraft: t(`${personalDocCategoryPrefix}blogDraft`), | 
					
						
							|  |  |  |     diary: t(`${personalDocCategoryPrefix}diary`), | 
					
						
							|  |  |  |     researchReport: t(`${personalDocCategoryPrefix}researchReport`), | 
					
						
							|  |  |  |     bookExcerpt: t(`${personalDocCategoryPrefix}bookExcerpt`), | 
					
						
							|  |  |  |     schedule: t(`${personalDocCategoryPrefix}schedule`), | 
					
						
							|  |  |  |     list: t(`${personalDocCategoryPrefix}list`), | 
					
						
							|  |  |  |     projectOverview: t(`${personalDocCategoryPrefix}projectOverview`), | 
					
						
							|  |  |  |     photoCollection: t(`${personalDocCategoryPrefix}photoCollection`), | 
					
						
							|  |  |  |     creativeWriting: t(`${personalDocCategoryPrefix}creativeWriting`), | 
					
						
							|  |  |  |     codeSnippet: t(`${personalDocCategoryPrefix}codeSnippet`), | 
					
						
							|  |  |  |     designDraft: t(`${personalDocCategoryPrefix}designDraft`), | 
					
						
							|  |  |  |     personalResume: t(`${personalDocCategoryPrefix}personalResume`), | 
					
						
							|  |  |  |     other: t(`${personalDocCategoryPrefix}other`), | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  | const businessDocCategoryPrefix | 
					
						
							|  |  |  |   = 'datasetDocuments.metadata.categoryMap.businessDoc.' | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | export const useBusinessDocCategories = () => { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |   const { t } = useTranslation() | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |   return { | 
					
						
							| 
									
										
										
										
											2024-01-08 18:06:23 +08:00
										 |  |  |     meetingMinutes: t(`${businessDocCategoryPrefix}meetingMinutes`), | 
					
						
							|  |  |  |     researchReport: t(`${businessDocCategoryPrefix}researchReport`), | 
					
						
							|  |  |  |     proposal: t(`${businessDocCategoryPrefix}proposal`), | 
					
						
							|  |  |  |     employeeHandbook: t(`${businessDocCategoryPrefix}employeeHandbook`), | 
					
						
							|  |  |  |     trainingMaterials: t(`${businessDocCategoryPrefix}trainingMaterials`), | 
					
						
							|  |  |  |     requirementsDocument: t(`${businessDocCategoryPrefix}requirementsDocument`), | 
					
						
							|  |  |  |     designDocument: t(`${businessDocCategoryPrefix}designDocument`), | 
					
						
							|  |  |  |     productSpecification: t(`${businessDocCategoryPrefix}productSpecification`), | 
					
						
							|  |  |  |     financialReport: t(`${businessDocCategoryPrefix}financialReport`), | 
					
						
							|  |  |  |     marketAnalysis: t(`${businessDocCategoryPrefix}marketAnalysis`), | 
					
						
							|  |  |  |     projectPlan: t(`${businessDocCategoryPrefix}projectPlan`), | 
					
						
							|  |  |  |     teamStructure: t(`${businessDocCategoryPrefix}teamStructure`), | 
					
						
							|  |  |  |     policiesProcedures: t(`${businessDocCategoryPrefix}policiesProcedures`), | 
					
						
							|  |  |  |     contractsAgreements: t(`${businessDocCategoryPrefix}contractsAgreements`), | 
					
						
							|  |  |  |     emailCorrespondence: t(`${businessDocCategoryPrefix}emailCorrespondence`), | 
					
						
							|  |  |  |     other: t(`${businessDocCategoryPrefix}other`), | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |