source cgi/mirrorfind-.tcl ;# Load source utilities1.tcl ;# Store if 0 { source ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/readMe.tcl } if 0 { # affiliation1 was created from: http://bibdigital.sid.inpe.br/col/dpi.inpe.br/banon-pc2@1905/2006/02.16.12.09/doc/script.cgi?query=y+2015|2019+and+(firstg+*CPT+or+firstg+*OBT+or+firstg+*CST)+and+af+*&fieldlist=affiliation&frequencyformat=yes } Load ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/affiliation1 affiliation1 Load ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/affiliation2 affiliation2 set affiliation1List {} foreach line [split $affiliation1 \n] { lappend affiliation1List $line } llength $affiliation1List # => 2050 set affiliation2List {} ;# Google english translation foreach line [split $affiliation2 \n] { lappend affiliation2List $line } llength $affiliation2List # => 2050 lrange $affiliation1List 0 2 # => {5726 Instituto Nacional de Pesquisas Espaciais (INPE)} {2396 } { 382 Universidade de São Paulo (USP)} # set affiliationList {} set affiliationXtypeList {} for {set i 0} {$i <= [expr [llength $affiliation1List] - 1]} {incr i} { set af1 [regsub -all { \& } [lrange [lindex $affiliation1List $i] 1 end] {\&}] set af2 [regsub -all { / } [lrange [lindex $affiliation2List $i] 1 end] {/}] set af2 [regsub -all { \& } $af2 {\&}] set af2 [regsub -all { – } $af2 {–}] if {([string equal $af1 $af2] || [regexp -nocase {Centre|Modelling|Programme| d?el [^R]| y |Boliviano|Venezolano|Venezuela|Royal|Bolivia|Universidad |Consiglio|GCP|Malaysia|Ecuador|France|Peru|Texas|Spain|Climatici|Comisión|Finland|England|Catalana|Laboratoire|Météo|China|PLOCAN|Netherlands|Tropenbos|Scotland|INRA|INRA|Lincoln|Virginia|Wisconsin|Università} $af1]) && ![regexp -nocase {Universidade Federal|Brazil|Museu |FATEC|SIMEPAR|EMBRAPA|Bradar|Imazon|ADAMI|Climatempo|Ltda|SIPAM|COPEL|EPAGRI|ETEC|ITAIPU|UNIP|Vale S. ?A.|CEMADEN|Capixaba|CENA|Santarem|Fibria|São Paulo|Geopixel|Campinas|Mamirauá|Petrobras|SAMARCO|Uberlândia|^usp$} $af2]} { # international # lappend affiliationList [list $af1 international] lappend affiliationXtypeList $af1 international } else { # national # lappend affiliationList [list $af1 national] lappend affiliationXtypeList $af1 national } } # llength $affiliationList ## => 2050 # llength [set affiliationXtype [join $affiliationList \n]] # Store affiliationXtype ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/affiliationXtype array set affiliationXtypeArray $affiliationXtypeList set {affiliationXtypeArray(Instituto Nacional de Pesquisas Espaciais (INPE))} inpe # unset affiliationXtypeArray() if 0 { # y 2015|2019 and (firstg *CPT or firstg *OBT or firstg *CST) and af * # => 2510 # repGroupAffiliationData was created by copying all the lines from: http://bibdigital.sid.inpe.br/col/dpi.inpe.br/banon-pc2@1905/2006/02.16.12.09/doc/script.cgi?query=y+2015|2019+and+(firstg+*CPT+or+firstg+*OBT+or+firstg+*CST)+and+af+*&fieldlist=repository+group+affiliation } Load ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/repGroupAffiliationData repGroupAffiliationData if [info exists repXgroupAffiliationArray] {unset repXgroupAffiliationArray} # CPT firstgroup set CPTfirstXobtCounter 0 set CPTfirstXobtList {} lappend CPTfirstXobtList {} lappend CPTfirstXobtList {
}
lappend CPTfirstXobtList {O primeiro autor INPE é do CPTEC e pelo menos um dos outros autores é da OBT}
lappend CPTfirstXobtList {}

