Importing deprecated statements in Wikidata - wikidata

I read that Openrefine Wikidata import can only create statements with rank = Normal.
I am in a situation where I would like to import deprecated identifiers, namely old ISSNs (identifiers for serial publications) that used to be used to refer to a publication, but that are no longer in use. They have value because other bibliographic databases might still use them to refer to a publication.
So I'd like to be able to import these values, and mark them as "deprecated".
OpenRefine Wikidata import really really can't do that ? any workaround I could use ?
If I can't do that by the time I import the data from OpenRefine, I can flag these statements with "reason for deprecation = withdrawn identifier value". Can I run another automated process after import that would automatically set a deprecated rank on these statements ?
If I can't set them automatically to deprecated neither at import time nor after, which other qualifier can I use to indicated these identifiers are no longer in use ? (the official term being "Cancelled ISSN")
Thanks

A possibility I found would be to use the Wikidata-Toolkit library, in which StatementBuilder can create Statements with a specified rank. I would still to know/fetch the list of statements to modify...
I am still open to suggestions on the possibility to specify ranks at import time.

Related

Do Firestore imports merge or override collections?

Let's say I have the current Firestore data:
COLLECTION_1
DOC_A
DOC_B
DOC_C
COLLECTION_2
DOC_X
And I have some exported data, which is:
COLLECTION_1
DOC_B // DOC_A IS NOT HERE
DOC_C
DOC_D // DOC_D IS AN "EXTRA"
// COLLECTION_2 IS MISSING
COLLECTION_3 // THERE IS AN "EXTRA" COLLECTION
DOC_3
What happens when I import data data? Will some kind of "merge" occur, or my entire Firestore will be replaced with the imported data as is? I'm gessing DOC_D and COLLECTIO_3 will be added for sure. But will DOC_A and COLLECTION_2 (the ones missing on the exported data) still be there after the import?
PS: I'm asking this on the context of a full import (i.e: all collections).
To import specific collections, it seems that you need to use an export that exported specific collections, and you need to import it back using gcloud. The web console only allows for full imports. Anyway, I think the global "merge or override" behavior on a full import is probably similar to the same behavior over a specific collection.
Docs on import/export
This was super quick to test it. The result is
COLLECTION_1
DOC_A
DOC_B
DOC_C
DOC_D
COLLECTION_2
DOC_X
COLLECTION_3
DOC_3
Everything is happening by document. Mentioned documentation says:
If a document with the same ID already exists, the import overwrites
the existing document.
If a document in your database is not affected by an import, it will
remain in your database after the import.
And this exactly happening. Documents that are exist in the import are overridden, and not existing are added. If document is in Firestore but not in import it remains unchanged.
BTW if you test it in GUI, you have to refresh the page after import. Otherwise changes are not visible (at least it happened to me).

Kotlin arrow-kt Flatten nested Either

