mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-01-04 03:25:30 +08:00
### What problem does this PR solve? Refactor Datasets UI #3221. ### Type of change - [X] New Feature (non-breaking change which adds functionality)
25 lines
531 B
TypeScript
25 lines
531 B
TypeScript
export type FormListItem = {
|
|
frequency: number;
|
|
tag: string;
|
|
};
|
|
|
|
export function transformTagFeaturesArrayToObject(
|
|
list: Array<FormListItem> = [],
|
|
) {
|
|
return list.reduce<Record<string, number>>((pre, cur) => {
|
|
pre[cur.tag] = cur.frequency;
|
|
|
|
return pre;
|
|
}, {});
|
|
}
|
|
|
|
export function transformTagFeaturesObjectToArray(
|
|
object: Record<string, number> = {},
|
|
) {
|
|
return Object.keys(object).reduce<Array<FormListItem>>((pre, key) => {
|
|
pre.push({ frequency: object[key], tag: key });
|
|
|
|
return pre;
|
|
}, []);
|
|
}
|