set CPTfirstXcstCounter 0
set CPTfirstXcstList {}
lappend CPTfirstXcstList {}
lappend CPTfirstXcstList {
}
lappend CPTfirstXcstList {O primeiro autor INPE é do CPTEC e pelo menos um dos outros autores é do CST}
lappend CPTfirstXcstList {}

set CPTfirstXnationalCounter 0
set CPTfirstXnationalList {}
lappend CPTfirstXnationalList {}
lappend CPTfirstXnationalList {
}
lappend CPTfirstXnationalList {O primeiro autor INPE é do CPTEC e pelo menos um dos outros autores é do Brasil sem ser do INPE}
lappend CPTfirstXnationalList {}

set CPTfirstXinternationalCounter 0
set CPTfirstXinternationalList {}
lappend CPTfirstXinternationalList {}
lappend CPTfirstXinternationalList {
}
lappend CPTfirstXinternationalList {O primeiro autor INPE é do CPTEC e pelo menos um dos outros autores é do Exterior}
lappend CPTfirstXinternationalList {}

# OBT firstgroup
set OBTfirstXcptCounter 0
set OBTfirstXcptList {}
lappend OBTfirstXcptList {}
lappend OBTfirstXcptList {
}
lappend OBTfirstXcptList {O primeiro autor INPE é da OBT e pelo menos um dos outros autores é do CPTEC}
lappend OBTfirstXcptList {}

set OBTfirstXcstCounter 0
set OBTfirstXcstList {}
lappend OBTfirstXcstList {}
lappend OBTfirstXcstList {
}
lappend OBTfirstXcstList {O primeiro autor INPE é da OBT e pelo menos um dos outros autores é do CST}
lappend OBTfirstXcstList {}

set OBTfirstXnationalCounter 0
set OBTfirstXnationalList {}
lappend OBTfirstXnationalList {}
lappend OBTfirstXnationalList {
}
lappend OBTfirstXnationalList {O primeiro autor INPE é da OBT e pelo menos um dos outros autores é do Brasil sem ser do INPE}
lappend OBTfirstXnationalList {}

set OBTfirstXinternationalCounter 0
set OBTfirstXinternationalList {}
lappend OBTfirstXinternationalList {}
lappend OBTfirstXinternationalList {
}
lappend OBTfirstXinternationalList {O primeiro autor INPE é da OBT e pelo menos um dos outros autores é do Exterior}
lappend OBTfirstXinternationalList {}

# CST firstgroup
set CSTfirstXcptCounter 0
set CSTfirstXcptList {}
lappend CSTfirstXcptList {}
lappend CSTfirstXcptList {
}
lappend CSTfirstXcptList {O primeiro autor INPE é do CST e pelo menos um dos outros autores é do CPT}
lappend CSTfirstXcptList {}

set CSTfirstXobtCounter 0
set CSTfirstXobtList {}
lappend CSTfirstXobtList {}
lappend CSTfirstXobtList {
}
lappend CSTfirstXobtList {O primeiro autor INPE é do CST e pelo menos um dos outros autores é da OBT}
lappend CSTfirstXobtList {}

set CSTfirstXnationalCounter 0
set CSTfirstXnationalList {}
lappend CSTfirstXnationalList {}
lappend CSTfirstXnationalList {
}
lappend CSTfirstXnationalList {O primeiro autor INPE é do CST e pelo menos um dos outros autores é do Brasil sem ser do INPE}
lappend CSTfirstXnationalList {}

set CSTfirstXinternationalCounter 0
set CSTfirstXinternationalList {}
lappend CSTfirstXinternationalList {}
lappend CSTfirstXinternationalList {
}
lappend CSTfirstXinternationalList {O primeiro autor INPE é do CST e pelo menos um dos outros autores é do Exterior}
lappend CSTfirstXinternationalList {}

# national
set nationalXcptCounter 0
set nationalXcptList {}
lappend nationalXcptList {}
lappend nationalXcptList {
}
lappend nationalXcptList {O primeiro autor não é do INPE mas é do Brasil e pelo menos um dos outros autores é do CPETEC}
lappend nationalXcptList {}

set nationalXobtCounter 0
set nationalXobtList {}
lappend nationalXobtList {}
lappend nationalXobtList {
}
lappend nationalXobtList {O primeiro autor não é do INPE mas é do Brasil e pelo menos um dos outros autores é da OBT}
lappend nationalXobtList {}

