File size: 588 Bytes
b0768ab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import type { PromptExample } from '@/types/example';

/**
 * Get all unique sub-types from a collection of examples
 */
export function getUniqueSubTypes(examples: PromptExample[]): string[] {
  const subTypes = new Set<string>();
  examples.forEach(example => {
    if (example.子題型) {
      subTypes.add(example.子題型);
    }
  });
  return Array.from(subTypes);
}

/**
 * Filter examples by sub-type
 */
export function getExamplesBySubType(examples: PromptExample[], subType: string): PromptExample[] {
  return examples.filter(example => example.子題型 === subType);
}