PatentsLens

Methods

PatentsLens.merge_applicants!Method
merge_applicants!(db::LensDB, regex::String; new_name, new_country) -> SQLite.Query
merge_applicants!(
    db::LensDB,
    regex::String,
    kwargs...
)

Merge all applicants whose names match the regular expression regex into one applicant. The new applicant will have the id, name and country of the first matching applicant, unless otherwise specified using the new_name and new_country parameters. All references will be updated to point to the new applicant.

Optional keyword arguments:

  • new_name: A String with the name for the new applicant entry
  • new_country: A String with the country code for the new applicant entry
source
PatentsLens.merge_applicants!Method
merge_applicants!(db::LensDB, applicants::Vector{Int64}; new_name, new_country) -> SQLite.Query
merge_applicants!(
    db::LensDB,
    applicants::Vector{Int},
    kwargs...
)

Merge a list of applicants identified by their IDs into one applicant. The new applicant will have the name and country of the first listed applicant, unless otherwise specified using the new_name and new_country keyword arguments. All references will be updated to point to the new applicant.

Optional keyword arguments:

  • new_name: A String with the name for the new applicant entry
  • new_country: A String with the country code for the new applicant entry
source
PatentsLens.apply_application_filter!Method
apply_application_filter!(db::LensDB, filter::PatentsBase.AbstractFilter) -> SQLite.Query

Apply filter to database db, generating a temporary table of matching applications.

source
PatentsLens.apply_family_filter!Method
apply_family_filter!(db::LensDB, filter::PatentsBase.AbstractFilter) -> SQLite.Query

Apply filter to database db, generating a temporary table of matching patent families.

source
PatentsLens.build_index!Method
build_index!(db::SQLite.DB)

Build the key search index of the database db. This has no effect on the FTS5 full-text search index.

source
PatentsLens.bulk_insert_apps!Method
bulk_insert_apps!(db::SQLite.DB, apps::Vector{LensApplication}) -> String

Insert the applications listed in apps into the database db, replacing existing data on conflict, but preserving and extending party, family and citation relation graphs.

source
PatentsLens.db_keyFunction

Helper function to return database table or column names or key values for certain dispatch types.

source
PatentsLens.doc_keyMethod
doc_key(a::LensApplication) -> String

Return a String with the full document key of application a

source
PatentsLens.docdb_idMethod
docdb_id(a::LensApplication) -> Union{Nothing, Int64}

Return an Int representing the database ID of application a, or nothing if the field is missing

source
PatentsLens.drop_index!Method
drop_index!(db::SQLite.DB)

Drop the key search index of the database db. This has no effect on the FTS5 full-text search index.

source
PatentsLens.ignore_fulltext!Function
ignore_fulltext!() -> Any
ignore_fulltext!(toggle::Bool) -> Any

Toggle whether PatentsLens should skip full text information when importing data files. This can improve performance and might be needed for large datasets to fit into memory.

source
PatentsLens.initdb!Method
initdb!(db::SQLite.DB)

Initialize the schema of the database db. This removes all existing PatentsLens data!

source
PatentsLens.languageMethod
language(a::LensApplication) -> Union{Nothing, String}

Return a String with the language code of application a, or nothing if the field is missing

source
PatentsLens.load_jsonl!Method
load_jsonl!(db::LensDB, path::String; chunk_size, skip_on_error, rebuild_index) -> Union{Nothing, Bool}
load_jsonl!(db::LensDB, path::String, kwargs...)

Read all application data from the Lens.org JSON lines data file at path, and store it in the SQLite database db. The database must be set up with the proper table schema beforehand.

Optional keyword arguments:

  • chunk_size: controls how many lines are read into memory before being bulk-inserted into the database. Higher values will improve speed at the cost of requiring more memory.
  • skip_on_error: If true, loading process will not terminate when encountering a parsing error, but continue with the next record instead.
  • rebuild_index: If true (default), the search index for the database will be dropped and fully rebuilt instead of updating it. This tends to be faster when importing a large amount of data relative to the amount already in the database.
source
PatentsLens.query_select_applicationsMethod
query_select_applications(f::PatentsBase.AbstractFilter) -> PatentsLens.UnboundQuery

Generate an SQLite query to select the Lens IDs of all applications matching f.

source
PatentsLens.query_select_familiesMethod
query_select_families(f::PatentsBase.AbstractFilter) -> PatentsLens.UnboundQuery

Generate an SQLite query to select the family IDs of all families matching f.

source
PatentsLens.read_jsonlMethod
read_jsonl(path::String; skip_on_error) -> Vector{LensApplication}
read_jsonl(path::String, kwargs...)

Return a Vector{LensApplication} with all applications from the Lens.org JSON lines data file at path.

Optional keyword arguments:

  • skip_on_error: If true, loading process will not terminate when encountering a parsing error, but continue with the next record instead.
source
PatentsLens.validate_injMethod
validate_inj(s::String) -> Bool

Validate a string can be safely pasted into a SQL query without injection risk

source

Types

