# Resolve using https://hub.toolforge.org/

**URL:** <https://forum.openrefine.org/t/resolve-using-https-hub-toolforge-org/368>\
**Category:** Data cleaning and transformations\
**Tags:** hints-and-tips\
**Created:** [February 1, 2023, 9:48am UTC](https://forum.openrefine.org/t/resolve-using-https-hub-toolforge-org/368 "2023-02-01T09:48:38Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![salgo60](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.openrefine.org/salgo60/32/245_2.png) [@salgo60](https://forum.openrefine.org/u/salgo60)\
**Post date:** [February 1, 2023, 9:48am UTC](https://forum.openrefine.org/t/resolve-using-https-hub-toolforge-org/368/1 "2023-02-01T09:48:38Z")

</div>

If a column has the values of a Wikidata property I have used [hub.toolforge.org](https://hub.toolforge.org/) to resolve

Examples  
1: Column with value same as WD P8433

1. Hubtools --\> [https://hub.toolforge.org/P8433:G8095?format=json](https://hub.toolforge.org/P8433:G8095?format=json) --\> JSON

```auto
{
    "origin": {
         "id": "P8433:G8095",
         "value": "G8095",
         "properties": [
              "P8433"
          ],
         "qid": "Q98490206"
          },
         "destination": {
         "langs": [
         "en"
],
    "sites": [
         "wiki"
     ],
     "bestFallbackSitelink": {
     "site": "wikidatawiki",
     "title": "Q98490206",
      "score": 0.5
   },
   "url": "https://www.wikidata.org/wiki/Q98490206"
   }
}

```

1. Add column by fetching URL

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/openrefine/original/1X/ffe65726b379a75b41a566f75baff765cfc98137.png)

1. Parse the Qnumber from fetched JSON

> value.parseJson()['origin']["qid"]

---

<div class="post-metadata">

**Author:** ![Sandra](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.openrefine.org/sandra/32/74_2.png) [@Sandra](https://forum.openrefine.org/u/Sandra)\
**Post date:** [February 6, 2023, 7:47pm UTC](https://forum.openrefine.org/t/resolve-using-https-hub-toolforge-org/368/2 "2023-02-06T19:47:59Z")

</div>

Thanks for suggesting this. it has also helped me!

I did the following:

- Start with a column of bare identifiers, in my case for the Wikidata [P3638](https://www.wikidata.org/wiki/Property:P3638) property
- Edit column \> Add column by fetching URLs
- Enter `"https://hub.toolforge.org/P3638:" + value + "?format=json"` to construct the URL, enter a column name, run and wait
- Produces a new column with json, and then extract Q-ids using the following GREL: `value.parseJson()['origin']["qid"]` (note that your post above made the quotes curly, which doesn’t work)
- Reconcile Qids via Reconcile \> Use values as identifiers; choose the Wikidata reconciliation service.

If someone knows how to do this with less steps (omitting the json generating and parsing would be so awesome)?

---

<div class="post-metadata">

**Author:** ![salgo60](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.openrefine.org/salgo60/32/245_2.png) [@salgo60](https://forum.openrefine.org/u/salgo60)\
**Post date:** [February 6, 2023, 8:49pm UTC](https://forum.openrefine.org/t/resolve-using-https-hub-toolforge-org/368/3 "2023-02-06T20:49:27Z")

</div>

**Maybe it should be a feature request** → add menu option for a column to reconciliate values to Wikidata objects that has a specific property with those values…

As we today have option use _ **Use values as identifiers…** _

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/openrefine/original/1X/2ed72502b37d025062cf79471d83cdfdd86df895.png)

---

<div class="post-metadata">

**Author:** ![tfmorris](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.openrefine.org/tfmorris/32/17_2.png) [@tfmorris](https://forum.openrefine.org/u/tfmorris)\
**Post date:** [February 6, 2023, 9:48pm UTC](https://forum.openrefine.org/t/resolve-using-https-hub-toolforge-org/368/4 "2023-02-06T21:48:32Z")

</div>

> **Maybe it should be a feature request** → add menu option for a column to reconciliate values to Wikidata objects that has a specific property with those values…

That's exactly how identifier/key-based "reconciliation" used to work with Freebase, although it's not really a reconciliation operation since it can be done with a single direct lookup. A QID is just a specific instance of a strong identifier. OpenRefine should be able to do lookups against any unique strong identifier.

Tom

---

<div class="post-metadata">

**Author:** ![antonin\_d](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.openrefine.org/antonin_d/32/32_2.png) [@antonin\_d](https://forum.openrefine.org/u/antonin_d)\
**Post date:** [February 7, 2023, 6:24am UTC](https://forum.openrefine.org/t/resolve-using-https-hub-toolforge-org/368/5 "2023-02-07T06:24:52Z")

</div>

It is also possible to do it with the Wikidata reconciliation service, but the feature is very hidden: you need to first create a column of names for your entities (if you do not have names, you can input some arbitrary string as a placeholder) and then reconcile that column, with the other column of identifiers configured to match the identifier property.

There are some open issues about making that easier, such as:

> <https://github.com/OpenRefine/OpenRefine/issues/2433>
>
> Sometimes, you want to reconcile with objects no matter what their name (label) …in Wikidata is. I have therefore created an empty column and tried to reconcile to it:
> 
> \<img width="603" alt="Bez názvu" src="https://user-images.githubusercontent.com/21329813/76943122-21b9df00-68ff-11ea-8cc6-d4dea83059b3.png"\>
> 
> However, the reconciliation process fails because it is probably dependent on a non-empty string in the main field. Is it possible to somehow only reconcile based on coordinates?

---

<div class="post-metadata">

**Author:** ![thadguidry](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.openrefine.org/thadguidry/32/653_2.png) [@thadguidry](https://forum.openrefine.org/u/thadguidry)\
**Post date:** [February 7, 2023, 7:20am UTC](https://forum.openrefine.org/t/resolve-using-https-hub-toolforge-org/368/6 "2023-02-07T07:20:07Z")

</div>

@antonin_d Do you think we should document that feature under the Wikidata extension docs? Seems like it’s begging for a new section heading perhaps called “Reconciling objects no matter their name” or something more appropriate on this page [Reconciling with Wikibase | OpenRefine](https://openrefine.org/docs/manual/wikibase/reconciling) ?

---

<div class="post-metadata">

**Author:** ![antonin\_d](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.openrefine.org/antonin_d/32/32_2.png) [@antonin\_d](https://forum.openrefine.org/u/antonin_d)\
**Post date:** [February 7, 2023, 7:34am UTC](https://forum.openrefine.org/t/resolve-using-https-hub-toolforge-org/368/7 "2023-02-07T07:34:48Z")

</div>

Yes that would make sense.

---

<div class="post-metadata">

**Author:** ![thadguidry](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.openrefine.org/thadguidry/32/653_2.png) [@thadguidry](https://forum.openrefine.org/u/thadguidry)\
**Post date:** [February 7, 2023, 7:50am UTC](https://forum.openrefine.org/t/resolve-using-https-hub-toolforge-org/368/8 "2023-02-07T07:50:52Z")

</div>

@antonin_d Great, if you could quickly just type up a paragraph, then I can review and add more to it. The reason I’m asking you first, is that I would do it myself, but I am struggling a bit to actually understand the workflow steps you mentioned above. Perhaps it’s just me being blind still to the “ **no name** entities” problem itself. Or maybe it should be called “ **missing name** entities”. Dunno.

---

<div class="post-metadata">

**Author:** ![abbe98](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.openrefine.org/abbe98/32/1299_2.png) [@abbe98](https://forum.openrefine.org/u/abbe98)\
**Post date:** [February 7, 2023, 11:13am UTC](https://forum.openrefine.org/t/resolve-using-https-hub-toolforge-org/368/9 "2023-02-07T11:13:52Z")

</div>

One feature I have been thinking of is the ability to “Add column by fetching destination URL”(final URL in a redirect chain). While this type of use case might not be its primary use case I could see it being useful here too.

The main use case I imagine would be to just update redirected URLs.

---

<div class="post-metadata">

**Author:** ![tfmorris](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.openrefine.org/tfmorris/32/17_2.png) [@tfmorris](https://forum.openrefine.org/u/tfmorris)\
**Post date:** [February 7, 2023, 7:58pm UTC](https://forum.openrefine.org/t/resolve-using-https-hub-toolforge-org/368/10 "2023-02-07T19:58:09Z")

</div>

> One feature I have been thinking of is the ability to “Add column by fetching destination URL”(final URL in a redirect chain). While this type of use case might not be its primary use case I could see it being useful here too.
> 
> The main use case I imagine would be to just update redirected URLs.

So you want the resolved destination URL, not its contents? Please create a feature request in the issue tracker. It seems like perhaps this could be generalized to return all headers, not just the `Location:` header, maybe using the HEAD verb instead of GET to make it more lightweight.

Tom

---

<div class="post-metadata">

**Author:** ![thadguidry](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.openrefine.org/thadguidry/32/653_2.png) [@thadguidry](https://forum.openrefine.org/u/thadguidry)\
**Post date:** [February 11, 2023, 2:56pm UTC](https://forum.openrefine.org/t/resolve-using-https-hub-toolforge-org/368/11 "2023-02-11T14:56:46Z")

</div>

@abbe98 There are several examples of how to get Redirect info using Python  
[Github search with ‘Python and HTTPRedirectHandler’](https://github.com/search?l=Python&p=2&q=HTTPRedirectHandler&type=Code)

Here’s just one snippet I hacked up and used in Expression editor with Jython that is semi-working, but I leave it as an exercise to get it working fully 🙂

```auto
import urllib2

class RedirectHandler(urllib2.HTTPRedirectHandler):
    def http_error_302(self, req, fp, code, msg, headers):

        result = urllib2.HTTPError(req.get_full_url(), code, msg, headers, fp)
        result.status = code
        return result
    http_error_301 = http_error_303 = http_error_307 = http_error_302

opener = urllib2.build_opener(RedirectHandler())
webpage = opener.open('https://openrefine.org')

return opener

```

---

<div class="post-metadata">

**Author:** ![abbe98](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.openrefine.org/abbe98/32/1299_2.png) [@abbe98](https://forum.openrefine.org/u/abbe98)\
**Post date:** [February 12, 2023, 3:36pm UTC](https://forum.openrefine.org/t/resolve-using-https-hub-toolforge-org/368/12 "2023-02-12T15:36:12Z")

</div>

@thadguidry yeah I have such a solution but I could imagine the use-case being common enough to be in core.
