Workdocumentation 2023-03-30

From BITPlan ceur-ws Wiki
Revision as of 16:34, 30 March 2023 by Wf (talk | contribs)
Jump to navigation Jump to search
# created by /home/wf/.local/lib/python3.10/site-packages/ceurspt/ceurws.py
CREATE
# P31  :instance of  Q13442814:scholarly article
LAST|P31|Q13442814
# P1433: published in 
LAST|P1433|Q39294161
# english label
LAST|Len|"Scholarly Social Machines"
# P1476:title
LAST|P1476|en:"Scholarly Social Machines"
# P407 :language of work or name  Q1860:English
Q117337537|P407|Q1860
# P953 :full work available at URL
Q117337537|P953|"https://ceur-ws.org/Vol-1878/article-05.pdf"
# P50: author, P1545: series ordinal
Q117337537|P50|Q5232894|P1545|"1"
smwsync -u -t ceur-ws --context  CeurwsSchema --topic Volume -pk 3355 -p acronym title description url date dblp k10plus urn   --progress
smwsync -u -t ceur-ws --context  CeurwsSchema --topic Paper -pkv Q117337714 -p title

cwp script

#!/bin/bash
# WF 2023-03-30
#Vol-2644/paper35

#
# import a paper to the wiki
#
paper2wiki() {
  local paperid="$1"
  target_wiki=/tmp/$paperid.wiki
  target_wb=/tmp/$paperid.wbjson
  dir=$(dirname $target_wiki)
  echo $dir
  mkdir -p $dir
  echo "getting markup from $paperid"
  curl -s http://ceurspt.wikidata.dbis.rwth-aachen.de/$paperid.smw -o $target_wiki
  echo "checking whether paper $paperid is already in wikidata"
  qid=$(wd q -p P953 -o https://ceur-ws.org/$paperid.pdf)
  if [ $? -eq 0 ]
  then
    echo "$qid ✅"
  else
    echo "getting wikibase-cli json from $paperid"
    curl -s http://ceurspt.wikidata.dbis.rwth-aachen.de/$paperid.wbjson -o $target_wb
    #wikirestore -t ceur-ws --backupPath /tmp -p "$paperid"
    cat $target_wb | jq .
    echo "shall i add the paper to wikidata y/ys/n?"
    read answer
    case $answer in
      y*)
          wd create-entity $target_wb > /tmp/$paperid.cjson
          qid=$(cat /tmp/$paperid.cjson | jq --raw-output .entity.id)
          wd_url="https://www.wikidata.org/wiki/$qid"
          echo "created wikidata entry $qid"
          if [ "$answer" = "ys" ]
          then
            open $wd_url
          fi
          wikiedit -t ceur-ws --template Paper --property wikidataid --value $qid -p $paperid  --force
      ;;
    esac
  fi
}

#
#
#
volume2wiki() {
  local l_volume="$1"
  target_wiki=/tmp/Vol-$l_volume.wiki
  dir=$(dirname $target_wiki)
  mkdir -p $dir
  curl -s http://ceurspt.wikidata.dbis.rwth-aachen.de/Vol-$l_volume.smw -o $target_wiki
  wikirestore -t ceur-ws --backupPath /tmp -p "Vol-$l_volume"
}

#
# handle the volume
#
handle_volume() {
  local l_volume="$1"
  echo "getting volume $l_volume ..." 1>&2
  for paper in $(curl -s http://cvb.bitplan.com/dblp/volume/$l_volume/paper | jq --raw-output ".[].pdf_id")
  do
    paper2wiki $paper
  done
}

volume2wiki $1
handle_volume $1