PatentsLens.LensAbstractType
struct LensAbstract <: PatentsBase.AbstractShortDescription

Struct representing the abstract or short description of a patent application in the Lens.org format

Fields:

  • abstract::Vector{PatentsLens.LensLocalizedText}
source
PatentsLens.LensApplicantType
struct LensApplicant <: PatentsBase.AbstractApplicant

Struct representing a patent applicant in the Lens.org format

Fields:

  • residence::Union{Nothing, String}

  • extracted_name::Union{Nothing, PatentsLens.LensExtractedName}

  • id::Union{Nothing, Int64}

source
PatentsLens.LensApplicationType
struct LensApplication <: PatentsBase.AbstractApplication

Struct representing a patent application retrieved from Lens.org.

Fields:

  • lens_id::String

  • publication_type::String

  • jurisdiction::String

  • doc_number::String

  • kind::String

  • date_published::Union{Nothing, Dates.Date}

  • doc_key::String

  • docdb_id::Union{Nothing, Int64}

  • lang::Union{Nothing, String}

  • biblio::PatentsLens.LensBiblio

  • abstract::Union{Nothing, LensAbstract}

  • claims::Union{Nothing, PatentsLens.LensClaims}

  • description::Union{Nothing, LensFulltext}

  • families::PatentsLens.LensFamilies

source
PatentsLens.LensApplicationReferenceType
struct LensApplicationReference <: PatentsBase.AbstractApplicationID

Struct representing a reference to a patent application in the Lens.org format

Fields:

  • document_id::PatentsLens.LensDocumentID

  • lens_id::Union{Nothing, String}

source
PatentsLens.LensClaimType
struct LensClaim <: PatentsBase.AbstractClaim

Struct representing a patent claim in the Lens.org format.

Fields:

  • claim::Vector{PatentsLens.LensLocalizedText}
source
PatentsLens.LensDBType
struct LensDB <: PatentsBase.AbstractDataSource
LensDB(db::SQLite.DB)
LensDB(file::String)

Wrapper around an SQLite database containing PatentsLens data.

The constructor will create a new database if one does not exist at the specified location. It will also initialize the database with the correct schema if necessary.

Fields:

  • db::SQLite.DB
source
PatentsLens.LensFamilyType
struct LensFamily <: PatentsBase.AbstractFamily

Struct representing an aggregated patent family in the Lens.org format

Fields:

  • members::Vector{LensApplication}
source
PatentsLens.LensForwardCitationType
struct LensForwardCitation <: PatentsBase.AbstractPatentCitation

Struct representing a forward citation ("cited by"-entry) in the Lens.org format

Fields:

  • ref::LensApplicationReference
source
PatentsLens.LensFulltextType
struct LensFulltext <: PatentsBase.AbstractFulltext

Struct representing the full text of a patent application in the Lens.org format

Fields:

  • text::String

  • lang::Union{Nothing, String}

source
PatentsLens.LensInventorType
struct LensInventor <: PatentsBase.AbstractInventor

Struct representing a patent inventor in the Lens.org format

Fields:

  • residence::Union{Nothing, String}

  • extracted_name::Union{Nothing, PatentsLens.LensExtractedName}

  • id::Union{Nothing, Int64}

source
PatentsLens.LensNPLCitationType
struct LensNPLCitation <: PatentsBase.AbstractNPLCitation

Struct representing a non-patent literature (NPL) citation in the Lens.org format

Fields:

  • sequence::Union{Nothing, Int64}

  • nplcit::Union{Nothing, PatentsLens.LensNPLCitationInner}

  • cited_phase::Union{Nothing, String}

source
PatentsLens.LensPatentCitationType
struct LensPatentCitation <: PatentsBase.AbstractPatentCitation

Struct representing a patent citation in the Lens.org format

Fields:

  • sequence::Union{Nothing, Int64}

  • patcit::Union{Nothing, LensApplicationReference}

  • cited_phase::Union{Nothing, String}

source
PatentsLens.LensPortfolioType
struct LensPortfolio <: PatentsBase.AbstractPortfolio

Struct representing a party's portfolio of patent applications

Fields:

  • owner::PatentsBase.AbstractParty

  • applications::Union{Nothing, Vector{LensApplication}}

  • families::Union{Nothing, Vector{LensFamily}}

source
PatentsLens.LensTitleType
struct LensTitle <: PatentsBase.AbstractTitle

Struct representing the title of a patent application in the Lens.org format

Fields:

  • title::Vector{PatentsLens.LensLocalizedText}
source
PatentsLens.LensDocumentIDType
struct LensDocumentID <: PatentsBase.AbstractApplicationID

Struct implementation of PatentsBase.AbstractApplicationID in the Lens.org format

Fields:

  • jurisdiction::String

  • doc_number::String

  • kind::Union{Nothing, String}

  • date::Union{Nothing, Dates.Date}

source
PatentsLens.UnboundQueryType
struct UnboundQuery

Struct representing a query with placeholders along with the parameters to bind to those placeholders

Fields:

  • text::String

  • params::Vector{String}

source