(* Checking wrong names and pictures without names *) maintainCheckNames := Module[{n1, n2, y, r, p, cap, names, yrp, link, ystart, pics, time1, time2}, Print["----- Selecting pictures that mention the names and pictures that show mushrooms ..."]; namesListBlank = (" " <> # <> " ") & /@ namesList; matchMushroomsBlank = (" " <> # <> " ") & /@ matchMushrooms; time1 = Timing[ picsNames = Select[picsTexas, (!StringFreeQ[" " <> picCaptionW @@ # <> " ", namesListBlank]) &]; namesPic[r_String, p_String] := {}; Do[ {r, p} = pic; cap = " " <> picCaptionW[r, p] <> " "; names = StringCases[cap, namesListBlank, Overlaps -> All]; names = StringTrim /@ names; names = Union[names]; namesPic[r, p] = names, {pic, picsNames}]; ][[1]]; Print["Selected ", Length[picsNames], " pictures that mention names from the list in ", time1, " second."]; time2 = Timing[ picsMushrooms = Select[picsTexas, (!StringFreeQ[" " <> StringReplace[picCaptionW @@ #, "-" -> " "] <> " ", matchMushroomsBlank, IgnoreCase -> True]) &]; mushroomsPic[r_String, p_String] := {}; Do[ {r, p} = pic; cap = " " <> picCaptionW[r, p] <> " "; cap = StringReplace[cap, "-" -> " "]; names = StringCases[cap, matchMushroomsBlank, IgnoreCase -> True]; names = StringTrim /@ names; names = ToLowerCase /@ names; names = Union[names]; mushroomsPic[r, p] = names, {pic, picsMushrooms}]; ][[1]]; Print["Selected ", Length[picsMushrooms], " pictures with some mushrooms in ", time2, " second."]; (* Checking pictures that have names from the list, but don't show mushrooms *) picsNames1 = Complement[picsNames, picsMushrooms]; n1 = Length[picsNames1]; If[n1 > 0, Print["Warning: there are ", n1, " pictures that mention names from the list but not of a mushroom."]; Print[" - Following names (in the middle column) should be added to file ", fileRemove, ": "]; table = Table[ {r, p} = pic; y = toyear[r]; cap = picCaption[r, p]; names = namesPic[r, p]; yrp = y <> "/" <> r <> "/" <> p; link = Hyperlink[yrp, "http://127.0.0.1:81/pictures/archives/compress/" <> yrp <> ".htm"]; {link, names, cap}, {pic, picsNames1}]; Print[table // TableForm]; ]; (* Checking pictures without names *) ystart = If[NumberQ[yStart], Max[yStart, firstyear // ToExpression], lastyear // ToExpression]; picsMushrooms1 = Complement[picsMushrooms, picsNames]; n1 = Length[picsMushrooms1]; If[n1 > 0, Print["Warning: there are ", n1, " pictures that show a mushroom but don't mention the names."]; pics = Select[ picsMushrooms1, (ToExpression[toyear[First[#]]] >= ystart) &]; n2 = Length[pics]; If[n2 < n1, Print["Warning: showing partial list of ", n2, " pictures (year >= ", ystart, ") without names. To show full list, define yStart <= ", firstyear, " in the main program."]]; table = Table[ {r, p} = pic; y = toyear[r]; cap = picCaption[r, p]; names = mushroomsPic[r, p]; yrp = y <> "/" <> r <> "/" <> p; link = Hyperlink[yrp, "http://127.0.0.1:81/pictures/archives/compress/" <> yrp <> ".htm"]; {link, names, cap}, {pic, pics}]; Print[table // TableForm]; ]; picsList = Union[picsNames, picsMushrooms]; picsList = Sort[picsList, OrderedQ[ToExpression /@ {#1, #2}] &]; Print[Length[picsList], " pictures describe some sort of mushrooms."]; ];