I'm programming using the functional library arrow-kt (formerly known as kategory). I'm using Either monad to aggregate errors or success information of an api call. I got myself into a state (which shouldn't happen in the first place) in which I have a nestet Either monads. I'm trying to flatten the structure to get the inner monad. The documentation is very limited and I couldn't find a way to do It.
Here's an example of a nested Either monad that I would like to flatten:
Either.right(Either.right(Either.left("error")))
You may flatten such a structure with flatten:
import arrow.core.*
import arrow.typeclasses.*
val result = Either.right(Either.right(Either.left("error")))
Either.monad<String>().flatten(result)
// keep flattening until you are happy with the result
// Right(b=Left(a=error))
Or just flatMap:
import arrow.core.*
import arrow.typeclasses.*
val result = Either.right(Either.right(Either.left("error")))
result.flatMap { it.flatMap { it } }
// Left(a=error)
The fact that you ended up with such nested structure probably means that you are not using the right datatype or wrong abstraction at some point in your program as that is kind of a useless value.
If you wish to preserve the left values as indicated in your comment I think a more suitable datatype would be Validated which allows for error accumulation as demonstrated here http://arrow-kt.io/docs/datatypes/validated/
Alternatively Either#fold can help you contemplate both cases and coalesce then into whatever value you wish.
I'm assuming you already run into these where most of this stuff is explained but just in case some useful links that will help you model this with Arrow
Docs: http://arrow-kt.io/docs/datatypes/either/
Video: https://www.youtube.com/watch?v=q6HpChSq-xc
FP Error handling with Arrow: http://arrow-kt.io/docs/patterns/error_handling/
Additionally feel free to swing by our chat channels if you need a more interactive experience with the maintainers and other contributors than SO where we frequently help people of all levels learning FP and Arrow.
Gitter: https://gitter.im/arrow-kt/Lobby
Slack: https://kotlinlang.slack.com/messages/C5UPMM0A0
Cheers!

What's the difference between these two imports statement?

In Meteor 1.4, what's the difference between these two import statements in the client code and in the server code? Why?
Client code:
import { Items } from '../imports/api/items.js';
Server code:
import '../imports/api/items.js';
Both statements will execute the file given, however the first one will add Item to the scope. This can be useful if the file has many exports and you are only concerned with that single class/function/object/etc.
The second is used for side effects provided from importing it (like initializing a store or something like that; I confess I don't know much about meteor).
Mozilla has a great resource on the import statement https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import

How to make Flow understand code written for Node.js?

I'm just getting started with Flow, trying to introduce it into an existing Node codebase.
Here are two lines Flow complains about:
import Module from 'module';
const nodeVersion = Number(process.versions.node.split('.')[0]);
The warnings about these lines are, respectively:
module. Required module not found
call of method `split`. Method cannot be called on possibly null value
So it seems like Flow isn't aware of some things that are standard in a Node environment (e.g. process.versions.node is guaranteed to be a string, and there is definitely a Node builtin called module).
But then again, Flow's configuration docs suggest it's Node-aware by default. And I have plenty of other stuff like import fs from 'fs'; which does not cause any warning. So what am I doing wrong?
Module fs works as expected because Flow comes with built-in definitions for it, see declare module "fs" here: https://github.com/facebook/flow/blob/master/lib/node.js#L624
Regarding process.versions.node, you can see in the same file that the versions key is typed as a map of nullable strings, with no mention of the specific node property: versions : { [key: string] : ?string };. So you'll need to either make a PR to improve this definition, or adjust your code for the possibility of that value being null.
I guess the answer about module "module" is obvious now – there are no built-in definitions for that module in Flow in lib/node.js. You could write your own definitions, and optionally send a PR with them to the Flow team. You can also try searching github for these, someone might have done the work already.
That lib directory is very useful by the way, it has Flow definitions for DOM and other stuff as well.

Counter in Collections module Python

I've come across a really weird problem. I'm trying to use Counter function in collections module. However, I keep getting the same error message
AttributeError: 'module' object has no attribute 'Counter'
I have tried using it before and it worked fine, but now for some reason when I import "collections" module it has a very limited number of attributes.
I have tried:
import collections # when calling Counter I would then use collections.Counter()
import collections as collect # collect.Counter()
For both of those I keep getting Attribute Error.
I have also tried
from collections import Counter
And in this case I got:
ImportError: cannot import name Counter
These are all tested both in ipython interface and through a script (not importing anything else, just the collections).
Any ideas?
The Counter class was added to the module in Python 2.7. You are most likely using Python 2.6 or older. From the collections.Counter() documentation:
New in version 2.7.
On python 2.5 or 2.6, use this backport instead.
Came across the same issue while installing pandas.
Cause: Counter is only supported in python2.7 and higher and is not available in earlier versions - Counter class got added into collections package in Python 2.7.
Solution 1: As stated by Martin Pieters - use the backport.
Add counter.py at /lib64/python2.6/ - this is where the collections.py is ./lib64/python2.6/collections.py
Patch collections.py with:
from counter import Counter
Solution 2: use the backport_collections package.
Next patch (the import statement) the package you're getting exception at i.e. pandas in my case:
from backport_collections import Counter
You're probably using an old version of Python, the Counter class, as stated in the documentation was added in version 2.7.
You should use a new version of python AS python 3. You can then use this module.
Then import,
import collections
from collections import counter

Resources