def run(): # Bootstrap logging boot_logging() # Load configuration configFile = LoadConfig() # Run this step only if enabled if configFile.FormateExportCountryCartography: # Get some paths from configuration storage_path = configFile.ResultBiblioPath output_path = configFile.ResultPath # Compute prefixes prefixes = [""] if configFile.GatherFamilly: prefixes.append("Families") # Build maps for all prefixes for prefix in prefixes: # Status message label = label_from_prefix(prefix) logger.info( "Generating maps about patent issuing countries for {}. ". format(label)) # Compute storage slot storage_name = prefix + configFile.ndf # Generate map generate_map(storage_path, storage_name, output_path) # Due to limit of D3, countries resources are necessary placed # in same working directory... other solution is to start an http server # http://stackoverflow.com/questions/17077931/d3-samples-in-a-microsoft-stack # Clone required resources into result directory shutil.copy('countries.json', os.path.join(output_path, "countries.json"))
def run(): # Bootstrap logging boot_logging() # Load configuration config = LoadConfig() # Run this only if enabled if not config.GatherImages: return # Get some information from configuration expression = config.requete storage_basedir = config.ResultBiblioPath storage_dirname = config.ndf output_path = config.ResultPathImages # Compute prefixes prefixes = [""] if config.GatherFamilly: prefixes.append("Families") # Build maps for all prefixes for prefix in prefixes: # Status message label = label_from_prefix(prefix) logger.info("Generating gallery of drawings for {}. ".format(label)) # Compute storage slot using prefix and DataDirectory # e.g. "Lentille" vs. "FamiliesLentille" storage_name = prefix + storage_dirname # Load bibliographic data biblio_file = LoadBiblioFile(storage_basedir, storage_name) # Generate thumbnails gallery = [] patents = biblio_file['brevets'] cpt = 0 for patent in patents: cpt + 1 AnnonceProgres(Appli='p2n_image', valMax=100, valActu=90 + cpt * 10 / len(patents)) patent_label = get_patent_label(patent) i = 1 logger.info('Processing patent {}'.format(patent_label)) path_img_base = '{}//{}-{}.tiff'.format(output_path, patent_label, '{}') path = path_img_base.format(i) while os.path.exists(path): thumb, orig, tiff = generate_thumbnails(path) gallery.append({ "_id": '{}-{}'.format(patent_label, i), 'thumb': thumb, 'orig': orig, 'label': patent['title'], 'ipcr7': patent['IPCR7'], 'code': patent_label, 'tiff': tiff, }) i += 1 path = path_img_base.format(i) # Render gallery AnnonceProgres(Appli='p2n_image', valMax=100, valActu=100) RenderTemplate( 'ModeleImages.html', output_path + '/index' + prefix + '.html', request=expression.replace('"', ''), gallery=gallery, json=json.dumps(gallery), )
def run(): """ Usage: p2n ops init --key=<ops-oauth-key> --secret=<ops-oauth-secret> p2n run [--config=requete.cql] [--with-family] p2n acquire [--config=requete.cql] [--with-family] p2n normalisation [--config=requete.cql] p2n maps [--config=requete.cql] p2n networks [--config=requete.cql] p2n tables [--config=requete.cql] p2n bibfile [--config=requete.cql] p2n iramuteq [--config=requete.cql] p2n freeplane [--config=requete.cql] p2n carrot [--config=requete.cql] p2n images [--config=requete.cql] p2n cluster [--config=requete.cql] p2n interface [--config=requete.cql] p2n adhoc search --expression=<expression> p2n adhoc dump --expression=<expression> [--format=<format>] [--with-family] [--with-register] p2n adhoc list --expression=<expression> [--with-family] [--field=<field>] [--with-register] p2n adhoc worldmap --expression=<expression> --country-field=<country-field> [--with-family] [--with-register] p2n adhoc pivot --expression=<expression> [--format=<format>] [--with-family] [--with-register] p2n --version p2n (-h | --help) ------------ Classic mode ------------ p2n ops init Initialize Patent2Net with OPS OAuth credentials p2n run Run data acquisition and all formatters p2n acquire Run document acquisition --with-family Also run family data acquisition with "p2n acquire" p2n normalisation Suppress multiples equivalents, operates cleaning process in names (applicants and inventors). this is just for retrocompatibility as these steps are included in acquire process p2n maps Build maps of country coverage of patents, as well as applicants and inventors p2n networks Build various artefacts for data exploration based on network graphs p2n tables Export various artefacts for tabular data exploration p2n bibfile Export data in bibfile format p2n iramuteq Fetch more data and export it to suitable format for using in Iramuteq p2n freeplane Build mind map for Freeplane p2n carrot Export data to XML suitable for using in Carrot p2n images Fetch images and build thumbnails p2n cluster Build a double clusterer interface mixing abstracts and IPC description p2n interface Build main Patent2Net html interface Options: --config=<config> Path to requete.cql. Will fall back to environment variable "P2N_CONFIG". Examples: # Initialize Patent2Net with OPS OAuth credentials p2n ops init --key=ScirfedyifJiashwOckNoupNecpainLo --secret=degTefyekDevgew1 # Run query and gather data p2n acquire --config=/path/to/RequestsSets/Lentille.cql --with-family # Build all world maps export P2N_CONFIG=/path/to/RequestsSets/Lentille.cql p2n maps # Run data acquisition and all targets p2n run ----------- Ad hoc mode ----------- p2n ops init Initialize Patent2Net with OPS OAuth credentials p2n adhoc search Display search results for given query expression in raw OPS format (JSON) p2n adhoc dump Display full results for given query expression in OpsExchangeDocument or Patent2NetBrevet format (JSON) p2n adhoc list Display list of values from single field for given query expression p2n adhoc worldmap Generate world map for given query expression over given field p2n adhoc pivot Generate data for pivot table Options: --expression=<expression> Search expression in CQL format, e.g. "TA=lentille" --format=<format> Control output format for "p2n adhoc dump", Choose from "ops" or "brevet" [default: ops]. --field=<field> Which field name to use with "p2n adhoc list" [default: document_number]. --with-register Also acquire register information for each result hit. Required for "--country-field=register.designated_states". --country-field=<country-field> Field name of country code for "p2n adhoc worldmap" e.g. "country", "applicants", "inventors", "register.designated_states" Examples: # Initialize Patent2Net with OPS OAuth credentials p2n ops init --key=ScirfedyifJiashwOckNoupNecpainLo --secret=degTefyekDevgew1 # Run query and output results in OpsExchangeDocument format (JSON) p2n adhoc dump --expression='TA=lentille' # Run query and output results in Patent2NetBrevet format (JSON) p2n adhoc dump --expression='TA=lentille' --format=brevet # Run query and output list of document numbers, including family members (JSON) p2n adhoc list --expression='TA=lentille' --with-family # Run query and output list of application numbers in epodoc format p2n adhoc list --expression='TA=lentille' --field='application_number_epodoc' # Generate data for world maps using d3plus/geo_map (JSON) p2n adhoc worldmap --expression='TA=lentille' --country-field='country' p2n adhoc worldmap --expression='TA=lentille' --country-field='applicants' p2n adhoc worldmap --expression='TA=lentille' --country-field='inventors' p2n adhoc worldmap --expression='TA=lentille' --country-field='register.designated_states' --with-register # Generate data suitable for PivotTable.js (JSON) p2n adhoc pivot --expression='TA=lentille' --with-family """ # Use generic commandline options schema and amend with current program name commandline_schema = (run.__doc__).format(program=APP_NAME) # Read commandline options options = docopt.docopt(commandline_schema, version=APP_NAME + ' ' + __version__) # Start logging subsystem boot_logging(options) # Clean option names options = normalize_docopt_options(options) # Debugging #print('Options:\n{}'.format(pformat(options))) # Patent2Net ad-hoc mode interface if options['adhoc']: adhoc_interface(options) # Patent2Net classic interface else: classic_interface(options)