Advertisement
Guest User

WikidataStructorEditSpecies

a guest
Jul 1st, 2014
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.83 KB | None | 0 0
  1. uppertaxon = 1353804;
  2. MapMonitor[
  3. (item = GetItem[#];
  4. claims = GetParam[item, "claims"];
  5. label =
  6. SortBy[Tally["value" /. (Last /@ GetParam[item, "labels"])],
  7. Last][[-1, 1]];
  8. Print["Обрабатываю ", #, " [[" <> label <> "]]"];
  9. summary = "Setting ";
  10. editclaims = editlabels = editdescs = {};
  11. If[GetParam[claims, {"P31", "numeric-id"}] === 16521,
  12. Print["Already contains [[P:Is a]]=[[taxon]]. Do nothing"],
  13. AppendTo[editclaims, FormatCreateClaim[31, "item", 16521]];
  14. Print["Setting [[P:Is a]]=[[taxon]]..."];
  15. summary = summary <> "[[Property:P31]]=[[Q16521]], "];
  16. If[! FreeQ[
  17. GetParam[#, "numeric-id"] & /@ GetParam[claims, {"P105"}],
  18. 7432],
  19. Print[
  20. "Already contains [[P:taxonomic rank]]=[[species]]. Do nothing"],
  21. AppendTo[editclaims, FormatCreateClaim[105, "item", 7432]];
  22. Print["Setting [[P:taxonomic rank]]=[[species]]..."];
  23. summary = summary <> "[[Property:P105]]=[[Q7432]], "];
  24. If[(GetParam[#, "value"] & /@ GetParam[claims, {"P225"}]) === {},
  25. AppendTo[editclaims, FormatCreateClaim[225, "string", label]];
  26. Print["Setting [[P:Latin name]]=[[" <> label <> "]]..."];
  27. summary = summary <> "[[Property:P225]]=" <> label <> ", ",
  28. Print["Already contains [[P:Latin name]]"];
  29. If[FreeQ[GetParam[#, "value"] & /@ GetParam[claims, {"P225"}],
  30. label], Print[
  31. "BUT IT IS NOT EQUAL TO [[" <> label <>
  32. "]]!!!! Doing nothing, please check manually"]]
  33. ];
  34. If[! FreeQ[
  35. GetParam[#, "numeric-id"] & /@ GetParam[claims, {"P171"}],
  36. uppertaxon],
  37. Print[
  38. "Already contains [[P171]]=[[" <> genus <> "]]. Do nothing"],
  39. AppendTo[editclaims, FormatCreateClaim[171, "item", uppertaxon]];
  40. Print["Setting [[P:171]]=[[" <> genus <> "]]..."];
  41. summary =
  42. summary <> "[[Property:P171]]=[[Q" <> ToString@uppertaxon <>
  43. "]], "];
  44. If[GetParam[item, {"labels", "ru"}] === {},
  45. editlabels = Join[editlabels, FormatSetLabel["ru", label]];
  46. summary = summary <> " russian label",
  47. Print["Already contains russian label: [[" <>
  48. GetParam[item, {"labels", "ru", "value"}] <> "]]"],
  49. Print[GetParam[item, {"labels", "ru"}]]];
  50. If[GetParam[item, {"descriptions", "ru"}] === {},
  51. editdescs =
  52. Join[editdescs,
  53. FormatSetDesc["ru", "вид растений из рода " <> genus]];
  54. If[StringFreeQ[summary, "russian"],
  55. summary = summary <> "russian description, ",
  56. summary = summary <> " and description, "],
  57. Print["Already contains russian description: [[" <>
  58. GetParam[item, {"descriptions", "ru", "value"}] <> "]]"];
  59. summary = summary <> ", ",
  60. Print[GetParam[item, {"descriptions", "ru"}]]];
  61. If[GetParam[item, {"labels", "fr"}] === {},
  62. editlabels = Join[editlabels, FormatSetLabel["fr", label]];
  63. summary = summary <> " french label",
  64. Print["Already contains french label: [[" <>
  65. GetParam[item, {"labels", "fr", "value"}] <> "]]"],
  66. Print[GetParam[item, {"labels", "fr"}]]];
  67. If[GetParam[item, {"descriptions", "fr"}] === {},
  68. editdescs =
  69. Join[editdescs,
  70. FormatSetDesc["fr", "espèce de plants de genre " <> genus]];
  71. If[StringFreeQ[summary, "french"],
  72. summary = summary <> "french description, ",
  73. summary = summary <> " and description, "],
  74. Print["Already contains french description: [[" <>
  75. GetParam[item, {"descriptions", "fr", "value"}] <> "]]"];
  76. summary = summary <> ", ",
  77. Print[GetParam[item, {"descriptions", "fr"}]]];
  78. If[GetParam[item, {"labels", "de"}] === {},
  79. editlabels = Join[editlabels, FormatSetLabel["de", label]];
  80. summary = summary <> " german label",
  81. Print["Already contains german label: [[" <>
  82. GetParam[item, {"labels", "de", "value"}] <> "]]"],
  83. Print[GetParam[item, {"labels", "de"}]]];
  84. If[GetParam[item, {"descriptions", "de"}] === {},
  85. editdescs =
  86. Join[editdescs,
  87. FormatSetDesc["de", "Art der Gattung " <> genus]];
  88. If[StringFreeQ[summary, "german"],
  89. summary = summary <> "german description, ",
  90. summary = summary <> " and description, "],
  91. Print["Already contains german description: [[" <>
  92. GetParam[item, {"descriptions", "de", "value"}] <> "]]"];
  93. summary = summary <> ", ",
  94. Print[GetParam[item, {"descriptions", "de"}]]];
  95. summary = StringDrop[summary, -2];
  96. edititem = {"claims" -> editclaims,
  97. "labels" -> Flatten[GetParam[{#}, "labels"] & /@ editlabels, 1],
  98. "descriptions" ->
  99. Flatten[GetParam[{#}, "descriptions"] & /@ editdescs, 1]};
  100. (*If[editclaims=={},edititem=Rest[edititem]];*)
  101. Print["New data: ", edititem];
  102.  
  103. SetItem[#, edititem, summary, True]
  104. ) &,
  105. items[[1 ;; -1, 1]]];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement