Package: plwordnet
Polish Wordnet Python librarySimple, easy-to-use and reasonably fast library for using theSłowosieć(also known as PlWordNet) - a lexico-semantic database of the Polish language. PlWordNet can also be browsedhere.I created this library, because since version 2.9, PlWordNet cannot be easily loaded into Python (for example withnltk), as it is only provided in a customplwnxmlformat.UsageLoad wordnet from an XML file (this will take about 20 seconds), and print basic statistics.importplwordnetwn=plwordnet.load('plwordnet_4_2.xml')print(wn)Expected output:PlWordnet
  lexical units: 513410
  synsets: 353586
  relation types: 306
  synset relations: 1477849
  lexical relations: 393137Find lexical units with nameleśnyand print all relations, where where that unit is in the subject/parent position.forluinwn.lemmas('leśny'):fors,p,oinwn.lexical_relations_where(subject=lu):print(p.format(s,o))Expected output:leśny.2 tworzy kolokację z polana.1
leśny.2 jest synonimem mpar. do las.1
leśny.3 przypomina las.1
leśny.4 jest derywatem od las.1
leśny.5 jest derywatem od las.1
leśny.6 przypomina las.1Print all relation types and their ids:forid,relinwn.relation_types.items():print(id,rel.name)Expected output:10 hiponimia
11 hiperonimia
12 antonimia
13 konwersja
...See more usage examples in theexamples notebook.InstallationNote:plwordnetrequires Python 3.7 or newer.pip install plwordnetVersion supportThis library should be able to read future versions of PlWordNet without modification, even if more relation types are added. Still, if you use this library with a version of PlWordNet that is not listed below, please consider contributing information if it is supported.PlWordNet 4.2PlWordNet 4.0PlWordNet 3.2PlWordNet 3.0PlWordNet 2.3PlWordNet 2.2PlWordNet 2.1DocumentationSeeplwordnet/wordnet.pyforRelationType,SynsetandLexicalUnitclass definitions.Package functionsload(source): Reads PlWordNet, wheresrcis a path to the wordnet XML file, or a path to the pickled wordnet object. Passed paths can point to files compressed with gzip or lzma.Wordnetinstance propertieslexical_relations: List of (subject, predicate, object) triplessynset_relations: List of (subject, predicate, object) triplesrelation_types: Mapping from relation type id to objectrelation_by_name: Mapping from human readable relation name to relation idslexical_units: Mapping from lexical unit id to unit objectlexical_units_by_name: Mapping from lexical unit name to a set of matching lexical unit idssynsets: Mapping from synset id to object(lexical|synset)_relations_(s|o|p): Mapping from id of subject/object/predicate to a set of matching lexical unit/synset relation idsWordnetmethodslemmas(value): Returns a list ofLexicalUnit, where the name is equal tovaluelexical_relations_where(subject, predicate, object): Returns lexical relation triples, with matching subject or/and predicate or/and object. Subject, predicate and object arguments can be integer ids orLexicalUnitandRelationTypeobjects.synset_relations_where(subject, predicate, object): Returns synset relation triples, with matching subject or/and predicate or/and object. Subject, predicate and object arguments can be integer ids orSynsetandRelationTypeobjects.hypernyms(synset, interlingual=False): Returns hypernyms of a synset (synsetcan be an integer id or aSynsetobject)hyponyms(synset, interlingual=False): Returns hyponyms of a synset (synsetcan be an integer id or aSynsetobject)hypernym_paths(synset, full_search=False, interlingual=False): Returns a hypernym path to a synset with no hypernyms (or all possible paths iffull_search=True)dump(dst): Pickles theWordnetobject to opened filedstor to a new file with pathdst.RelationTypemethodsformat(x, y, short=False): Substitutesxandyinto theRelationTypedisplay formatdisplay. Ifshort,xandyare separated by the short relation nameshortcut.