File size: 972 Bytes
47b4127
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import type { AttributedValue } from "@fello/contracts";

export function formatValue(field: AttributedValue | undefined | null): string {
  if (!field || field.value === null || field.value === undefined || field.value === "") {
    return "Unknown";
  }

  return String(field.value);
}

export function formatScore(value: number | null | undefined): string {
  if (value === null || value === undefined) {
    return "Unavailable";
  }

  return value.toFixed(1);
}

export function formatConfidence(value: number | null | undefined): string {
  if (value === null || value === undefined) {
    return "0%";
  }

  return `${Math.round(value * 100)}%`;
}

export function toCompanyLines(
  companies: Array<{ company_name: string; partial_domain?: string | null }>,
): string {
  return companies
    .map((company) =>
      company.partial_domain
        ? `${company.company_name}, ${company.partial_domain}`
        : company.company_name,
    )
    .join("\n");
}