(* General settings - without performing subroutines *) (* Previously saved definitions *) filedump = "F:\\temp\\html.mx"; Print["Getting various data for pictures from saved session of maintain/structured/maint.nb from the file ", filedump, " ..."]; timedump = NumberForm[Timing[Get[filedump]][[1]], {5, 1}]; Print[" --- Data were read in ", timedump, " second."]; ClearAll[accNamesPic, nameOnPic]; (* remove previously saved definitions *) diskphp = "C"; (* php, lynx, ... *) diskhtml = "F"; diskc = "E"; (* sergeev and temp directories *) diskf = "F"; (* log files *) diskfile[disk_String, file_String] := FileNameJoin[{disk <> ":", file}]; dir00 = diskfile[diskhtml, "html"]; dir0 = dirmushrooms = ToFileName[{dir00, "pictures", "tmushrooms"}]; dirtemp = diskfile[diskc, "temp"]; dirwork = dirwork0 = diskfile[diskc, "sergeev\\tamu\\html\\tmushrooms"]; dirdata= FileNameJoin[{dirwork, "data"}]; filedump = FileNameJoin[{dirtemp, "tmushrooms-web.mx"}]; htmldomain = "www.texasmushrooms.org"; (* could change *) apikey ="AIzaSyC_URruirXwk_QqHyZP57b51VxpJRzqfhc"; (* https://console.developers.google.com/apis/credentials/key/157?project=my-project-1486416305745&pli=1 *) yearsTexas = Range[2007, 2099]; matchName1 = RegularExpression["[A-Z][a-z]{2,50}"]; matchName2a = RegularExpression["[A-Z][a-z]{2,50} [a-z]{3,50}"]; matchName2b = RegularExpression["[A-Z][a-z]{2,50} [a-z]{3,50}[-][a-z]{3,50}"]; matchName2 = RegularExpression["([A-Z][a-z]{2,50} [a-z]{3,50}|[A-Z][a-z]{2,50} [a-z]{3,50}[-][a-z]{3,50})"]; matchName = RegularExpression["([A-Z][a-z]{2,50}|[A-Z][a-z]{2,50} [a-z]{3,50}|[A-Z][a-z]{2,50} [a-z]{3,50}[-][a-z]{3,50})"]; matchFungus = {"mushroom", "mushrooms", "fungus", "fungi", "fungal"}; matchSlime = {"slime mold", "slime molds"}; matchLichen = {"lichen", "lichens", "cyanolichen", "cyanolichens"}; matchMushrooms = {matchFungus, matchSlime, matchLichen}//Flatten; longdash = FromCharacterCode[8211]; yearSearchMin = 2010; yearSearch = 2019; failedAttempts[year_] := 0; failedAttemptsM = 5; dirSearch = FileNameJoin[{dirwork, "data", "search", "gbif"}]; dirIds = FileNameJoin[{dirwork, "data", "ids", "gbif"}]; (* Reading packages *) filefunc = ToFileName[dirwork, "functions.m"]; If[FileType[filefunc] =!= File, Print["Fatal Error: no file ", filefunc, " Exiting ..."]; Exit[]]; Get[filefunc]; checkdir /@ {dirtemp, dirwork, dirdata}; checkdir1[dir0]; (* Reading sub-programs *) SetDirectory[dirwork]; subprogs = FileNames["maintain-*.m"]; (* subprogs = Join[subprogs, {"replnames.m"}]; *) subnames = progname /@ subprogs; Print["Getting sub-programs: ", Transpose[{subprogs, subnames}] // TableForm]; (* Get /@ subprogs; *) (* Binary format *) ToExpression[(Print["Getting program ", #, "... "]; Import[#, "Text"])] & /@ subprogs; (* Beginning operations *) maintainInit; (* Reading list of mushroom names from MO web site *) maintainReadMO; (* Reading names to be added or removed from MO names list *) maintainReadAdd; (* Selecting pictures taken in Texas *) maintainSelectTexas; (* Trimming list of names *) maintainListTrim; (* Checking wrong names and pictures without names *) maintainCheckNames; (* Search IDs for a given name and select the most likely ID - from catalogueoflife.org *) (* Do[Print["Reading search data for the year: ", year]; Do[maintainDataSearch[name, year], {name, namesList2}], {year, yearSearchMin, yearSearch}]; *) (* Search IDs for a given name and select the most likely ID - from https://www.gbif.org *) Print["----- Searching species from https://www.gbif.org"]; nYear = "bgif"; failedAttempts[nYear] = 0; nameKey[name_] := 0; Do[maintainDataAdded[name]; maintainSearchGbif[name]; maintainKeyGbif[name]; key = nameKey[name]; If[key =!= 0, maintainDataGbif[key]; If[keyData[key, "synonym"], key1 = keyData[key, "acceptedKey"]; If[IntegerQ[key1], maintainDataGbif[key1]; namesci1 = keyData[key1, "scientificName"]; name1 = shortName[namesci1]; If[name1 =!= "", maintainSearchGbif[name1]; maintainKeyGbif[name1]; maintainDataGbif[key1];]; Print[name, " -> ", namesci1]; ]]; ], {name, namesList2}]; (* Checking synonyms *) maintainCheckSynonyms; (* Montage of pictures for each mushroom *) maintainMontageNames; (* Sorting names *) maintainSort; (* Data from inaturalist.org *) maintainInaturalist; (* Generate listing of common names from data for added names *) maintainCnamesAdded; (* Common names *) maintainCommonNames; (* Organize collection subsets by dates *) maintainSubsets; (* Main index file *) maintainIndex; (* Creating geo files *.kml for each mushroom *) maintainKML; (* Get Wikipedia articles *) maintainWiki; (* Weather data *) maintainWeather; (* Index file sorted by full classification line *) maintainIndexf; (* Alphabetical list *) maintainIndexa; (* List of English names *) maintainIndexEn; (* Web page for each mushroom species *) maintainSpecies; (* Group pictures by dates *) maintainDates; (* Checking possible missing names *) maintainCheckMissed; (* Redirecting obsolete name to a new name *) maintainRedirect; (* Save list of mushrooms and list of pictures with mushrooms to a file to show links on web pages *) maintainSaveLists; (* Saving a list of mushrooms in a history folder *) maintainHistory; (* Creating sitemap for Google *) maintainSitemap; (* Saving session - for possible debugging *) maintainDumpsave;