mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-14 17:08:31 +08:00
### What problem does this PR solve? feat: Added UI functions related to data-flow knowledge base #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;
|
|
}, []);
|
|
}
|