2024-07-24 12:50:48 +08:00
|
|
|
import { useCallback } from 'react'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
|
|
|
|
export const useKnowledge = () => {
|
|
|
|
const { t } = useTranslation()
|
|
|
|
|
|
|
|
const formatIndexingTechnique = useCallback((indexingTechnique: string) => {
|
|
|
|
return t(`dataset.indexingTechnique.${indexingTechnique}`)
|
|
|
|
}, [t])
|
|
|
|
|
2024-07-30 16:59:03 +08:00
|
|
|
const formatIndexingMethod = useCallback((indexingMethod: string, isEco?: boolean) => {
|
|
|
|
if (isEco)
|
|
|
|
return t('dataset.indexingMethod.invertedIndex')
|
|
|
|
|
2024-07-24 12:50:48 +08:00
|
|
|
return t(`dataset.indexingMethod.${indexingMethod}`)
|
|
|
|
}, [t])
|
|
|
|
|
|
|
|
const formatIndexingTechniqueAndMethod = useCallback((indexingTechnique: string, indexingMethod: string) => {
|
|
|
|
let result = formatIndexingTechnique(indexingTechnique)
|
|
|
|
|
|
|
|
if (indexingMethod)
|
2024-07-30 16:59:03 +08:00
|
|
|
result += ` · ${formatIndexingMethod(indexingMethod, indexingTechnique === 'economy')}`
|
2024-07-24 12:50:48 +08:00
|
|
|
|
|
|
|
return result
|
|
|
|
}, [formatIndexingTechnique, formatIndexingMethod])
|
|
|
|
|
|
|
|
return {
|
|
|
|
formatIndexingTechnique,
|
|
|
|
formatIndexingMethod,
|
|
|
|
formatIndexingTechniqueAndMethod,
|
|
|
|
}
|
|
|
|
}
|