| 1 |
|
| #!/usr/bin/env perl |
| 2 |
|
| |
| 3 |
|
| use strict; |
| 4 |
|
| use warnings; |
| 5 |
|
| use NOLookup::Patent::DataLookup; |
| 6 |
|
| use Encode; |
| 7 |
|
| use vars qw($opt_o $opt_n $opt_p $opt_i $opt_c $opt_v $opt_h $opt_d); |
| 8 |
|
| use Getopt::Std; |
| 9 |
|
| use Pod::Usage; |
| 10 |
|
| |
| 11 |
|
| use Data::Dumper; |
| 12 |
|
| $Data::Dumper::Indent=1; |
| 13 |
|
| |
| 14 |
|
| &getopts('hvd:o:n:p:i:c:'); |
| 15 |
|
| |
| 16 |
|
| if ($opt_h) { |
| 17 |
|
| pod2usage(); |
| 18 |
|
| } |
| 19 |
|
| |
| 20 |
|
| unless ($opt_o || $opt_n ) { |
| 21 |
|
| pod2usage("A trademark text or an application id must be specified!\n"); |
| 22 |
|
| } |
| 23 |
|
| |
| 24 |
|
| my $bo = NOLookup::Patent::DataLookup->new; |
| 25 |
|
| |
| 26 |
|
| $bo->{debug} = 1 if ($opt_d); |
| 27 |
|
| |
| 28 |
|
| if ($opt_o) { |
| 29 |
|
| $bo->lookup_tm_applid($opt_o); |
| 30 |
|
| } elsif ($opt_n) { |
| 31 |
|
| my $nm = decode('UTF-8', $opt_n); |
| 32 |
|
| $bo->lookup_tm_text($nm, $opt_p, $opt_i, $opt_c); |
| 33 |
|
| } |
| 34 |
|
| |
| 35 |
|
| if ($bo->error) { |
| 36 |
|
| print STDERR "Error: ", $bo->status, "\n"; |
| 37 |
|
| print STDERR " bo : ", Dumper $bo, "\n" if ($opt_d); |
| 38 |
|
| |
| 39 |
|
| } else { |
| 40 |
|
| if ($bo->warning) { |
| 41 |
|
| print STDERR "Warning: ", $bo->status, "\n"; |
| 42 |
|
| } |
| 43 |
|
| |
| 44 |
|
| #print "bo: ", Dumper $bo; |
| 45 |
|
| |
| 46 |
|
| if ($bo->size <1) { |
| 47 |
|
| print "No match on search\n"; |
| 48 |
|
| |
| 49 |
|
| } elsif ($bo->size >= 1 && $opt_n) { |
| 50 |
|
| # Search, multiple entries on the data array |
| 51 |
|
| my $fmt = "%-21s%-22s%-35s%s\n"; |
| 52 |
|
| |
| 53 |
|
| print "-" x 120, "\n"; |
| 54 |
|
| print "Total count ", $bo->total_size, " matching entries, listing ", $bo->size, ":\n"; |
| 55 |
|
| printf($fmt, "application_number", "status", "applicant", "trademark_text"); |
| 56 |
|
| print "-" x 120, "\n"; |
| 57 |
|
| foreach my $e (@{$bo->data}) { |
| 58 |
|
| |
| 59 |
|
| my $appl = $e->applicant; |
| 60 |
|
| my $alen = length($appl); |
| 61 |
|
| if ($alen > 30) { |
| 62 |
|
| $appl = substr($appl, 0, 30) . ".."; |
| 63 |
|
| } |
| 64 |
|
| printf($fmt, |
| 65 |
|
| $e->application_number, |
| 66 |
|
| encode('UTF-8', $e->status), |
| 67 |
|
| encode('UTF-8', $appl), |
| 68 |
|
| encode('UTF-8', $e->trademark_text)); |
| 69 |
|
| } |
| 70 |
|
| |
| 71 |
|
| } elsif ($bo->size == 1 && $opt_o) { |
| 72 |
|
| # One entry on the data array |
| 73 |
|
| print "Single matching entry:\n"; |
| 74 |
|
| foreach my $e (@{$bo->data}) { |
| 75 |
|
| print |
| 76 |
|
| encode('UTF-8', $e->status ), "\t", |
| 77 |
|
| encode('UTF-8', $e->applicant ), "\t", |
| 78 |
|
| $e->application_number, "\t", |
| 79 |
|
| $e->filed_date, "\t", |
| 80 |
|
| $e->last_updated, "\t", |
| 81 |
|
| encode('UTF-8', $e->trademark_text), "\n"; |
| 82 |
|
| } |
| 83 |
|
| |
| 84 |
|
| } |
| 85 |
|
| |
| 86 |
|
| } |
| 87 |
|
| |
| 88 |
|
| if ($opt_v) { |
| 89 |
|
| print "\n--\nJSON data structure: ", |
| 90 |
|
| Dumper($bo->raw_json_decoded), "\n--\n"; |
| 91 |
|
| |
| 92 |
|
| } |
| 93 |
|
| |
| 94 |
|
| print STDERR "Debug bo: ", Dumper($bo), "\n--\n" if ($opt_d && $opt_d > 1); |
| 95 |
|
| |
| 96 |
|
| |
| 97 |
|
| =pod |
| 98 |
|
| |
| 99 |
|
| =head1 NAME |
| 100 |
|
| |
| 101 |
|
| no_patent.pl |
| 102 |
|
| |
| 103 |
|
| =head1 DESCRIPTION |
| 104 |
|
| |
| 105 |
|
| Uses NOLookup::Patent::DataLookup to perform lookup on an |
| 106 |
|
| a brand name and fetch and print the matching information. |
| 107 |
|
| |
| 108 |
|
| The data found are stored as NOLookup::Patent::Entry data objects. |
| 109 |
|
| |
| 110 |
|
| =head1 USAGE |
| 111 |
|
| |
| 112 |
|
| no_patent.pl -n solo |
| 113 |
|
| |
| 114 |
|
| no_patent.pl -o 199901548 |
| 115 |
|
| |
| 116 |
|
| For -o: successful output is a one single entry. |
| 117 |
|
| |
| 118 |
|
| For -n: successful output is a list name of the matching trademarks. |
| 119 |
|
| |
| 120 |
|
| Arguments: |
| 121 |
|
| |
| 122 |
|
| -n: trademark text (complete or part of registered tm text) |
| 123 |
|
| |
| 124 |
|
| When -n is specifed, also: |
| 125 |
|
| -p: page number (1..x), max. number of pages |
| 126 |
|
| -c: page count, number of entries per page (1..x, default 100). |
| 127 |
|
| -i: page index (1..x), which page to start on |
| 128 |
|
| |
| 129 |
|
| -o: application id (found from a -n operation) |
| 130 |
|
| |
| 131 |
|
| -d: debug: 1 or higher for increased debug level |
| 132 |
|
| -v: verbose dump of the complete JSON data structure |
| 133 |
|
| |
| 134 |
|
| =cut |
| 135 |
|
| |
| 136 |
|
| 1; |
| 137 |
|
| |
| 138 |
|
| |