#!/usr/bin/perl -w # # Copyright (c) 2002-2007 Erik Oliver # # $Id: claim.cgi,v 1.9 2007/06/02 $ # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation # files (the "Software"), to deal in the Software without # restriction, including without limitation the rights to use, copy, # modify, merge, publish, distribute, sublicense, and/or sell copies # of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. use strict; use vars qw/$q/; use CGI; use CGI::Carp qw(fatalsToBrowser); use ETree; $q = new CGI; print $q->header(); print q| Claim Trees and Number Checking
Erik's Web Web Based Patent Polishing Tools Claim Number Checking
|; if ($q->param('polish') && $q->param('polish') ne "") { &doTree(); } else { &printForm(); } print q|

This program is made available in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$Id: claim.cgi,v 1.9 2006/06/02 $

|; # # # end of main flow sub printForm() { print $q->start_form(),"\n"; print "
\n"; print "\n"; print "

Paste claims into box below

\n"; print $q->textarea(-name=>'polish',-rows=>10,-columns=>60); print "
\n"; print $q->submit(-label=>'Make Tree'); print "
"; print "
\n"; print $q->end_form(); } sub mytreeadd($$$) { my $root = shift; my $parent = shift; my $claim = shift; my $new_daughter = new SimpleTree $claim; my $ptr; if($parent == 0 || $root->GetLabel() eq $parent) { AddChildrenRight $root $new_daughter; } else { foreach $ptr (GetChildren $root) { mytreeadd($ptr,$parent,$claim); } } return; } sub doTree() { my $contents = $q->param('polish'); my $error = ""; # some simple cleanups $contents =~ s/\t/ /g; # build a hash of claim numbers first: my %claims; my $root = new SimpleTree "Root"; my @dependstack; while($contents =~ m/(\d+).*\W(A|An|The)(\W.*)/g) { my ($claim, $type, $body) = ($1,$2,$3); if(exists($claims{$claim})) { $error .= "error duplicate claim # $claim
\n" ; next; } $claims{$claim} = $type . $body; #print "Depend stack: ", join(" - ",@dependstack), "
\n"; # try to find bad depend if (($type eq "A" || $type eq "An") && $body =~ m/[Cc]laim (\d+)/) { $error .= "error claim # $claim starts with \"A\" but refers to a parent claim, claim # $1; treating as depend
\n"; $type = "The"; } if ($type eq "A" || $type eq "An") { # independent claim mytreeadd($root,0,$claim); while(@dependstack) {shift @dependstack; } unshift @dependstack, $claim; } else { $body =~ m/[Cc]laim (\d+)/; my $parent = $1; # basic errors - later claim ref; nonexist earlier claim ref if ($parent >= $claim) { $error .= "error claim # $claim depends on later claim, $parent
\n"; } elsif (!exists($claims{$parent}) ) { $error .= "error claim # $claim refers to nonexistent claim, $parent
\n"; } # subtle errors MPEP ordering violation # 1: $parent (parent) must be in dependstack my $found = 0; my $index = 0; for(;$index<@dependstack;$index++) { $found++ if($dependstack[$index] == $parent); } if(!$found) { # case 1: unlikely earlier claim if($parent < $claim) { $error .= "error claim # $claim refers to claim $parent, out of order
\n"; mytreeadd($root,$parent,$claim); } else { $error .= "error claim # $claim refers to claim $parent, out of order; cannot handle forward references changed to refer to claim $dependstack[0]
\n"; mytreeadd($root,$dependstack[0],$claim); } next; } # 2: try to pop stack elements if ($parent < $dependstack[0]) {while($parent < $dependstack[0]) {shift @dependstack;}} # push current claim onto stack unshift @dependstack, $claim; mytreeadd($root,$parent,$claim); } } my $key; my $ptr; print "

Error List
\n"; if($error eq "") { print "No claim numbering errors found.

\n"; } else { print "$error

\n"; } print "

Claim Trees

\n"; foreach $ptr (GetChildren $root) { $key = $ptr->GetLabel(); print "

Ind Claim #$key
$claims{$key}\n"; print "

",map("$_\n",@{$ptr->PrintTree}),"
\n"; print "


\n"; } }