PatentsLens
Methods
PatentsLens.merge_applicants!
— Methodmerge_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
: AString
with the name for the new applicant entrynew_country
: AString
with the country code for the new applicant entry
PatentsLens.merge_applicants!
— Methodmerge_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
: AString
with the name for the new applicant entrynew_country
: AString
with the country code for the new applicant entry
PatentsLens.apply_application_filter!
— Methodapply_application_filter!(db::LensDB, filter::PatentsBase.AbstractFilter) -> SQLite.Query
Apply filter
to database db
, generating a temporary table of matching applications.
PatentsLens.apply_family_filter!
— Methodapply_family_filter!(db::LensDB, filter::PatentsBase.AbstractFilter) -> SQLite.Query
Apply filter
to database db
, generating a temporary table of matching patent families.
PatentsLens.build_index!
— Methodbuild_index!(db::SQLite.DB)
Build the key search index of the database db
. This has no effect on the FTS5 full-text search index.
PatentsLens.bulk_insert_apps!
— Methodbulk_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.
PatentsLens.clear_filter!
— Methodclear_filter!(db::LensDB) -> SQLite.Query
Remove all active filters from a PatentsLens database.
PatentsLens.date_to_text
— Methoddate_to_text(date::Dates.Date) -> String
Convert a Date
to a text format for storage in SQLite.
PatentsLens.db
— Methoddb(ldb::LensDB) -> SQLite.DB
Return the SQLite.DB
wrapped by ldb
.
PatentsLens.db_key
— FunctionHelper function to return database table or column names or key values for certain dispatch types.
PatentsLens.doc_key
— Methoddoc_key(a::LensApplication) -> String
Return a String
with the full document key of application a
PatentsLens.docdb_id
— Methoddocdb_id(a::LensApplication) -> Union{Nothing, Int64}
Return an Int
representing the database ID of application a
, or nothing
if the field is missing
PatentsLens.drop_index!
— Methoddrop_index!(db::SQLite.DB)
Drop the key search index of the database db
. This has no effect on the FTS5 full-text search index.
PatentsLens.ignore_fulltext!
— Functionignore_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.
PatentsLens.initdb!
— Methodinitdb!(db::SQLite.DB)
Initialize the schema of the database db
. This removes all existing PatentsLens data!
PatentsLens.language
— Methodlanguage(a::LensApplication) -> Union{Nothing, String}
Return a String
with the language code of application a
, or nothing
if the field is missing
PatentsLens.list_placeholder
— Methodlist_placeholder(n::Int64) -> String
Generate a placeholder for a list of n
elements in an SQLite query
PatentsLens.load_jsonl!
— Methodload_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.
PatentsLens.publication_type
— Methodpublication_type(a::LensApplication) -> String
Return a String
with the document type of application a
PatentsLens.query_select_applications
— Methodquery_select_applications(f::PatentsBase.AbstractFilter) -> PatentsLens.UnboundQuery
Generate an SQLite query to select the Lens IDs of all applications matching f
.
PatentsLens.query_select_families
— Methodquery_select_families(f::PatentsBase.AbstractFilter) -> PatentsLens.UnboundQuery
Generate an SQLite query to select the family IDs of all families matching f
.
PatentsLens.read_jsonl
— Methodread_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.
PatentsLens.set_pragmas!
— Methodset_pragmas!(db::SQLite.DB)
Set the required pragmas on the database connection db
.
PatentsLens.validate_inj
— Methodvalidate_inj(s::String) -> Bool
Validate a string can be safely pasted into a SQL query without injection risk
Types
PatentsLens.LensAbstract
— Typestruct LensAbstract <: PatentsBase.AbstractShortDescription
Struct representing the abstract or short description of a patent application in the Lens.org format
Fields:
abstract::Vector{PatentsLens.LensLocalizedText}
PatentsLens.LensApplicant
— Typestruct 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}
PatentsLens.LensApplication
— Typestruct 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
PatentsLens.LensApplicationReference
— Typestruct 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}
PatentsLens.LensClaim
— Typestruct LensClaim <: PatentsBase.AbstractClaim
Struct representing a patent claim in the Lens.org format.
Fields:
claim::Vector{PatentsLens.LensLocalizedText}
PatentsLens.LensDB
— Typestruct 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
PatentsLens.LensFamily
— Typestruct LensFamily <: PatentsBase.AbstractFamily
Struct representing an aggregated patent family in the Lens.org format
Fields:
members::Vector{LensApplication}
PatentsLens.LensForwardCitation
— Typestruct LensForwardCitation <: PatentsBase.AbstractPatentCitation
Struct representing a forward citation ("cited by"-entry) in the Lens.org format
Fields:
ref::LensApplicationReference
PatentsLens.LensFulltext
— Typestruct LensFulltext <: PatentsBase.AbstractFulltext
Struct representing the full text of a patent application in the Lens.org format
Fields:
text::String
lang::Union{Nothing, String}
PatentsLens.LensInventor
— Typestruct 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}
PatentsLens.LensNPLCitation
— Typestruct 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}
PatentsLens.LensPatentCitation
— Typestruct 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}
PatentsLens.LensPortfolio
— Typestruct 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}}
PatentsLens.LensTitle
— Typestruct LensTitle <: PatentsBase.AbstractTitle
Struct representing the title of a patent application in the Lens.org format
Fields:
title::Vector{PatentsLens.LensLocalizedText}
PatentsLens.LensDocumentID
— Typestruct 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}
PatentsLens.UnboundQuery
— Typestruct UnboundQuery
Struct representing a query with placeholders along with the parameters to bind to those placeholders
Fields:
text::String
params::Vector{String}