set nationalXcstCounter 0
set nationalXcstList {}
lappend nationalXcstList {}
lappend nationalXcstList {
}
lappend nationalXcstList {O primeiro autor não é do INPE mas é do Brasil e pelo menos um dos outros autores é do CST}
lappend nationalXcstList {}

# international
set internationalXcptCounter 0
set internationalXcptList {}
lappend internationalXcptList {}
lappend internationalXcptList {
}
lappend internationalXcptList {O primeiro autor é do Exterior e pelo menos um dos outros autores é do CPETEC}
lappend internationalXcptList {}

set internationalXobtCounter 0
set internationalXobtList {}
lappend internationalXobtList {}
lappend internationalXobtList {
}
lappend internationalXobtList {O primeiro autor é do Exterior e pelo menos um dos outros autores é da OBT}
lappend internationalXobtList {}

set internationalXcstCounter 0
set internationalXcstList {}
lappend internationalXcstList {}
lappend internationalXcstList {
}
lappend internationalXcstList {O primeiro autor é do Exterior e pelo menos um dos outros autores é do CST}
lappend internationalXcstList {}

set repGroupAffiliationList [split $repGroupAffiliationData \n]
llength $repGroupAffiliationList
# => 2510

# foreach line [lrange [split $repGroupAffiliationData \n] 0 2] #	;# for testing
foreach line $repGroupAffiliationList {
	foreach {rep group affiliation} [split $line \t] {break}
	
	set groupList [split $group {;}]
	set groupList2 {}
	foreach gr $groupList {
		set gr2 [string trim $gr]
		if [string equal {} $gr2] {continue}
		lappend groupList2 $gr2
	}
	
	set affiliationList [split $affiliation {;}]
	set affiliationList2 {}
	foreach af $affiliationList {
		set af2 [string trim $af]
		if [string equal {} $af2] {continue}
		set af2 [regsub -all { \& } $af2 {\&}]
		set af2 [regsub -all {\s+} $af2 { }]
		lappend affiliationList2 $affiliationXtypeArray($af2)
	}
	
#	set repXgroupAffiliationArray($rep) [list $groupList2 $affiliationList2]
	
	if {[regexp {CPT} [lindex $groupList2 0]]} {
# CPT firstgroup
		foreach gr [lrange $groupList2 1 end] {
			if [regexp {OBT} $gr] {
# obt
				incr CPTfirstXobtCounter
				set url "$rep"
				lappend CPTfirstXobtList "$url [list $group]"
				break
			}
		}
		foreach gr [lrange $groupList2 1 end] {
			if [regexp {CST} $gr] {
# cst
				incr CPTfirstXcstCounter
				set url "$rep"
				lappend CPTfirstXcstList "$url [list $group]"
				break
			}
		}
		foreach afType $affiliationList2 {
			if [string equal national $afType] {
# national
				incr CPTfirstXnationalCounter
				set url "$rep"
				lappend CPTfirstXnationalList "$url [list $group $affiliation]"
				break
			}
		}			
		foreach afType $affiliationList2 {
			if [string equal international $afType] {
# international
				incr CPTfirstXinternationalCounter
				set url "$rep"
				lappend CPTfirstXinternationalList "$url [list $group $affiliation]"
				break
			}
		}
	}
			
	if {[regexp {OBT} [lindex $groupList2 0]]} {
# OBT firstgroup
		foreach gr [lrange $groupList2 1 end] {
			if [regexp {CPT} $gr] {
# cpt
				incr OBTfirstXcptCounter
				set url "$rep"
				lappend OBTfirstXcptList "$url [list $group]"
				break
			}
		}
		foreach gr [lrange $groupList2 1 end] {
			if [regexp {CST} $gr] {
# cst
				incr OBTfirstXcstCounter
				set url "$rep"
				lappend OBTfirstXcstList "$url [list $group]"
				break
			}
		}
		foreach afType $affiliationList2 {
			if [string equal national $afType] {
# national
				incr OBTfirstXnationalCounter
				lappend OBTfirstXnationalList [list $rep $group $affiliation]
				break
			}
		}			
		foreach afType $affiliationList2 {
			if [string equal international $afType] {
# international
				incr OBTfirstXinternationalCounter
				lappend OBTfirstXinternationalList [list $rep $group $affiliation]
				break
			}
		}
	}
		
	if {[regexp {CST} [lindex $groupList2 0]]} {
# CST firstgroup
		foreach gr [lrange $groupList2 1 end] {
			if [regexp {CPT} $gr] {
# cpt
				incr CSTfirstXcptCounter
				set url "$rep"
				lappend CSTfirstXcptList "$url [list $group]"
				break
			}
		}
		foreach gr [lrange $groupList2 1 end] {
			if [regexp {OBT} $gr] {
# obt
				incr CSTfirstXobtCounter
				set url "$rep"
				lappend CSTfirstXobtList "$url [list $group]"
				break
			}
		}
		foreach afType $affiliationList2 {
			if [string equal national $afType] {
# national
				incr CSTfirstXnationalCounter
				set url "$rep"
				lappend CSTfirstXnationalList "$url [list $group $affiliation]"
				break
			}
		}			
		foreach afType $affiliationList2 {
			if [string equal international $afType] {
# international
				incr CSTfirstXinternationalCounter
				set url "$rep"
				lappend CSTfirstXinternationalList "$url [list $group $affiliation]"
				break
			}
		}
	}

	if {[regexp {national} [lindex $$affiliationList2 0]]} {
# national
		foreach gr $groupList2 {
			if [regexp {CPT} $gr] {
# cpt
				incr nationalXcptCounter
				set url "$rep"
				lappend nationalXcptList "$url [list $group $affiliation]"
				break
			}
		}
		foreach gr $groupList2 {
			if [regexp {OBT} $gr] {
# obt
				incr nationalXobtCounter
				set url "$rep"
				lappend nationalXobtList "$url [list $group $affiliation]"
				break
			}
		}
		foreach gr $groupList2 {
			if [regexp {CST} $gr] {
# cst
				incr nationalXcstCounter
				set url "$rep"
				lappend nationalXcstList "$url [list $group $affiliation]"
				break
			}
		}
	}
			
	if {[regexp {international} [lindex $$affiliationList2 0]]} {
# international
		foreach gr $groupList2 {
			if [regexp {CPT} $gr] {
# cpt
				incr internationalXcptCounter
				set url "$rep"
				lappend internationalXcptList "$url [list $group $affiliation]"
				break
			}
		}
		foreach gr $groupList2 {
			if [regexp {OBT} $gr] {
# obt
				incr internationalXobtCounter
				set url "$rep"
				lappend internationalXobtList "$url [list $group $affiliation]"
				break
			}
		}
		foreach gr $groupList2 {
			if [regexp {CST} $gr] {
# cst
				incr internationalXcstCounter
				set url "$rep"
				lappend internationalXcstList "$url [list $group $affiliation]"
				break
			}
		}
	}

}

