Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uppertaxon = 1353804;
- MapMonitor[
- (item = GetItem[#];
- claims = GetParam[item, "claims"];
- label =
- SortBy[Tally["value" /. (Last /@ GetParam[item, "labels"])],
- Last][[-1, 1]];
- Print["Обрабатываю ", #, " [[" <> label <> "]]"];
- summary = "Setting ";
- editclaims = editlabels = editdescs = {};
- If[GetParam[claims, {"P31", "numeric-id"}] === 16521,
- Print["Already contains [[P:Is a]]=[[taxon]]. Do nothing"],
- AppendTo[editclaims, FormatCreateClaim[31, "item", 16521]];
- Print["Setting [[P:Is a]]=[[taxon]]..."];
- summary = summary <> "[[Property:P31]]=[[Q16521]], "];
- If[! FreeQ[
- GetParam[#, "numeric-id"] & /@ GetParam[claims, {"P105"}],
- 7432],
- Print[
- "Already contains [[P:taxonomic rank]]=[[species]]. Do nothing"],
- AppendTo[editclaims, FormatCreateClaim[105, "item", 7432]];
- Print["Setting [[P:taxonomic rank]]=[[species]]..."];
- summary = summary <> "[[Property:P105]]=[[Q7432]], "];
- If[(GetParam[#, "value"] & /@ GetParam[claims, {"P225"}]) === {},
- AppendTo[editclaims, FormatCreateClaim[225, "string", label]];
- Print["Setting [[P:Latin name]]=[[" <> label <> "]]..."];
- summary = summary <> "[[Property:P225]]=" <> label <> ", ",
- Print["Already contains [[P:Latin name]]"];
- If[FreeQ[GetParam[#, "value"] & /@ GetParam[claims, {"P225"}],
- label], Print[
- "BUT IT IS NOT EQUAL TO [[" <> label <>
- "]]!!!! Doing nothing, please check manually"]]
- ];
- If[! FreeQ[
- GetParam[#, "numeric-id"] & /@ GetParam[claims, {"P171"}],
- uppertaxon],
- Print[
- "Already contains [[P171]]=[[" <> genus <> "]]. Do nothing"],
- AppendTo[editclaims, FormatCreateClaim[171, "item", uppertaxon]];
- Print["Setting [[P:171]]=[[" <> genus <> "]]..."];
- summary =
- summary <> "[[Property:P171]]=[[Q" <> ToString@uppertaxon <>
- "]], "];
- If[GetParam[item, {"labels", "ru"}] === {},
- editlabels = Join[editlabels, FormatSetLabel["ru", label]];
- summary = summary <> " russian label",
- Print["Already contains russian label: [[" <>
- GetParam[item, {"labels", "ru", "value"}] <> "]]"],
- Print[GetParam[item, {"labels", "ru"}]]];
- If[GetParam[item, {"descriptions", "ru"}] === {},
- editdescs =
- Join[editdescs,
- FormatSetDesc["ru", "вид растений из рода " <> genus]];
- If[StringFreeQ[summary, "russian"],
- summary = summary <> "russian description, ",
- summary = summary <> " and description, "],
- Print["Already contains russian description: [[" <>
- GetParam[item, {"descriptions", "ru", "value"}] <> "]]"];
- summary = summary <> ", ",
- Print[GetParam[item, {"descriptions", "ru"}]]];
- If[GetParam[item, {"labels", "fr"}] === {},
- editlabels = Join[editlabels, FormatSetLabel["fr", label]];
- summary = summary <> " french label",
- Print["Already contains french label: [[" <>
- GetParam[item, {"labels", "fr", "value"}] <> "]]"],
- Print[GetParam[item, {"labels", "fr"}]]];
- If[GetParam[item, {"descriptions", "fr"}] === {},
- editdescs =
- Join[editdescs,
- FormatSetDesc["fr", "espèce de plants de genre " <> genus]];
- If[StringFreeQ[summary, "french"],
- summary = summary <> "french description, ",
- summary = summary <> " and description, "],
- Print["Already contains french description: [[" <>
- GetParam[item, {"descriptions", "fr", "value"}] <> "]]"];
- summary = summary <> ", ",
- Print[GetParam[item, {"descriptions", "fr"}]]];
- If[GetParam[item, {"labels", "de"}] === {},
- editlabels = Join[editlabels, FormatSetLabel["de", label]];
- summary = summary <> " german label",
- Print["Already contains german label: [[" <>
- GetParam[item, {"labels", "de", "value"}] <> "]]"],
- Print[GetParam[item, {"labels", "de"}]]];
- If[GetParam[item, {"descriptions", "de"}] === {},
- editdescs =
- Join[editdescs,
- FormatSetDesc["de", "Art der Gattung " <> genus]];
- If[StringFreeQ[summary, "german"],
- summary = summary <> "german description, ",
- summary = summary <> " and description, "],
- Print["Already contains german description: [[" <>
- GetParam[item, {"descriptions", "de", "value"}] <> "]]"];
- summary = summary <> ", ",
- Print[GetParam[item, {"descriptions", "de"}]]];
- summary = StringDrop[summary, -2];
- edititem = {"claims" -> editclaims,
- "labels" -> Flatten[GetParam[{#}, "labels"] & /@ editlabels, 1],
- "descriptions" ->
- Flatten[GetParam[{#}, "descriptions"] & /@ editdescs, 1]};
- (*If[editclaims=={},edititem=Rest[edititem]];*)
- Print["New data: ", edititem];
- SetItem[#, edititem, summary, True]
- ) &,
- items[[1 ;; -1, 1]]];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement