User:Daniel Mietchen/Sandbox4URLshortening
Jump to navigation
Jump to search
This page is used in conjunction with m:Special:UrlShortener as a workaround to https://phabricator.wikimedia.org/T220703 . URL shortening can also be triggered via the MediaWiki API.
The following query uses these:
- Properties: KIT Linked Open Numbers ID (P5176) , numeric value (P1181) , title (P1476)
# Most common ngrams in titles of works that contain the string "bologna" # where the work has not been tagged as being about anything that contains that string SELECT DISTINCT ?Ngram ?Count ?Length ?CountTimesLength ?N ?ExamplePub ?ExamplePubTitle WITH { # Generating a list of regexes to look for the NumericValue-th word in a string SELECT ?Regex1 ?Regex2 ?Regex3 ?Regex4 ?NumericValue { ?NumberItem wdt:P5176 []; wdt:P1181 ?NumericValue . FILTER( ?NumericValue > 0 ) FILTER( ?NumericValue < 51) BIND( CONCAT( "^([^ ]+ ){", STR( ?NumericValue - 1 ),"}([^ ]+) .*") AS ?Regex1) BIND( CONCAT( "^([^ ]+ ){", STR( ?NumericValue + 1 ),"}([^ ]+) .*") AS ?Regex2) BIND( CONCAT( "^([^ ]+ ){", STR( ?NumericValue + 3 ),"}([^ ]+) .*") AS ?Regex3) BIND( CONCAT( "^([^ ]+ ){", STR( ?NumericValue + 5 ),"}([^ ]+) .*") AS ?Regex4) } } AS %regexes WITH { # Generating a list of titles to be analyzed SELECT ?Title ?Publication ?Seeds ?ClearTitleLength { # Choosing the entities whose titles are to be analyzed { SELECT ?Title ?Publication WHERE { hint:Query hint:optimizer "None". { SERVICE wikibase:mwapi { bd:serviceParam wikibase:api "Search"; wikibase:endpoint "www.wikidata.org"; mwapi:srsearch "virus and haswbstatement:P31=Q13442814". ?page_title wikibase:apiOutput mwapi:title. } } UNION { SERVICE wikibase:mwapi { bd:serviceParam wikibase:api "Search"; wikibase:endpoint "www.wikidata.org"; mwapi:srsearch "virus -and haswbstatement:P31=Q13442814". ?page_title wikibase:apiOutput mwapi:title. } } BIND(IRI(CONCAT(STR(wd:), ?page_title)) AS ?Publication) ?Publication wdt:P1476 ?Title. FILTER (REGEX(LCASE(?Title), "(transmi