# CPT firstgroup
# puts $CPTfirstXobtCounter
Store CPTfirstXobtCounter ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/CPTfirstXobtCounter.txt
lappend CPTfirstXobtlList {
} set CPTfirstXobt [join $CPTfirstXobtList \n] Store CPTfirstXobt ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/CPTfirstXobt.html # puts $CPTfirstXcstCounter Store CPTfirstXcstCounter ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/CPTfirstXcstCounter.txt lappend CPTfirstXcstlList {
} set CPTfirstXcst [join $CPTfirstXcstList \n] Store CPTfirstXcst ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/CPTfirstXcst.html # puts $CPTfirstXnationalCounter Store CPTfirstXnationalCounter ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/CPTfirstXnationalCounter.txt lappend CPTfirstXnationalList {
} set CPTfirstXnational [join $CPTfirstXnationalList \n] Store CPTfirstXnational ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/CPTfirstXnational.html # puts $CPTfirstXinternationalCounter Store CPTfirstXinternationalCounter ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/CPTfirstXinternationalCounter.txt lappend CPTfirstXinternationalList {
} set CPTfirstXinternational [join $CPTfirstXinternationalList \n] Store CPTfirstXinternational ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/CPTfirstXinternational.html # OBT firstgroup # puts $OBTfirstXcptCounter Store OBTfirstXcptCounter ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/OBTfirstXcptCounter.txt lappend OBTfirstXcptlList {
} set OBTfirstXcpt [join $OBTfirstXcptList \n] Store OBTfirstXcpt ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/OBTfirstXcpt.html # puts $OBTfirstXcstCounter Store OBTfirstXcstCounter ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/OBTfirstXcstCounter.txt lappend OBTfirstXcstlList {
} set OBTfirstXcst [join $OBTfirstXcstList \n] Store OBTfirstXcst ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/OBTfirstXcst.html # puts $OBTfirstXnationalCounter Store OBTfirstXnationalCounter ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/OBTfirstXnationalCounter.txt lappend OBTfirstXnationalList {
} set OBTfirstXnational [join $OBTfirstXnationalList \n] Store OBTfirstXnational ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/OBTfirstXnational.html # puts $OBTfirstXinternationalCounter Store OBTfirstXinternationalCounter ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/OBTfirstXinternationalCounter.txt lappend OBTfirstXinternationalList {
} set OBTfirstXinternational [join $OBTfirstXinternationalList \n] Store OBTfirstXinternational ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/OBTfirstXinternational.html # CST firstgroup # puts $CSTfirstXcptCounter Store CSTfirstXcptCounter ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/CSTfirstXcptCounter.txt lappend CSTfirstXcptlList {
} set CSTfirstXcpt [join $CSTfirstXcptList \n] Store CSTfirstXcpt ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/CSTfirstXcpt.html # puts $CSTfirstXobtCounter Store CSTfirstXobtCounter ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/CSTfirstXobtCounter.txt lappend CSTfirstXobtlList {
} set CSTfirstXobt [join $CSTfirstXobtList \n] Store CSTfirstXobt ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/CSTfirstXobt.html # puts $CSTfirstXnationalCounter Store CSTfirstXnationalCounter ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/CSTfirstXnationalCounter.txt lappend CSTfirstXnationalList {
} set CSTfirstXnational [join $CSTfirstXnationalList \n] Store CSTfirstXnational ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/CSTfirstXnational.html # puts $CSTfirstXinternationalCounter Store CSTfirstXinternationalCounter ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/CSTfirstXinternationalCounter.txt lappend CSTfirstXinternationalList {
} set CSTfirstXinternational [join $CSTfirstXinternationalList \n] Store CSTfirstXinternational ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/CSTfirstXinternational.html # national # puts $nationalXcptCounter Store nationalXcptCounter ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/nationalXcptCounter.txt lappend nationalXcptlList {
} set nationalXcpt [join $nationalXcptList \n] Store nationalXcpt ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/nationalXcpt.html # puts $nationalXobtCounter Store nationalXobtCounter ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/nationalXobtCounter.txt lappend nationalXobtlList {
} set nationalXobt [join $nationalXobtList \n] Store nationalXobt ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/nationalXobt.html # puts $nationalXcstCounter Store nationalXcstCounter ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/nationalXcstCounter.txt lappend nationalXcstlList {
} set nationalXcst [join $nationalXcstList \n] Store nationalXcst ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/nationalXcst.html # international # puts $internationalXcptCounter Store internationalXcptCounter ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/internationalXcptCounter.txt lappend internationalXcptlList {
} set internationalXcpt [join $internationalXcptList \n] Store internationalXcpt ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/internationalXcpt.html # puts $internationalXobtCounter Store internationalXobtCounter ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/internationalXobtCounter.txt lappend internationalXobtlList {
} set internationalXobt [join $internationalXobtList \n] Store internationalXobt ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/internationalXobt.html # puts $internationalXcstCounter Store internationalXcstCounter ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/internationalXcstCounter.txt lappend internationalXcstlList {
} set internationalXcst [join $internationalXcstList \n] Store internationalXcst ../../../../../sid.inpe.br/bibdigital/2020/03.07.15.09/doc/internationalXcst.html puts done if 0 { # workList file was created by copying all the lines from: http://www.urlib.net/col/dpi.inpe.br/banon/2004/02.16.09.30.00/doc/mirrorsearch.cgi?query=y+2015|2019+and+(firstg+*CPT+or+firstg+*OBT+or+firstg+*CST)+and+af+*&choice=full&continue=yes } if 0 { array names repXgroupAffiliationArray array get repXgroupAffiliationArray }