Package: features
Features is a simple implementation offeature set algebrain Python.Linguistic analyses commonly use sets ofbinary or privative featuresto
refer to different groups of linguistic objects: for example a group ofphonemesthat share some phonological features like[-consonantal,+high]or a set ofmorphemesthat occur in context of a specific person/number
combination like[-participant,GROUP]. Usually, the features are applied in
a way such that onlysome of their combinations are valid, while others are
impossible (i.e. refer to no object) – for example[+high, +low], or[-participant,+speaker].With this package, such feature systems can be defined with a simple contingencytable definition(feature matrix) and stored under a section name in a
simple clear-textconfiguration file. Each feature system can then beloadedby its name and provides its ownFeatureSetsubclass that
implements allcomparisons and operationsbetween its feature sets according
to the given definition (compatibility, entailment, intersection, unification,
etc.).Features creates thecomplete latticestructure between the possible feature
sets of each feature system and lets you navigate andvisualize their
relationsusing theGraphviz graph layout software.LinksGitHub:https://github.com/xflr6/featuresPyPI:https://pypi.org/project/features/Documentation:https://features.readthedocs.ioChangelog:https://features.readthedocs.io/en/latest/changelog.htmlIssue Tracker:https://github.com/xflr6/features/issuesDownload:https://pypi.org/project/features/#filesInstallationThis package runs under Python 2.7 and 3.5+, usepipto install:$pipinstallfeaturesThis will also install theconceptspackage from PyPI providing theFormal
Concept Analysis(FCA) algorithms on which this package is based.QuickstartLoad apredefined feature systemby name (in this case features for a
six-way person/number distinction, cf. the definitions in the bundledconfig.iniin thesource repository).>>>importfeatures>>>fs=features.FeatureSystem('plural')>>>print(fs.context)# doctest: +ELLIPSIS<Contextobjectmapping6objectsto10properties[3011c283]at0x...>|+1|-1|+2|-2|+3|-3|+sg|+pl|-sg|-pl|1s|X|||X||X|X|||X|1p|X|||X||X||X|X||2s||X|X|||X|X|||X|2p||X|X|||X||X|X||3s||X||X|X||X|||X|3p||X||X|X|||X|X||Createfeature setsfrom strings or string sequences. Usefeature string
parsing, get back string sequences and feature or extent strings in
their canonical order (definition order):>>>fs('+1 +sg'),fs(['+2','+2','+sg']),fs(['+sg','+3'])(FeatureSet('+1 +sg'),FeatureSet('+2 +sg'),FeatureSet('+3 +sg'))>>>fs('SG1').concept.intent('+1','-2','-3','+sg','-pl')>>>fs('1').string,fs('1').string_maximal,fs('1').string_extent('+1','+1 -2 -3','1s 1p')Usefeature algebra: intersection (join) , union/unification (meet),
set inclusion (extension/subsumption). Do feature set comparisons
(logical connectives).>>>fs('+1 +sg')%fs('+2 +sg')FeatureSet('-3 +sg')>>>fs('-3')^fs('+1')^fs('-pl')FeatureSet('+1 +sg')>>>fs('+3')>fs('-1')andfs('+pl')<fs('+2 -sg')True>>>fs('+1').incompatible_with(fs('+3'))andfs('+sg').complement_of(fs('+pl'))TrueNavigate the created subsumptionlattice(Hasse graph) ofall valid
feature sets:>>>fs('+1').upper_neighbors,fs('+1').lower_neighbors([FeatureSet('-3'),FeatureSet('-2')],[FeatureSet('+1 +sg'),FeatureSet('+1 +pl')])>>>fs('+1').upset()[FeatureSet('+1'),FeatureSet('-3'),FeatureSet('-2'),FeatureSet('')]>>>forfinfs:# doctest: +ELLIPSIS...print('[%s] <-> {%s}'%(f.string_maximal,f.string_extent))[+1-1+2-2+3-3+sg+pl-sg-pl]<->{}[+1-2-3+sg-pl]<->{1s}...[-1]<->{2s2p3s3p}[]<->{1s1p2s2p3s3p}Seethe docson how to define, load, and useyour own feature systems.Further readinghttps://en.wikipedia.org/wiki/Join_and_meethttps://en.wikipedia.org/wiki/Formal_concept_analysishttp://www.upriss.org.uk/fca/See alsoconcepts– Formal Concept Analysis with Pythonfileconfig– Config file sections as objectsgraphviz– Simple Python interface for GraphvizLicenseFeatures is distributed under theMIT license.