/** * @copyright Sister Software * @license AGPL-3.0 * @author Teffen Ellis, et al. * * `street` recipe — synthetic street-decomposition rows for Stage 3 (US-only): tuples → * {@link synthesizeStreetRow} → aligned LabeledRow. Ported from the root build script it replaced. */ import { makeLcg } from "@mailwoman/core/utils" import { stableSourceID } from "#adapters/source-id" import { alignAndWrite, readTuples, type CorpusRecipe } from "#recipes/scaffold" import { defaultRecipeSource } from "#recipes/sources" import { synthesizeStreetRow, type StreetBaseTuple } from "#synthesizers/street" import { SurfaceOrigin } from "#types" /** * The recipe draws a street name from a pool and joins it to a tuple's locality, region and postcode. * * No register asserts that the street runs through that locality. * The row is invented rather than a rendering of a published record. */ /** * Resolved once, because `source_id` includes the source as its prefix and a pair * that disagreed would name a source no row of this output declares. */ const STREET_SOURCE = defaultRecipeSource("synth-street") const STREET_PROVENANCE = { register: null, surface: SurfaceOrigin.Invented, // An invented row has no underlying record to name. baseSourceID: null, } /** * Recipe registered with the corpus builder. * * The file header describes the parse behavior this recipe exercises. * `description` below shows the generated surface form. */ export const streetRecipe: CorpusRecipe = { name: "street", description: "Street-decomposition rows (US): tuples → synthesizeStreetRow → aligned LabeledRow", mode: "tuples", options: [{ flag: "--house-number-prob
", description: "P(emit a house number). Default 0.85" }],
async run(opts, write) {
if (!opts.input) throw new Error("street recipe requires --input