How to get all nouns in a certain language from Wiktionary ...

文章推薦指數: 80 %
投票人數:10人

I'm trying to query Wiktionary with SPARQL to get all the terms that are nouns of a certain language (for example German) and as output:. Home Public Questions Tags Users Collectives ExploreCollectives FindaJob Jobs Companies Teams StackOverflowforTeams –Collaborateandshareknowledgewithaprivategroup. CreateafreeTeam WhatisTeams? Teams CreatefreeTeam CollectivesonStackOverflow Findcentralized,trustedcontentandcollaboratearoundthetechnologiesyouusemost. Learnmore Teams Q&Aforwork Connectandshareknowledgewithinasinglelocationthatisstructuredandeasytosearch. Learnmore HowtogetallnounsinacertainlanguagefromWiktionaryusingSPARQL AskQuestion Asked 6years,5monthsago Active 6years,5monthsago Viewed 927times 3 2 I'mtryingtoqueryWiktionarywithSPARQLtogetallthetermsthatarenounsofacertainlanguage(forexampleGerman) andasoutput: thestringofthenoun thegrammaticalgender(genus):male,female,neutral IamusingtheSPARQL-Endpoint:http://wiktionary.dbpedia.org/sparqlandIfoundanexamplebutIdidn'tfigureout howtoadaptittogettheinformationIwant. PREFIXterms: PREFIXrdfs: PREFIXdc: SELECT?sword?slang?spos?ssense?twordRes?tword?tlang FROM WHERE{ ?swordResterms:hasTranslation?twordRes. ?swordResrdfs:label?sword. ?swordResdc:language?slang. ?swordResterms:hasPoS?spos. OPTIONAL{?swordResterms:hasMeaning?ssense.} OPTIONAL{ ?twordBaseResterms:hasLangUsage?twordRes. ?twordBaseResrdfs:label?tword. } OPTIONAL{?twordResdc:language?tlang.} } sparqlwiktionary Share Improvethisquestion Follow askedJun17'15at15:26 nicole.torresnicole.torres 30722silverbadges44bronzebadges Addacomment  |  2Answers 2 Active Oldest Votes 7 Firstofall,youwanttoselectalltermsensesthatarenouns.Asyoucanseeinthequeryresultoftheexamplequery,thisinformationiscapturedbytheterms:hasPoSrelation.So,tospecificallyqueryallnouns,wecoulddothis: PREFIXterms: SELECT?term WHERE{ ?termterms:hasPoSterms:Noun. } LIMIT100 Result Thenextthingyouwantisonlynounsofacertainlanguage.Thisseemstobecoveredbythedc:languagerelation,soweaddanadditionalconstraintonthatrelation.Let'ssaywewantallEnglishnouns: PREFIXterms: PREFIXdc: SELECT?term WHERE{ ?termterms:hasPoSterms:Noun; dc:languageterms:English. } LIMIT100 Result So,wearenowselectingwhatyouwant,butwedon'tyethavetheoutputintheformatyouwant,astheabovequeryjustgivesbacktheidentifierofthetermsense,notthestring-valueoftheactualterm.Aswecanseeintheoutputfromtheexamplequery,thestringvalueiscapturedbytherdfs:labelproperty,soweaddthat: PREFIXterms: PREFIXdc: PREFIXrdfs: SELECT?term?termLabel WHERE{ ?termterms:hasPoSterms:Noun; dc:languageterms:English; rdfs:label?termLabel. } LIMIT100 Result Ifyounowlookatthisquery'sresultyou'llseethatthereissomethingoddwiththelanguagegoingon:despitethefactthatwethoughtweselectedEnglish,wearealsogettingbacklabelsthathaveadifferentlanguagetag(e.g.'@ru').Toremovetheseresultswecanrestrictourqueryfurther,andsaythatweonlywantbacklabelsinEnglish: PREFIXterms: PREFIXdc: PREFIXrdfs: SELECT?term?termLabel WHERE{ ?termterms:hasPoSterms:Noun; dc:languageterms:English; rdfs:label?termLabel. FILTER(langMatches(lang(?termLabel),"en")) } LIMIT100 Result Finally,thegender/genus.HereI'mnotreallysure.Lookingatsomeexampleresourcesinthewiktionarydata(forexample,theentryfordog)I'dsaythisinformationisnotactuallypresentinthedata. Share Improvethisanswer Follow editedJun17'15at23:59 answeredJun17'15at23:43 JeenBroekstraJeenBroekstra 20.5k44goldbadges4444silverbadges6868bronzebadges Addacomment  |  3 TheanswerfromJeenisgreatasastart.Here'sanoptionforgettingthegender. Englishdoesn'tservewellasanexamplelanguagesinceitdoesnothavegrammaticalgender.Let'stakeGerman: PREFIXterms: PREFIXdc: PREFIXrdfs: SELECT?term?termLabel WHERE{ ?termterms:hasPoSterms:Noun; dc:languageterms:German; rdfs:label?termLabel. FILTER(langMatches(lang(?termLabel),"de")) } LIMIT100 Result (Itwouldbenicetofilterthemanyexactduplicates.(Idon'tknowhow,andwhytheyarethere.)) TakingtheGermanterm"Eierkopf"insteadoftheEnglish"dog": Wecannowfollowthetermlinktohttp://wiktionary.dbpedia.org/resource/Eierkopf-German-NounwhereweseethelinktoWiktionaryinGermanhttp://de.wiktionary.org/wiki/Eierkopf(wecouldhaveguessedthatURLalso,withoutfetchingfromwiktionary.dbpedia.orgfirst). Herethegenuscanbeextractedfromthetext:"Substantiv,m"(mformasculine) TheoptionsforGermanare: m f n Ifanounhasdifferentgenderbasedontheregion/dialect,theofficialgenderisintheHTMLasabove,andacommentappearsbelow.Example: https://de.wiktionary.org/wiki/Butter SobesidesqueryingSPARQL,italsorequires1-2webpagerequestsperword,andsomeHTMLcontentextraction. Share Improvethisanswer Follow answeredJun19'15at18:14 FabianKesslerFabianKessler 7741010silverbadges1212bronzebadges Addacomment  |  YourAnswer ThanksforcontributingananswertoStackOverflow!Pleasebesuretoanswerthequestion.Providedetailsandshareyourresearch!Butavoid…Askingforhelp,clarification,orrespondingtootheranswers.Makingstatementsbasedonopinion;backthemupwithreferencesorpersonalexperience.Tolearnmore,seeourtipsonwritinggreatanswers. Draftsaved Draftdiscarded Signuporlogin SignupusingGoogle SignupusingFacebook SignupusingEmailandPassword Submit Postasaguest Name Email Required,butnevershown PostYourAnswer Discard Byclicking“PostYourAnswer”,youagreetoourtermsofservice,privacypolicyandcookiepolicy Nottheansweryou'relookingfor?Browseotherquestionstaggedsparqlwiktionaryoraskyourownquestion. TheOverflowBlog MigratingmetricsfromInfluxDBtoM3 Podcast397:Iscryptothekeytoademocratizingthemetaverse? FeaturedonMeta Reducingtheweightofourfooter UpcomingresponsiveActivitypage TwoBornottwoB-Farewell,BoltClockandBhargav! Communityinputneeded:Therulesforcollectivesarticles Visitchat Related 3 wheretodownloadmultilanguagewordlistfromWiktionary? 8 Easywaytogetwiktionarytitlesonlyinonelanguage? 0 GetURIfromresourceinResultSet 2 GetallCitiesofCountryfromDBpediausingSPARQL 1 GetallCountriesNamefromDBpediausingSPARQL 0 TranslatenounsusingSPARQLwithBabelnet 0 Getthe@languagetagfromaSPARQLrequest 0 HowtogetallinversepropertiesusingSPARQL? 0 HowtofindonlyEnglishlanguagewordsusingWiktionarysearchbox? 0 WiktionaryAPI:Gettagsforaword,andspecifylanguage HotNetworkQuestions Bangsoundandbreakerhastripped,anythingelsetocheck? Whatistherecordwordsizeforagamingsystem? WasPhilipLarkinfactuallycorrectwhenheimpliedthatin1955thestreetsinIrelandwere"end-ontohills"moreoftenthanthoseinEngland? Iaminvitedtoaconferenceasaplenaryspeaker,whopaystheexpenses? WeirdLichandLaboratoryManiacsituation,whowins? Meaningof"Overdispersion"inStatistics WhydoesmyddFullDiskCopyKeepfailingat8GB? Problemwiththesimulationoftwodifferentlow-passfilters Interviewtask:Findapotentialcustomerwhoisinterestedinaproduct "Shebuysit."inGerman Canosmiumreactwithoxygenatroomtemperature? BashRegexpatternforpasswordtoexcludespecificspecialcharacterswithnegativelookahead HowtochoosecapacitorvoltageratingforESDprotection? Givinghighlevelestimatestoclientwithoutcommitingtonumbers Whyaretherepingrepliesfromwithin172.31.0.0/16? Whenrunningabiggerwiretodealwithvoltagedropona240Vcircuit,doInowneedtorunaneutralaswell? HowcanIremovefoamboardinsulationfrombehinddrywallsoelectricalboxtabshaveclearancetograb? Iseeagreatcitywhoseglorywilltouchthestars.>>inLatin ShouldIassumedatapassedtomyfunctionisaccurate? HowcantheUKgovernmentfineitself? Whatcouldbecausingmydogtoconstantlylickherpaws? Howtogetbomb-ladendroneslongdistanceswithoutgatheringsuspicion? HowcanIobetidallyheatedwhileitisintidallock? WhenconnectingtwoAndroidphonesviaacable,howcanIchoosewhichphoneischargingwhichphone? morehotquestions Questionfeed SubscribetoRSS Questionfeed TosubscribetothisRSSfeed,copyandpastethisURLintoyourRSSreader. Yourprivacy Byclicking“Acceptallcookies”,youagreeStackExchangecanstorecookiesonyourdeviceanddiscloseinformationinaccordancewithourCookiePolicy. Acceptallcookies Customizesettings  



請為這篇文章評分?