parse

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package parse maps EPO XML <exchange-document> nodes to flat PatentRecord values for downstream Parquet storage.

All exported functions are pure and goroutine-safe. The streaming pipeline calls ExtractPatentRecord per element from a pool of extractor goroutines without any synchronisation.

Per-section parsers (classifications, citations, family members) degrade to an empty slice on malformed sub-trees rather than aborting the whole record. Hard failures (missing required root attributes) still bubble up as a returned error.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Citation

type Citation struct {
	// CitedID is the country+doc-number+kind triple, e.g. "US9114971B2".
	CitedID string `parquet:"name=cited_id, type=BYTE_ARRAY, convertedtype=UTF8"`
	// Categories holds the EPO examiner relevance codes: X (highly relevant),
	// Y (relevant in combination), A (background), E, O, T, …
	Categories []string `parquet:"name=categories, type=LIST"`
}

Citation is one <citation> under <references-cited>. CitedID is the concatenated country+number+kind of the cited document; Categories captures the EPO citation categories (X, Y, A, …).

type DocumentID

type DocumentID struct {
	Country   string // two-letter country code, e.g. "US", "EP"
	DocNumber string // bare application or publication number
	Kind      string // kind code, e.g. "B2", "A1"
}

DocumentID is the country + doc-number + kind triple identifying a single patent publication.

type ExchangeDocument

type ExchangeDocument struct {
	Country               string
	DocNumber             string
	Kind                  string
	Status                string
	PatentClassifications []PatentClassification
	Citations             []Citation
	FamilyMembers         []FamilyMember
}

ExchangeDocument is the in-memory mirror of an EPO <exchange-document> element. It is the parser's internal staging type — the public, flat output is PatentRecord.

type FamilyMember

type FamilyMember struct {
	PublicationReferences []PublicationReference
}

FamilyMember is one <family-member> under <patent-family>. Each member groups the publication references for a single patent within the same simple family.

type PatentClassification

type PatentClassification struct {
	Scheme               string // e.g. "CPCI" or "IPCR"
	ClassificationSymbol string // canonical symbol, e.g. "H04L63/00"
}

PatentClassification is one <patent-classification> entry. Scheme is the classification system (e.g. "CPCI", "IPCR"); ClassificationSymbol is the canonical symbol within that scheme.

type PatentRecord

type PatentRecord struct {
	// PatentID is the EPO identifier: country+doc-number+kind, e.g. "EP1234567A1".
	PatentID string `parquet:"name=patent_id, type=BYTE_ARRAY, convertedtype=UTF8"`
	// Status is the legal status of the document, e.g. "new", "update".
	Status string `parquet:"name=status, type=BYTE_ARRAY, convertedtype=UTF8"`
	// CPCList contains the CPC (Cooperative Patent Classification) symbols
	// assigned by the examining office.
	CPCList []string `parquet:"name=cpc_list, type=LIST"`
	// Citations lists all documents cited in the examination report.
	Citations []Citation `parquet:"name=citations, type=LIST"`
	// FamilyPatents lists the DOCDB patent identifiers of all simple-family
	// members, normalised to country+doc-number+kind.
	FamilyPatents []string `parquet:"name=family_patents, type=LIST"`
}

PatentRecord is the flat Parquet row written by the streaming pipeline. Field order and parquet tags are stable contracts — changing them is a breaking change for downstream consumers.

func ExtractPatentRecord

func ExtractPatentRecord(node *xmlquery.Node) (PatentRecord, error)

ExtractPatentRecord parses an EPO exchange-document XML node into a flat PatentRecord. Stateless and goroutine-safe; performs no I/O.

type PublicationReference

type PublicationReference struct {
	// DataFormat is the DOCDB identifier format: "docdb" or "epodoc".
	DataFormat string
	DocumentID DocumentID
}

PublicationReference is one <publication-reference> with its data-format attribute (typically "docdb" or "epodoc") and the resolved DocumentID.

type RecordSource

type RecordSource interface {
	Next(*PatentRecord) (bool, error)
	Close() error
}

RecordSource yields PatentRecord values one at a time. Implementations must be safe for sequential use; concurrent access is not required.

Next reports (true, nil) for a populated record, (false, nil) on EOF, and (false, err) on any other failure. Close releases the underlying reader.

func OpenRecordSource

func OpenRecordSource(path string) (RecordSource, error)

OpenRecordSource opens path as a RecordSource. The format is selected by extension: .parquet → Parquet; .csv or .csv.gz → CSV.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL