Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wikipedia_article is completely bogus #18

Closed
RemyNovactive opened this issue Aug 18, 2020 · 3 comments
Closed

wikipedia_article is completely bogus #18

RemyNovactive opened this issue Aug 18, 2020 · 3 comments
Labels

Comments

@RemyNovactive
Copy link

In the search function, a piece of code create an url 'wikipedia_article'.

$collection = $wikidata->search($keyword);

This url is the simple concatenation of the domain name and the label.

        $output = $collection->map(function ($item) use ($lang) {
            $item['wikipediaArticle'] = 'https://' . $lang . '.wikipedia.org/wiki/' . rawurlencode($item['label']);
            return new SearchResult($item, $lang);
        });

But the label does not contain the differentiation information between the different results. So, sometimes they all have the same URL...

image

@freearhey
Copy link
Owner

Thank you for noticing that! I'll see what I can do about it as soon as I have some free time.

@freearhey freearhey added the bug label Aug 18, 2020
@RemyNovactive
Copy link
Author

RemyNovactive commented Aug 18, 2020

I, for one, did this to get around the problem...

    public function autocomplete($keyword, $limit = 10) : Collection
    {
        $wikidata = new Wikidata();
        $collection = $wikidata->search($keyword, 'fr', $limit);
        return $collection->map(static function (SearchResult $item) {
            $item->wikipedia_article = 'http://www.wikidata.org/entity/' . $item->id;
            return $item;
        });
   }

composer.json :
"freearhey/wikidata": "^3.5", (3.5.1)

Other than that, this bundle is great. Thanks :)

@freearhey
Copy link
Owner

I have just published an updated version of the package, hopefully this will finally solve this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants