cgspace-notes/docs/2022-06/index.html

513 lines
29 KiB
HTML

<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta property="og:title" content="June, 2022" />
<meta property="og:description" content="2022-06-06
Look at the Solr statistics on CGSpace
I see 167,000 hits from a bunch of Microsoft IPs with reverse DNS &ldquo;msnbot-&rdquo; using the Solr query dns:*msnbot* AND dns:*.msn.com
I purged these first so I could see the other &ldquo;real&rdquo; IPs in the Solr facets
I see 47,500 hits from 80.248.237.167 on a data center ISP in Sweden, using a normal user agent
I see 13,000 hits from 163.237.216.11 on a data center ISP in Australia, using a normal user agent
I see 7,300 hits from 208.185.238.57 from Britanica, using a normal user agent
There seem to be many more of these:
" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://alanorth.github.io/cgspace-notes/2022-06/" />
<meta property="article:published_time" content="2022-06-06T09:01:36+03:00" />
<meta property="article:modified_time" content="2022-08-03T21:01:39+03:00" />
<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="June, 2022"/>
<meta name="twitter:description" content="2022-06-06
Look at the Solr statistics on CGSpace
I see 167,000 hits from a bunch of Microsoft IPs with reverse DNS &ldquo;msnbot-&rdquo; using the Solr query dns:*msnbot* AND dns:*.msn.com
I purged these first so I could see the other &ldquo;real&rdquo; IPs in the Solr facets
I see 47,500 hits from 80.248.237.167 on a data center ISP in Sweden, using a normal user agent
I see 13,000 hits from 163.237.216.11 on a data center ISP in Australia, using a normal user agent
I see 7,300 hits from 208.185.238.57 from Britanica, using a normal user agent
There seem to be many more of these:
"/>
<meta name="generator" content="Hugo 0.101.0" />
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BlogPosting",
"headline": "June, 2022",
"url": "https://alanorth.github.io/cgspace-notes/2022-06/",
"wordCount": "1786",
"datePublished": "2022-06-06T09:01:36+03:00",
"dateModified": "2022-08-03T21:01:39+03:00",
"author": {
"@type": "Person",
"name": "Alan Orth"
},
"keywords": "Notes"
}
</script>
<link rel="canonical" href="https://alanorth.github.io/cgspace-notes/2022-06/">
<title>June, 2022 | CGSpace Notes</title>
<!-- combined, minified CSS -->
<link href="https://alanorth.github.io/cgspace-notes/css/style.beb8012edc08ba10be012f079d618dc243812267efe62e11f22fe49618f976a4.css" rel="stylesheet" integrity="sha256-vrgBLtwIuhC&#43;AS8HnWGNwkOBImfv5i4R8i/klhj5dqQ=" crossorigin="anonymous">
<!-- minified Font Awesome for SVG icons -->
<script defer src="https://alanorth.github.io/cgspace-notes/js/fontawesome.min.f5072c55a0721857184db93a50561d7dc13975b4de2e19db7f81eb5f3fa57270.js" integrity="sha256-9QcsVaByGFcYTbk6UFYdfcE5dbTeLhnbf4HrXz&#43;lcnA=" crossorigin="anonymous"></script>
<!-- RSS 2.0 feed -->
</head>
<body>
<div class="blog-masthead">
<div class="container">
<nav class="nav blog-nav">
<a class="nav-link " href="https://alanorth.github.io/cgspace-notes/">Home</a>
</nav>
</div>
</div>
<header class="blog-header">
<div class="container">
<h1 class="blog-title" dir="auto"><a href="https://alanorth.github.io/cgspace-notes/" rel="home">CGSpace Notes</a></h1>
<p class="lead blog-description" dir="auto">Documenting day-to-day work on the <a href="https://cgspace.cgiar.org">CGSpace</a> repository.</p>
</div>
</header>
<div class="container">
<div class="row">
<div class="col-sm-8 blog-main">
<article class="blog-post">
<header>
<h2 class="blog-post-title" dir="auto"><a href="https://alanorth.github.io/cgspace-notes/2022-06/">June, 2022</a></h2>
<p class="blog-post-meta">
<time datetime="2022-06-06T09:01:36+03:00">Mon Jun 06, 2022</time>
in
<span class="fas fa-folder" aria-hidden="true"></span>&nbsp;<a href="/categories/notes/" rel="category tag">Notes</a>
</p>
</header>
<h2 id="2022-06-06">2022-06-06</h2>
<ul>
<li>Look at the Solr statistics on CGSpace
<ul>
<li>I see 167,000 hits from a bunch of Microsoft IPs with reverse DNS &ldquo;msnbot-&rdquo; using the Solr query <code>dns:*msnbot* AND dns:*.msn.com</code></li>
<li>I purged these first so I could see the other &ldquo;real&rdquo; IPs in the Solr facets</li>
</ul>
</li>
<li>I see 47,500 hits from 80.248.237.167 on a data center ISP in Sweden, using a normal user agent</li>
<li>I see 13,000 hits from 163.237.216.11 on a data center ISP in Australia, using a normal user agent</li>
<li>I see 7,300 hits from 208.185.238.57 from Britanica, using a normal user agent
<ul>
<li>There seem to be many more of these:</li>
</ul>
</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-console" data-lang="console"><span style="display:flex;"><span># zcat --force /var/log/nginx/access.log* | grep 208.185.238. | awk <span style="color:#e6db74">&#39;{print $1}&#39;</span> | sort | uniq -c | sort -h
</span></span><span style="display:flex;"><span> 2 208.185.238.1
</span></span><span style="display:flex;"><span> 166 208.185.238.54
</span></span><span style="display:flex;"><span> 1293 208.185.238.51
</span></span><span style="display:flex;"><span> 2587 208.185.238.59
</span></span><span style="display:flex;"><span> 4692 208.185.238.56
</span></span><span style="display:flex;"><span> 5480 208.185.238.53
</span></span><span style="display:flex;"><span> 6277 208.185.238.52
</span></span><span style="display:flex;"><span> 6400 208.185.238.58
</span></span><span style="display:flex;"><span> 8261 208.185.238.55
</span></span><span style="display:flex;"><span> 17549 208.185.238.57
</span></span></code></pre></div><ul>
<li>I see 3,000 hits from 178.208.75.33 by a Russian-owned IP in the Netherlands that is making a GET to / every one minute, using a normal user agent</li>
<li>I see 3,000 hits from 134.122.124.196 on Digital Ocean to the REST API with a normal user agent</li>
<li>I purged all these hits from IPs for a total of about 265,000</li>
<li>Then I faceted by user agent and found
<ul>
<li>1,000 hits by <code>insomnia/2022.2.1</code>, which I also saw last month and submitted to COUNTER-Robots</li>
<li>265 hits by <code>omgili/0.5 +http://omgili.com</code></li>
<li>150 hits by <code>Vizzit</code></li>
<li>132 hits by <code>MetaInspector/5.7.0 (+https://github.com/jaimeiniesta/metainspector)</code></li>
<li>73 hits by <code>Scoop.it</code></li>
<li>62 hits by <code>bitdiscovery</code></li>
<li>59 hits by <code>Asana/1.4.0 WebsiteMetadataRetriever</code></li>
<li>32 hits by <code>Sprout Social (Link Attachment)</code></li>
<li>29 hits by <code>CyotekWebCopy/1.9 CyotekHTTP/6.2</code></li>
<li>20 hits by <code>Hootsuite-Authoring/1.0</code></li>
</ul>
</li>
<li>I purged about 4,100 hits from these user agents</li>
<li>Run all system updates on AReS server (linode20) and reboot</li>
<li>I want to try to update some of the build dependencies of OpenRXV since Node.js 12 is no longer supported</li>
<li>Upgrade linode20 to Ubuntu 22.04 and start an AReS harvest</li>
<li>I merged the <a href="https://github.com/DSpace/DSpace/pull/8292">Mirage 2 build fix</a> to <code>dspace-6_x</code> for DSpace 6.4</li>
</ul>
<h2 id="2022-06-07">2022-06-07</h2>
<ul>
<li>I tested Node.js 14 one more time with vanilla DSpace 6.4-SNAPSHOT and with the CGSpace source and it worked well
<ul>
<li>I made <a href="https://github.com/DSpace/DSpace/pull/8331">a pull request</a> to DSpace to use Node.js 14 for Mirage 2</li>
<li>I even tested Node.js 16 and it works, but that is enough for now&hellip;</li>
</ul>
</li>
</ul>
<h2 id="2022-06-08">2022-06-08</h2>
<ul>
<li>Work on AReS a bit since I wasn&rsquo;t able to harvest after doing the updates on the server and in the containers a few days ago
<ul>
<li>I don&rsquo;t know what the problem was really, but on the server I had to enable IPv4 forwarding so the frontend container would build</li>
<li>Once I downed and upped AReS with docker-compose I was able to start a new harvest</li>
<li>I also did some tests to enable ES2020 target in the backend because we&rsquo;re on Node.js 14 there now</li>
</ul>
</li>
</ul>
<h2 id="2022-06-13">2022-06-13</h2>
<ul>
<li>Create a user for Mohammed Salem to test MEL submission on DSpace Test:</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-console" data-lang="console"><span style="display:flex;"><span>$ dspace user -a -m mel-submit@cgiar.org -g MEL -s Submit -p <span style="color:#e6db74">&#39;owwwwwwww&#39;</span>
</span></span></code></pre></div><ul>
<li>According to my notes from <a href="/cgspace-notes/2020-10/">2020-10</a> the account must be in the admin group in order to submit via the REST API</li>
</ul>
<h2 id="2022-06-14">2022-06-14</h2>
<ul>
<li>Start a harvest on AReS</li>
</ul>
<h2 id="2022-06-16">2022-06-16</h2>
<ul>
<li>Francesca asked us to add the CC-BY-3.0-IGO license to the submission form on CGSpace
<ul>
<li>I remember I <a href="https://github.com/spdx/license-list-XML/issues/767">had requested SPDX to add CC-BY-NC-ND-3.0-IGO</a> in 2019-02, and they finally <a href="https://github.com/spdx/license-list-XML/pull/1068">merged it</a> in 2020-07, but I never added it to CGSpace</li>
<li>I will add the full suite of CC 3.0 IGO licenses to CGSpace and then make a request to SPDX for the others:
- CC-BY-3.0-IGO
- CC-BY-SA-3.0-IGO
- CC-BY-ND-3.0-IGO
- CC-BY-NC-3.0-IGO
- CC-BY-NC-SA-3.0-IGO
- CC-BY-NC-ND-3.0-IGO</li>
</ul>
</li>
<li>I filed <a href="https://github.com/spdx/license-list-XML/issues/1525">an issue asking for SPDX to add CC-BY-3.0-IGO</a></li>
<li>Meeting with Moayad from CodeObia to discuss OpenRXV
<ul>
<li>He added the ability to use multiple indexes / dashboards, and to be able to embed them in iframes</li>
</ul>
</li>
<li>Add <code>cg.contributor.initiative</code> with a controlled vocabulary based on CLARISA&rsquo;s list to the CGSpace submission form</li>
<li>Switch to the <code>linux-virtual-hwe-20.04</code> kernel on CGSpace (linode18), run all system updates, and reboot</li>
</ul>
<h2 id="2022-06-17">2022-06-17</h2>
<ul>
<li>I noticed a few ORCID identifiers missing for some scientists so I added them to the controlled vocabulary and then tagged them on CGSpace:</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-console" data-lang="console"><span style="display:flex;"><span>$ cat 2022-06-17-add-orcids.csv
</span></span><span style="display:flex;"><span>dc.contributor.author,cg.creator.identifier
</span></span><span style="display:flex;"><span>&#34;Tijjani, A.&#34;,&#34;Abdulfatai Tijjani: 0000-0002-0793-9059&#34;
</span></span><span style="display:flex;"><span>&#34;Tijjani, Abdulfatai&#34;,&#34;Abdulfatai Tijjani: 0000-0002-0793-9059&#34;
</span></span><span style="display:flex;"><span>&#34;Mrode, Raphael A.&#34;,&#34;Raphael Mrode: 0000-0003-1964-5653&#34;
</span></span><span style="display:flex;"><span>&#34;Okeyo Mwai, Ally&#34;,&#34;Ally Okeyo Mwai: 0000-0003-2379-7801&#34;
</span></span><span style="display:flex;"><span>&#34;Ojango, Julie M.K.&#34;,&#34;Ojango J.M.K.: 0000-0003-0224-5370&#34;
</span></span><span style="display:flex;"><span>&#34;Prendergast, J.G.D.&#34;,&#34;James Prendergast: 0000-0001-8916-018X&#34;
</span></span><span style="display:flex;"><span>&#34;Ekine-Dzivenu, Chinyere&#34;,&#34;Chinyere Ekine-Dzivenu: 0000-0002-8526-435X&#34;
</span></span><span style="display:flex;"><span>&#34;Ekine, C.&#34;,&#34;Chinyere Ekine-Dzivenu: 0000-0002-8526-435X&#34;
</span></span><span style="display:flex;"><span>&#34;Ekine-Dzivenu, C.C&#34;,&#34;Chinyere Ekine-Dzivenu: 0000-0002-8526-435X&#34;
</span></span><span style="display:flex;"><span>&#34;Shilomboleni, Helena&#34;,&#34;Helena Shilomboleni: 0000-0002-9875-6484&#34;
</span></span><span style="display:flex;"><span>$ ./ilri/add-orcid-identifiers-csv.py -i /tmp/2022-06-17-add-orcids.csv -db dspace -u dspace -p <span style="color:#e6db74">&#39;fuuu&#39;</span> | tee /tmp/orcids.log
</span></span><span style="display:flex;"><span>$ grep -c <span style="color:#e6db74">&#39;Adding ORCID&#39;</span> /tmp/orcids2.log
</span></span><span style="display:flex;"><span>304
</span></span></code></pre></div><ul>
<li>Also make some changes to the Discovery facets and item view
<ul>
<li>I reduced the number of items to show for CRP facets from 20 to 5</li>
<li>I added a facet for the Initiatives</li>
<li>I re-organized a few parts of the item view to add Action Areas and the list of author affiliations</li>
</ul>
</li>
</ul>
<h2 id="2022-06-18">2022-06-18</h2>
<ul>
<li>I deployed the changes on CGSpace and started a full Discovery index for the new Initiatives facet</li>
<li>Run <code>dspace cleanup -v</code> on CGSpace</li>
</ul>
<h2 id="2022-06-20">2022-06-20</h2>
<ul>
<li>Add missing ORCID identifier for ILRI staff to CGSpace and tag their items</li>
</ul>
<h2 id="2022-06-21">2022-06-21</h2>
<ul>
<li>Work on OpenRXV backend dependencies
<ul>
<li>Update Elasticsearch and TypeScript and eslint</li>
</ul>
</li>
<li>Sit in on webinar about contributing terms to AGROVOC
<ul>
<li>I agreed that I would send Sara Jani from ICARDA a list of new terms we have that don&rsquo;t match AGROVOC by end of June</li>
<li>I need to indicate which center is using them so we can have an appropriate expert review the terms</li>
</ul>
</li>
</ul>
<h2 id="2022-06-22">2022-06-22</h2>
<ul>
<li>I re-deployed AReS with the latest OpenRXV changes then started a fresh harvest</li>
<li>Meeting with Salem to discuss metadata between CGSpace and MEL
<ul>
<li>We started working through his spreadsheet and then the Internet dropped</li>
</ul>
</li>
</ul>
<h2 id="2022-06-23">2022-06-23</h2>
<ul>
<li>Start looking at country names between MEL, CGSpace, and standards like UN M.49 and GeoNames
<ul>
<li>I used <code>xmllint</code> to extract the countries from CGSpace&rsquo;s input forms:</li>
</ul>
</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-console" data-lang="console"><span style="display:flex;"><span>$ xmllint --xpath <span style="color:#e6db74">&#39;//value-pairs[@value-pairs-name=&#34;countrylist&#34;]/pair/stored-value/node()&#39;</span> dspace/config/input-forms.xml &gt; /tmp/cgspace-countries.txt
</span></span></code></pre></div><ul>
<li>Then I wrote a Python script (<code>countries-to-csv.py</code>) to read them and save their names alongside the ISO 3166-1 Alpha2 code</li>
<li>Then I joined them with the other lists:</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-console" data-lang="console"><span style="display:flex;"><span>$ csvjoin --outer -c alpha2 ~/Downloads/clarisa-countries.csv ~/Downloads/UNSD<span style="color:#ae81ff">\ </span><span style="color:#ae81ff">\ </span>Methodology.csv ~/Downloads/geonames-countries.csv /tmp/cgspace-countries.csv /tmp/mel-countries.csv&gt; /tmp/countries.csv
</span></span></code></pre></div><ul>
<li>This mostly worked fine, and is much easier than writing another Python script with Pandas&hellip;</li>
</ul>
<h2 id="2022-06-24">2022-06-24</h2>
<ul>
<li>Spent some more time working on my <code>countries-to-csv.py</code> script to fix some logic errors</li>
<li>Then re-export the UN M.49 countries to a clean list because the one I did yesterday somehow has errors:</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-console" data-lang="console"><span style="display:flex;"><span>csvcut -d &#39;;&#39; -c &#39;ISO-alpha2 Code,Country or Area&#39; ~/Downloads/UNSD\ —\ Methodology.csv | sed -e &#39;1s/ISO-alpha2 Code/alpha2/&#39; -e &#39;1s/Country or Area/UN M.49 Name/&#39; &gt; ~/Downloads/un-countries.csv
</span></span></code></pre></div><ul>
<li>Check the number of lines in each file:</li>
</ul>
<pre tabindex="0"><code>$ wc -l clarisa-countries.csv un-countries.csv cgspace-countries.csv mel-countries.csv
250 clarisa-countries.csv
250 un-countries.csv
198 cgspace-countries.csv
258 mel-countries.csv
</code></pre><ul>
<li>I am seeing strange results with csvjoin&rsquo;s <code>--outer</code> join that I need to keep unmatched terms from both left and right files&hellip;
<ul>
<li>Using <code>xsv join --full</code> is giving me better results:</li>
</ul>
</li>
</ul>
<pre tabindex="0"><code>$ xsv join --full alpha2 ~/Downloads/clarisa-countries.csv alpha2 ~/Downloads/un-countries.csv | xsv select &#39;!alpha2[1]&#39; &gt; /tmp/clarisa-un-xsv-full.csv
</code></pre><ul>
<li>Then adding the CGSpace and MEL countries:</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-console" data-lang="console"><span style="display:flex;"><span>$ xsv join --full alpha2 /tmp/clarisa-un-xsv-full.csv alpha2 /tmp/cgspace-countries.csv | xsv <span style="color:#66d9ef">select</span> <span style="color:#e6db74">&#39;!alpha2[1]&#39;</span> &gt; /tmp/clarisa-un-cgspace-xsv-full.csv
</span></span><span style="display:flex;"><span>$ xsv join --full alpha2 /tmp/clarisa-un-cgspace-xsv-full.csv alpha2 /tmp/mel-countries.csv | xsv <span style="color:#66d9ef">select</span> <span style="color:#e6db74">&#39;!alpha2[1]&#39;</span> &gt; /tmp/clarisa-un-cgspace-mel-xsv-full.csv
</span></span></code></pre></div><h2 id="2022-06-26">2022-06-26</h2>
<ul>
<li>Start a harvest on AReS</li>
</ul>
<h2 id="2022-06-28">2022-06-28</h2>
<ul>
<li>Start working on the CGSpace subject export for FAO</li>
<li>First I exported a list of all metadata in our <code>dcterms.subject</code> and other center-specific subject fields with their counts:</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-console" data-lang="console"><span style="display:flex;"><span>localhost/dspacetest= ☘ \COPY (SELECT DISTINCT text_value AS &#34;subject&#34;, count(*) FROM metadatavalue WHERE dspace_object_id in (SELECT dspace_object_id FROM item) AND metadata_field_id IN (187, 120, 210, 122, 215, 127, 208, 124, 128, 123, 125, 135, 203, 236, 238, 119) GROUP BY &#34;subject&#34; ORDER BY count DESC) to /tmp/2022-06-28-cgspace-subjects.csv WITH CSV HEADER;
</span></span><span style="display:flex;"><span>COPY 27010
</span></span></code></pre></div><ul>
<li>Then I extracted the subjects and looked them up against AGROVOC:</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-console" data-lang="console"><span style="display:flex;"><span>$ csvcut -c subject /tmp/2022-06-28-cgspace-subjects.csv | sed <span style="color:#e6db74">&#39;1d&#39;</span> &gt; /tmp/2022-06-28-cgspace-subjects.txt
</span></span><span style="display:flex;"><span>$ ./ilri/agrovoc-lookup.py -i /tmp/2022-06-28-cgspace-subjects.txt -o /tmp/2022-06-28-cgspace-subjects-results.csv
</span></span></code></pre></div><ul>
<li>I keep getting timeouts after every five or ten requests, so this will not be feasible for 27,000 subjects!</li>
<li>I think I will have to write some custom script to use the AGROVOC RDF file
<ul>
<li>Using rdflib to open the 1.2GB <code>agrovoc_lod.rdf</code> file takes several minutes and doesn&rsquo;t seem very efficient</li>
</ul>
</li>
<li>I tried using <a href="https://github.com/ozekik/lightrdf">lightrdf</a> and it&rsquo;s much quicker, but the documentation is limiting and I&rsquo;m not sure how to search yet
<ul>
<li>I had to try in different Python versions because 3.10.x is apparently too new</li>
</ul>
</li>
<li>For future reference I was able to search with lightrdf:</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-python" data-lang="python"><span style="display:flex;"><span><span style="color:#f92672">import</span> lightrdf
</span></span><span style="display:flex;"><span>parser <span style="color:#f92672">=</span> lightrdf<span style="color:#f92672">.</span>Parser()
</span></span><span style="display:flex;"><span><span style="color:#75715e"># prints millions of lines</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">for</span> triple <span style="color:#f92672">in</span> parser<span style="color:#f92672">.</span>parse(<span style="color:#e6db74">&#34;./agrovoc_lod.rdf&#34;</span>, base_iri<span style="color:#f92672">=</span><span style="color:#66d9ef">None</span>):
</span></span><span style="display:flex;"><span> print(triple)
</span></span><span style="display:flex;"><span>agrovoc <span style="color:#f92672">=</span> lightrdf<span style="color:#f92672">.</span>RDFDocument(<span style="color:#e6db74">&#39;agrovoc_lod.rdf&#39;</span>);
</span></span><span style="display:flex;"><span><span style="color:#75715e"># all results for prefix http://aims.fao.org/aos/agrovoc/c_5</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">for</span> triple <span style="color:#f92672">in</span> agrovoc<span style="color:#f92672">.</span>search_triples(<span style="color:#e6db74">&#39;http://aims.fao.org/aos/agrovoc/c_5&#39;</span>, <span style="color:#66d9ef">None</span>, <span style="color:#66d9ef">None</span>):
</span></span><span style="display:flex;"><span> print(triple)
</span></span><span style="display:flex;"><span>(<span style="color:#e6db74">&#39;http://aims.fao.org/aos/agrovoc/c_5&#39;</span>, <span style="color:#e6db74">&#39;http://www.w3.org/2004/02/skos/core#altLabel&#39;</span>, <span style="color:#e6db74">&#39;&#34;Abalone&#34;@de&#39;</span>)
</span></span><span style="display:flex;"><span>(<span style="color:#e6db74">&#39;http://aims.fao.org/aos/agrovoc/c_5&#39;</span>, <span style="color:#e6db74">&#39;http://www.w3.org/2004/02/skos/core#prefLabel&#39;</span>, <span style="color:#e6db74">&#39;&#34;abalones&#34;@en&#39;</span>)
</span></span><span style="display:flex;"><span><span style="color:#75715e"># all stuff for abalones in English</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">for</span> triple <span style="color:#f92672">in</span> agrovoc<span style="color:#f92672">.</span>search_triples(<span style="color:#66d9ef">None</span>, <span style="color:#66d9ef">None</span>, <span style="color:#e6db74">&#39;&#34;abalones&#34;@en&#39;</span>):
</span></span><span style="display:flex;"><span> print(triple)
</span></span></code></pre></div><ul>
<li>I ran the <code>agrovoc-lookup.py</code> from a Linode server and it completed without issues&hellip; hmmm</li>
</ul>
<h2 id="2022-06-29">2022-06-29</h2>
<ul>
<li>Continue working on the list of non-AGROVOC subject to report to FAO
<ul>
<li>I got a one liner to get the list of non-AGROVOC subjects and join them with their counts (updated to use regex in csvgrep):</li>
</ul>
</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-console" data-lang="console"><span style="display:flex;"><span>$ csvgrep -c <span style="color:#e6db74">&#39;number of matches&#39;</span> -r <span style="color:#e6db74">&#39;^0$&#39;</span> /tmp/2022-06-28-cgspace-subjects-results.csv <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span> | csvcut -c subject \
</span></span><span style="display:flex;"><span> | csvjoin -c subject /tmp/2022-06-28-cgspace-subjects.csv - \
</span></span><span style="display:flex;"><span> &gt; /tmp/2022-06-28-cgspace-non-agrovoc.csv
</span></span></code></pre></div><h2 id="2022-06-30">2022-06-30</h2>
<ul>
<li>Check some AfricaRice records for potential duplicates on CGSpace for Abenet:</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-console" data-lang="console"><span style="display:flex;"><span>$ csvcut -l -c dc.title,dcterms.issued,dcterms.type ~/Downloads/Africarice_2ndBatch_ay.csv | sed <span style="color:#e6db74">&#39;1s/line_number/id/&#39;</span> &gt; /tmp/africarice.csv
</span></span><span style="display:flex;"><span>$ csv-metadata-quality -i /tmp/africarice.csv -o /tmp/africarice-cleaned.csv -u
</span></span><span style="display:flex;"><span>$ ./ilri/check-duplicates.py -i /tmp/africarice-cleaned.csv -u dspacetest -db dspacetest -p <span style="color:#e6db74">&#39;dom@in34sniper&#39;</span> -o /tmp/africarice-duplicates.csv
</span></span></code></pre></div><ul>
<li>Looking at the non-AGROVOC subjects again, I see some in our list that are duplicated in uppercase and lowercase, so I will run it again with all lowercase:</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-console" data-lang="console"><span style="display:flex;"><span>localhost/dspacetest= ☘ \COPY (SELECT DISTINCT(lower(text_value)) AS &#34;subject&#34;, count(*) FROM metadatavalue WHERE dspace_object_id in (SELECT dspace_object_id FROM item) AND metadata_field_id IN (187, 120, 210, 122, 215, 127, 208, 124, 128, 123, 125, 135, 203, 236, 238, 119) GROUP BY &#34;subject&#34; ORDER BY count DESC) to /tmp/2022-06-30-cgspace-subjects.csv WITH CSV HEADER;
</span></span></code></pre></div><ul>
<li>Also, I see there might be something wrong with my csvjoin because nigeria shows up in the final list as having not matched&hellip;
<ul>
<li>Ah, I was using <code>csvgrep -m 0</code> to find rows that didn&rsquo;t match, but that also matched items that had 10, 100, 50, etc&hellip;</li>
<li>We need to use a regex:</li>
</ul>
</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-console" data-lang="console"><span style="display:flex;"><span>$ csvgrep -c <span style="color:#e6db74">&#39;number of matches&#39;</span> -r <span style="color:#e6db74">&#39;^0$&#39;</span> /tmp/2022-06-30-cgspace-subjects-results.csv <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span> | csvcut -c subject \
</span></span><span style="display:flex;"><span> | csvjoin -c subject /tmp/2022-06-30-cgspace-subjects.csv - \
</span></span><span style="display:flex;"><span> &gt; /tmp/2022-06-30-cgspace-non-agrovoc.csv
</span></span></code></pre></div><ul>
<li>Then I took all the terms with fifty or more occurences and put them on a Google Sheet
<ul>
<li>There I started removing any term that was a variation of an existing AGROVOC term (like cowpea/cowpeas, policy/policies) or a compound concept</li>
</ul>
</li>
<li>pnbecker on DSpace Slack mentioned that they made a JSPUI deduplication step that is open source: <a href="https://github.com/the-library-code/deduplication">https://github.com/the-library-code/deduplication</a>
<ul>
<li>It uses Levenshtein distance via PostgreSQL&rsquo;s fuzzystrmatch extension</li>
</ul>
</li>
</ul>
<!-- raw HTML omitted -->
</article>
</div> <!-- /.blog-main -->
<aside class="col-sm-3 ml-auto blog-sidebar">
<section class="sidebar-module">
<h4>Recent Posts</h4>
<ol class="list-unstyled">
<li><a href="/cgspace-notes/2022-08/">August, 2022</a></li>
<li><a href="/cgspace-notes/2022-07/">July, 2022</a></li>
<li><a href="/cgspace-notes/2022-06/">June, 2022</a></li>
<li><a href="/cgspace-notes/2022-05/">May, 2022</a></li>
<li><a href="/cgspace-notes/2022-04/">April, 2022</a></li>
</ol>
</section>
<section class="sidebar-module">
<h4>Links</h4>
<ol class="list-unstyled">
<li><a href="https://cgspace.cgiar.org">CGSpace</a></li>
<li><a href="https://dspacetest.cgiar.org">DSpace Test</a></li>
<li><a href="https://github.com/ilri/DSpace">CGSpace @ GitHub</a></li>
</ol>
</section>
</aside>
</div> <!-- /.row -->
</div> <!-- /.container -->
<footer class="blog-footer">
<p dir="auto">
Blog template created by <a href="https://twitter.com/mdo">@mdo</a>, ported to Hugo by <a href='https://twitter.com/mralanorth'>@mralanorth</a>.
</p>
<p>
<a href="#">Back to top</a>
</p>
</footer>
</body>
</html>