ó <¿CVc @ sdZddlmZmZmZddlZddlZddlmZm Z ddl m Z m Z m Z mZmZddlmZmZmZmZmZede fd„ƒYƒZd Zd Zd d „Zed eefd„ƒYƒZdeefd„ƒYZdd„Zd„Zdd„Z d„Z!dd„Z"d„Z#e$fe$dd„Z%d„Z&d„Z'dd„Z(d„Z)ede*fd„ƒYƒZ+e+ƒZ,e$e-e$e.dd„Z/d e0fd!„ƒYZ1d"„Z2d#„Z3d$„Z4d%„Z5d&„Z6d'„Z7d(„Z8d)„Z9d*„Z:d+„Z;d,„Z<d-„Z=d.d/„Z>d0„Z?d1„Z@d2„ZAd3e fd4„ƒYZBed5eBeCfd6„ƒYƒZDed7eBeEfd8„ƒYƒZFed9eBeEfd:„ƒYƒZGed;eBeCfd<„ƒYƒZHd=„ZIeed>e*fd?„ƒYƒƒZJd@eJfdA„ƒYZKdBeJfdC„ƒYZLeKdDdEe-dFdDƒZMeJdGdFdHƒZNedIe*fdJ„ƒYƒZOdKe*fdL„ƒYZPdMdN„ZQe-dO„ZRe-dP„ZSeTdQkrìeSƒndRdSdTdUdVdWdXdYdZd[d\d]g ZUdS(^uY Basic data classes for representing feature structures, and for performing basic operations on those feature structures. A feature structure is a mapping from feature identifiers to feature values, where each feature value is either a basic value (such as a string or an integer), or a nested feature structure. There are two types of feature structure, implemented by two subclasses of ``FeatStruct``: - feature dictionaries, implemented by ``FeatDict``, act like Python dictionaries. Feature identifiers may be strings or instances of the ``Feature`` class. - feature lists, implemented by ``FeatList``, act like Python lists. Feature identifiers are integers. Feature structures are typically used to represent partial information about objects. A feature identifier that is not mapped to a value stands for a feature whose value is unknown (*not* a feature without a value). Two feature structures that represent (potentially overlapping) information about the same object can be combined by unification. When two inconsistent feature structures are unified, the unification fails and returns None. Features can be specified using "feature paths", or tuples of feature identifiers that specify path through the nested feature structures to a value. Feature structures may contain reentrant feature values. A "reentrant feature value" is a single feature value that can be accessed via multiple feature paths. Unification preserves the reentrance relations imposed by both of the unified feature structures. In the feature structure resulting from unification, any modifications to a reentrant feature value will be visible using any of its feature paths. Feature structure variables are encoded using the ``nltk.sem.Variable`` class. The variables' values are tracked using a bindings dictionary, which maps variables to their values. When two feature structures are unified, a fresh bindings dictionary is created to track their values; and before unification completes, all bound variables are replaced by their values. Thus, the bindings dictionaries are usually strictly internal to the unification process. However, it is possible to track the bindings of variables if you choose to, by supplying your own initial bindings dictionary to the ``unify()`` function. When unbound variables are unified with one another, they become aliased. This is encoded by binding one variable to the other. Lightweight Feature Structures ============================== Many of the functions defined by ``nltk.featstruct`` can be applied directly to simple Python dictionaries and lists, rather than to full-fledged ``FeatDict`` and ``FeatList`` objects. In other words, Python ``dicts`` and ``lists`` can be used as "light-weight" feature structures. >>> from nltk.featstruct import unify >>> unify(dict(x=1, y=dict()), dict(a='a', y=dict(b='b'))) # doctest: +SKIP {'y': {'b': 'b'}, 'x': 1, 'a': 'a'} However, you should keep in mind the following caveats: - Python dictionaries & lists ignore reentrance when checking for equality between values. But two FeatStructs with different reentrances are considered nonequal, even if all their base values are equal. - FeatStructs can be easily frozen, allowing them to be used as keys in hash tables. Python dictionaries and lists can not. - FeatStructs display reentrance in their string representations; Python dictionaries and lists do not. - FeatStructs may *not* be mixed with Python dictionaries and lists (e.g., when performing unification). - FeatStructs provide a number of useful methods, such as ``walk()`` and ``cyclic()``, which are not available for Python dicts and lists. In general, if your feature structures will contain any reentrances, or if you plan to use them as dictionary keys, it is strongly recommended that you use full-fledged ``FeatStruct`` objects. iÿÿÿÿ(tprint_functiontunicode_literalstdivisionN(tread_strtraise_unorderable_types(tVariablet ExpressiontSubstituteBindingsIt LogicParsertLogicalExpressionException(t string_typest integer_typesttotal_orderingtpython_2_unicode_compatiblet unicode_reprt FeatStructcB sFeZdZeZd d„Zd„Zd„Zd„Z ed„Z d„Z d„Z d„Z d „Zd „Zd „Zd Zd „Zd„Zd„Zed„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd d!d d„Zd„Z d ed ed„Z!d„Z"d„Z#d„Z$RS("uô A mapping from feature identifiers to feature values, where each feature value is either a basic value (such as a string or an integer), or a nested feature structure. There are two types of feature structure: - feature dictionaries, implemented by ``FeatDict``, act like Python dictionaries. Feature identifiers may be strings or instances of the ``Feature`` class. - feature lists, implemented by ``FeatList``, act like Python lists. Feature identifiers are integers. Feature structures may be indexed using either simple feature identifiers or 'feature paths.' A feature path is a sequence of feature identifiers that stand for a corresponding sequence of indexing operations. In particular, ``fstruct[(f1,f2,...,fn)]`` is equivalent to ``fstruct[f1][f2]...[fn]``. Feature structures may contain reentrant feature structures. A "reentrant feature structure" is a single feature structure object that can be accessed via multiple feature paths. Feature structures may also be cyclic. A feature structure is "cyclic" if there is any feature path from the feature structure to itself. Two feature structures are considered equal if they assign the same values to all features, and have the same reentrancies. By default, feature structures are mutable. They may be made immutable with the ``freeze()`` method. Once they have been frozen, they may be hashed, and thus used as dictionary keys. cK sñ|tkrÑ|dkr(tjt|St|ƒrGtjt||S|r\tdƒ‚nt|tƒr¦tj j |ƒrtjt||St jt ||Sqít |ƒrÂt jt |ƒStdƒ‚nt t|ƒj|||SdS(uæ Construct and return a new feature structure. If this constructor is called directly, then the returned feature structure will be an instance of either the ``FeatDict`` class or the ``FeatList`` class. :param features: The initial feature values for this feature structure: - FeatStruct(string) -> FeatStructReader().read(string) - FeatStruct(mapping) -> FeatDict(mapping) - FeatStruct(sequence) -> FeatList(sequence) - FeatStruct() -> FeatDict() :param morefeatures: If ``features`` is a mapping or None, then ``morefeatures`` provides additional features for the ``FeatDict`` constructor. uLKeyword arguments may only be specified if features is None or is a mapping.u&Expected string or mapping or sequenceN(RtNonetFeatDictt__new__t _is_mappingt TypeErrort isinstanceR tFeatStructReadert_START_FDICT_REtmatchtFeatListt _is_sequencetsuper(tclstfeaturest morefeatures((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyR–s     cC s tƒ‚dS(uNReturn an iterable of the feature identifiers used by this FeatStruct.N(tNotImplementedError(tself((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyt_keysÈscC s tƒ‚dS(uUReturn an iterable of the feature values directly defined by this FeatStruct.N(R(R ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyt_valuesÍscC s tƒ‚dS(u³Return an iterable of (fid,fval) pairs, where fid is a feature identifier and fval is the corresponding feature value, for all features defined by this FeatStruct.N(R(R ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyt_itemsÒscC s"|j||tƒtƒtƒƒS(uB Return True if ``self`` and ``other`` assign the same value to to every feature. In particular, return true if ``self[p]==other[p]`` for every feature path *p* such that ``self[p]`` or ``other[p]`` is a base value (i.e., not a nested feature structure). :param check_reentrance: If True, then also return False if there is any difference between the reentrances of ``self`` and ``other``. :note: the ``==`` is equivalent to ``equal_values()`` with ``check_reentrance=True``. (t_equaltset(R tothertcheck_reentrance((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyt equal_valuesÜscC s"|j|ttƒtƒtƒƒS(u Return true if ``self`` and ``other`` are both feature structures, assign the same values to all features, and contain the same reentrances. I.e., return ``self.equal_values(other, check_reentrance=True)``. :see: ``equal_values()`` (R$tTrueR%(R R&((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyt__eq__ìs cC s ||k S(N((R R&((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyt__ne__÷scC s?t|tƒs%|jj|jjkSt|ƒt|ƒkSdS(N(RRt __class__t__name__tlen(R R&((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyt__lt__úscC sT|jstdƒ‚ny |jSWn*tk rO|jtƒƒ|_|jSXdS(uu If this feature structure is frozen, return its hash value; otherwise, raise ``TypeError``. u5FeatStructs must be frozen before they can be hashed.N(t_frozenRt_hashtAttributeErrort_calculate_hashvalueR%(R ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyt__hash__s   c C s†||krtS|j|jkr&tSt|ƒt|ƒkrBtSt|jƒƒt|jƒƒkrjtS|r³t|ƒ|ks”t|ƒ|krÕt|ƒt|ƒf|kSn"t|ƒt|ƒf|krÕtS|jt|ƒƒ|jt|ƒƒ|jt|ƒt|ƒfƒxe|jƒD]W\}}||}t |t ƒrn|j |||||ƒs~tSq'||kr'tSq'WtS(uÐ Return True iff self and other have equal values. :param visited_self: A set containing the ids of all ``self`` feature structures we've already visited. :param visited_other: A set containing the ids of all ``other`` feature structures we've already visited. :param visited_pairs: A set containing ``(selfid, otherid)`` pairs for all pairs of feature structures we've already visited. ( R)R,tFalseR.R%R!tidtaddR#RRR$( R R&R't visited_selft visited_othert visited_pairstfnamet self_fvalt other_fval((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyR$s4 $$    cC s¿t|ƒ|krdS|jt|ƒƒd}x‰t|jƒƒD]u\}}|d9}|t|ƒ7}|d9}t|tƒr—||j|ƒ7}n|t|ƒ7}t|d@ƒ}qBW|S(ué Return a hash value for this feature structure. :require: ``self`` must be frozen. :param visited: A set containing the ids of all feature structures we've already visited while hashing. iiÇi%iÿÿÿ( R6R7tsortedR#thashRRR3tint(R tvisitedthashvalR;tfval((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyR3Ms  u'Frozen FeatStructs may not be modified.cC s!|jr dS|jtƒƒdS(u Make this feature structure, and any feature structures it contains, immutable. Note: this method does not attempt to 'freeze' any feature value that is not a ``FeatStruct``; it is recommended that you use only immutable feature values. N(R0t_freezeR%(R ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pytfreezems cC s|jS(u$ Return True if this feature structure is immutable. Feature structures can be made immutable with the ``freeze()`` method. Immutable feature structures may not be made mutable again, but new mutable copies can be produced with the ``copy()`` method. (R0(R ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pytfrozenwscC sxt|ƒ|krdS|jt|ƒƒt|_x?t|jƒƒD]+\}}t|tƒrE|j|ƒqEqEWdS(uæ Make this feature structure, and any feature structure it contains, immutable. :param visited: A set containing the ids of all feature structures we've already visited while freezing. N( R6R7R)R0R>R#RRRD(R RAR;RC((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRD€s cC s$|rtj|ƒS|j|ƒSdS(u² Return a new copy of ``self``. The new copy will not be frozen. :param deep: If true, create a deep copy; if false, create a shallow copy. N(tcopytdeepcopyR,(R tdeep((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRG“s cC s tƒ‚dS(N(R(R tmemo((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyt __deepcopy__¡scC s|jiƒt|ƒS(uH Return True if this feature structure contains itself. (t_find_reentrancesR6(R ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pytcyclic¨scC s|jtƒƒS(u» Return an iterator that generates this feature structure, and each feature structure it contains. Each feature structure will be generated exactly once. (t_walkR%(R ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pytwalk®scC s tƒ‚dS(uù Return an iterator that generates this feature structure, and each feature structure it contains. :param visited: A set containing the ids of all feature structures we've already visited while freezing. N(R(R RA((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRN¶scc szt|ƒ|krdS|jt|ƒƒ|VxE|jƒD]7}t|tƒr;x|j|ƒD] }|Vq`Wq;q;WdS(N(R6R7R"RRRN(R RARCtelt((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRNÀscC sot|ƒ|kr%t|t|ƒ| r>t |t ƒr+d|j }q+dt |ƒ}qpt |t ƒrj|jd ||j fƒqp|tkrŠ|jd |ƒqp|tkrª|jd |ƒqpt |tƒrÓ|jd ||fƒqpt |tƒs|jd |t |ƒfƒqp|j||ƒ} |jd || fƒqpW|t|ƒr\d |t|ƒ|f}nd|dj|ƒ|fS(Nuiudisplayu%s->(%s)uprefixu%suslashu/%su%s=%su+%su-%su%s=<%s>u(%s)%su%s[%s]%su, (R6tAssertionErrortreprR.R>R†tgetattrRtappendRRR tnameRR)R5RRRaR‹( R RQRctsegmentstprefixtsuffixR;RCtdisplayt fval_repr((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRaâsB#     cC sk|t|ƒrKt|ƒ|ks(t‚tt|ƒdƒ|t|ƒ)su%su%s = %su %s = <%s>u %s -> (%s)iÿÿÿÿuu iiu =cs s|]}t|ƒVqdS(N(R.(R˜tline((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pys ]su[ %s%s ]u(%s) (R6RŽRR.tmaxR‰R>R†tljustRRR‘R’RRRaRRRŒtpop(R RQRct maxfnamelentlinesR;RCR—t fval_linestltnamelinetmaxlenRštidstrtidline((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRŒsP#   $%  1'N(R-RdReRRqtstrRxRtR}R~RR€R‚RnRstclearRtpopitemt setdefaultRpRKR!R"R#RRaRŒ(((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyR<s*              ,RcB sïeZdZd d„ZdZd„Zd„Zd„Zee j ƒZ ee j ƒZ ee j ƒZ ee j ƒZ ee jƒZee jƒZee jƒZee jƒZee jƒZd„Zd„Zd„Zd „Zd „ZRS( uy A list of feature values, where each feature value is either a basic value (such as a string or an integer), or a nested feature structure. Feature lists may contain reentrant feature values. A "reentrant feature value" is a single feature value that can be accessed via multiple feature paths. Feature lists may also be cyclic. Two feature lists are considered equal if they assign the same values to all features, and have the same reentrances. :see: ``FeatStruct`` for information about feature paths, reentrance, cyclic feature structures, mutability, freezing, and hashing. cC s9t|tƒr%tƒj||ƒntj||ƒdS(uZ Create a new feature list, with the specified features. :param features: The initial list of features for this feature list. If ``features`` is a string, then it is paresd using ``FeatStructReader``. Otherwise, it should be a sequence of basic values and nested feature structures. N(RR RRotlistRq(R R((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRq~s u&Expected int or feature path. Got %r.cC s¯t|tƒrtj||ƒSt|tƒr˜yA|}x0|D](}t|tƒs\t‚n||}q>W|SWq«ttfk r”t|ƒ‚q«Xnt|j |ƒ‚dS(N( RR RªRtRuRRvRwRRx(R RyRzR{((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRt‘s  cC s¾|jrttƒ‚nt|ttfƒr=tj||ƒSt|tƒr§t |ƒdkrmtdƒ‚qº||d }t|t ƒs™t |ƒ‚n||d=nt |j |ƒ‚dS(ukIf the feature with the given name or path exists, delete its value; otherwise, raise ``KeyError``.iuThe path () can not be setiÿÿÿÿN(R0RgRfRR tsliceRªR€RuR.RRvRRx(R RyR((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyR€¡s cC sÄ|jrttƒ‚nt|ttfƒr@tj|||ƒSt|tƒr­t |ƒdkrptdƒ‚qÀ||d }t|t ƒsœt |ƒ‚n|||dÖs(R,R6textend(R RJRˆ((RJsa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRKÔscC sttt|ƒƒƒS(N(RªtrangeR.(R ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyR!ÝscC s|S(N((R ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyR"ÞscC s t|ƒS(N(t enumerate(R ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyR#ßscC sJ|t|ƒr_t|ƒ|ks(t‚tt|ƒdƒ|t|ƒ(%s)u%su%s[%s]u, ( R6RŽRR.R‘RRR’RRRaRR‹(R RQRcR”R“RC((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRaæs"  ((R-RdReRqRxRtR€R‚RnRªt__iadd__t__imul__R‘R¬tinsertRtremovetreversetsortRKR!R"R#Ra(((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRns(       udefaultcC sD|dkrt|ƒ}ntj|ƒ}t|||tƒƒ|S(u¸ Return the feature structure that is obtained by replacing each variable bound by ``bindings`` with its binding. If a variable is aliased to a bound variable, then it will be replaced by that variable's value. If a variable is aliased to an unbound variable, then it will be replaced by that variable. :type bindings: dict(Variable -> any) :param bindings: A dictionary mapping from variables to values. udefault(t_default_fs_classRGRHt_substitute_bindingsR%(tfstructRStfs_class((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRRs cC st|ƒ|krdS|jt|ƒƒt|ƒrD|jƒ}n't|ƒr_t|ƒ}n tdƒ‚x’|D]Š\}}x1t|tƒr±||kr±||}||2s(RµRGRHRpRsR†t_retract_bindingsR%(R·RSR¸t new_bindingst inv_bindings((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRT#s  cC sÔt|ƒ|krdS|jt|ƒƒt|ƒrD|jƒ}n't|ƒr_t|ƒ}n tdƒ‚xb|D]Z\}}t||ƒrrt|ƒ|kr¶|t|ƒ|| Variable) :param new_vars: A dictionary that is used to hold the mapping from old variables to new variables. For each variable *v* in this feature structure: - If ``new_vars`` maps *v* to *v'*, then *v* will be replaced by *v'*. - If ``new_vars`` does not contain *v*, but ``vars`` does contain *v*, then a new entry will be added to ``new_vars``, mapping *v* to the new variable that is used to replace it. To consistently rename the variables in a set of feature structures, simply apply rename_variables to each one, using the same dictionary: >>> from nltk.featstruct import FeatStruct >>> fstruct1 = FeatStruct('[subj=[agr=[gender=?y]], obj=[agr=[gender=?y]]]') >>> fstruct2 = FeatStruct('[subj=[agr=[number=?z,gender=?y]], obj=[agr=[number=?z,gender=?y]]]') >>> new_vars = {} # Maps old vars to alpha-renamed vars >>> fstruct1.rename_variables(new_vars=new_vars) [obj=[agr=[gender=?y2]], subj=[agr=[gender=?y2]]] >>> fstruct2.rename_variables(new_vars=new_vars) [obj=[agr=[gender=?y2, number=?z2]], subj=[agr=[gender=?y2, number=?z2]]] If new_vars is not specified, then an empty dictionary is used. udefaultN(RµRRUR%tuniont_rename_variablesRGRH(R·RXRYRZR¸((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRW]s+    c C sœt|ƒ|krdS|jt|ƒƒt|ƒrD|jƒ}n't|ƒr_t|ƒ}n tdƒ‚x*|D]"\}}t|tƒrî||krª||||>> from nltk.featstruct import FeatStruct >>> FeatStruct('[a=?x]').unify(FeatStruct('[b=?x]')) [a=?x, b=?x2] :type bindings: dict(Variable -> any) :param bindings: A set of variable bindings to be used and updated during unification. :type trace: bool :param trace: If true, generate trace output. :type rename_vars: bool :param rename_vars: If True, then rename any variables in ``fstruct2`` that are also used in ``fstruct1``, in order to avoid collisions on variable names. udefaultuGMixing FeatStruct objects with Python dicts and lists is not supported.N((((((RµRgRRŽRRGRHRpRUR¿R%t_trace_unify_startt_destructively_unifyt_UnificationFailureErrortUnificationFailuret_apply_forwardst_apply_forwards_to_bindingst_resolve_aliasesR¶t_trace_unify_succeedt_trace_bindings(tfstruct1tfstruct2RSR]R^R_R¸t user_bindingst fstruct1copyt fstruct2copyt bindings_copytvars1tvars2tforwardtresult((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyR\ésJ.    !      RÈcB seZdZRS(umAn exception that is used by ``_destructively_unify`` to abort unification when a failure is encountered.(R-RdRe(((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRÈNsc C s||kr&|r"t||ƒn|S||t|ƒR†t_unify_feature_valuesRR.RÉR­R( RÏRÐRSR×R]R^R¸tpathR;tfval2tfindex((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRÇRs>    #$c C s·|rt|||ƒnx&t|ƒ|krA|t|ƒ}qWx&t|ƒ|krj|t|ƒ}qEWd} } x/t|tƒr¦||kr¦|} ||}qxWx/t|tƒrØ||krØ|} ||}qªWt||ƒrt||ƒrt||||||||ƒ} nÔt|tƒr[t|tƒr[||krR|||Fsu u| iu|u| Unify feature: %su / u|\ ((tprintR‹R.t_trace_valrepr(RÛRáRÜtfullname((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRÆBs   $&cC s~tddt|ƒdƒtddt|ƒdƒtddt|ƒdƒtddt|ƒdt|ƒƒdS(Nu u| u|u| (identical objects)u+-->(RåR.R(RÛRá((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRÙKscC s[|tkrd}nd}tddt|ƒdƒtddt|ƒd|ƒdS(Nuu (nonfatal)u u| u| |uX uX X <-- FAIL(RÉRåR.(RÛRØtresume((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRàPs  cC sFtddt|ƒdƒtddt|ƒdt|ƒƒdS(Nu u| u|u+-->(RåR.R(RÛRá((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRÍUscC sqt|ƒdkrmt|jƒdd„ƒ}ddjd„|Dƒƒ}tddt|ƒd |ƒndS( NiR‡cS s |djS(Ni(R’(tv((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyt\su{%s}u, cs s+|]!\}}d|t|ƒfVqdS(u%s: %sN(Ræ(R˜R¹Rz((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pys ^su u| u Bindings: (R.R>R†R‹Rå(RÛRSt binditemstbindstr((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRÎYs  cC s)t|tƒrd|Sdt|ƒSdS(Nu%s(RRR(Rz((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRæascC s|t||ƒkS(uÏ Return True if ``fstruct1`` subsumes ``fstruct2``. I.e., return true if unifying ``fstruct1`` with ``fstruct2`` would result in a feature structure equal to ``fstruct2.`` :rtype: bool (R\(RÏRÐ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyR`gsic s2g‰‡fd†}t||d|d|ƒˆS(u¢ Return a list of the feature paths of all features which are assigned incompatible values by ``fstruct1`` and ``fstruct2``. :rtype: list(tuple) c sˆj|ƒ|S(N(R‘(RáRÜRÛ(t conflict_list(sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyt add_conflictys R^R](R\(RÏRÐR]Rî((Rísa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyt conflictsqscC st|dƒot|dƒS(Nu __contains__ukeys(R„(Ré((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRƒscC s,t|dƒo+t|dƒo+t|tƒ S(Nu__iter__u__len__(R„RR (Ré((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyR†scC sLt|tƒrtSt|ttfƒr2ttfStd|jjƒ‚dS(NuBTo unify objects of type %s, you must specify fs_class explicitly.(RRRsRªRgR,R-(tobj((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRµŠs  tSubstituteBindingsSequencecB s)eZdZd„Zd„Zd„ZRS(u‚ A mixin class for sequence clases that distributes variables() and substitute_bindings() over the object's elements. cC sag|D]}t|tƒr|^qtg|D]'}t|tƒr/t|jƒƒ^q/gƒS(N(RRtsumRRªRV(R RP((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRV™s%cC s,|jg|D]}|j||ƒ^q ƒS(N(R,tsubst(R RSRé((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRRžscC s0t|tƒr|j|ƒS|j||ƒSdS(N(RRRRR}(R RéRS((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRó¡s (R-RdReRVRRRó(((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRñ”s  tFeatureValueTuplecB seZdZd„ZRS(u A base feature value that is a tuple of other base feature values. FeatureValueTuple implements ``SubstituteBindingsI``, so it any variable substitutions will be propagated to the elements contained by the set. A ``FeatureValueTuple`` is immutable. cC s1t|ƒdkrdSddjd„|DƒƒS(Niu()u(%s)u, cs s|]}d|fVqdS(u%sN((R˜tb((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pys ±s(R.R‹(R ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRb¯s(R-RdReRb(((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRô§stFeatureValueSetcB seZdZd„ZeZRS(u  A base feature value that is a set of other base feature values. FeatureValueSet implements ``SubstituteBindingsI``, so it any variable substitutions will be propagated to the elements contained by the set. A ``FeatureValueSet`` is immutable. cC s7t|ƒdkrdSddjtd„|DƒƒƒS(Niu{/}u{%s}u, cs s|]}d|fVqdS(u%sN((R˜Rõ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pys Às(R.R‹R>(R ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRb¼s(R-RdReRbR(((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRö´s tFeatureValueUnioncB s eZdZd„Zd„ZRS(up A base feature value that represents the union of two or more ``FeatureValueSet`` or ``Variable``. cC stt|tƒ}td„|DƒƒdkrDt|tƒ}t|ƒSt|ƒdkrdt|ƒdStj||ƒS(Ncs s|]}t|tƒVqdS(N(RR(R˜Ré((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pys Ïsii(t_flattenR÷RòRöR.Rªt frozensetR(RRŠ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRÉs cC s!ddjtd„|DƒƒƒS(Nu{%s}u+cs s|]}d|fVqdS(u%sN((R˜Rõ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pys Þs(R‹R>(R ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRbÚs(R-RdReRRb(((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyR÷Ãs tFeatureValueConcatcB s eZdZd„Zd„ZRS(uz A base feature value that represents the concatenation of two or more ``FeatureValueTuple`` or ``Variable``. cC stt|tƒ}td„|DƒƒdkrDt|tƒ}t|ƒSt|ƒdkrdt|ƒdStj||ƒS(Ncs s|]}t|tƒVqdS(N(RR(R˜Ré((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pys ìsii(RøRúRòRôR.RªRuR(RRŠ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRæs cC sddjd„|DƒƒS(Nu(%s)u+cs s|]}d|fVqdS(u%sN((R˜Rõ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pys ùs(R‹(R ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRb÷s(R-RdReRRb(((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRúàs cC sGg}x:|D]2}t||ƒr2|j|ƒq |j|ƒq W|S(u} Helper function -- return a copy of list, with all elements of type ``cls`` spliced in rather than appended in. (RR¬R‘(tlstRRØRP((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRøüs  RrcB s‰eZdZd d d„Zed„ƒZed„ƒZed„ƒZd„Z d„Z d„Z d„Z d „Z d „Zd „ZRS( ui A feature identifier that's specialized to put additional constraints, default values, etc. cC s‹|dkst‚||_||_||_|jdkrQd|jf|_n6|jdkrud|jf|_nd|jf|_dS(Nuprefixuslashiÿÿÿÿii(Nuprefixuslash(RRŽt_namet_defaultt_displayt_sortkey(R R’R|R–((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRqs   cC s|jS(uThe name of this feature.(Rü(R ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyR’ scC s|jS(uDefault value for this feature.(Rý(R ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyR|%scC s|jS(u1Custom display location: can be prefix, or slash.(Rþ(R ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyR–*scC s d|jS(Nu*%s*(R’(R ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRb/scC sEt|tƒrtSt|tƒs5td||ƒn|j|jkS(Nu<(RR R)RrRRÿ(R R&((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyR/2s cC s(t|ƒt|ƒko'|j|jkS(N(ttypeRü(R R&((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyR*9scC s ||k S(N((R R&((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyR+<scC s t|jƒS(N(R?Rü(R ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyR4?scC s|j|||ƒS(N(t read_value(R tstpositionRQtparser((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRFscC s||kr|StSdS(up If possible, return a single value.. If not, return the value ``UnificationFailure``. N(RÉ(R RáRÜRS((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRÞIs N(R-RdReRRqtpropertyR’R|R–RbR/R*R+R4RRÞ(((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRr s      t SlashFeaturecB seZd„ZRS(cC s|j|||ƒS(N(t read_partial(R RRRQR((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRSs(R-RdR(((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRRst RangeFeaturecB s)eZejdƒZd„Zd„ZRS(u(-?\d+):(-?\d+)cC sa|jj||ƒ}|s-td|ƒ‚nt|jdƒƒt|jdƒƒf|jƒfS(Nurangeii(tRANGE_RERRgR@tgrouptend(R RRRQRtm((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRXscC sj|dkr|S|dkr |St|d|dƒt|d|dƒf}|d|dkrftS|S(Nii(RR›tminRÉ(R RáRÜRStrng((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRÞ]s  .(R-RdRÁtcompileR RRÞ(((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRVs uslashR|R–utypeuprefixRßcB s;eZdZd„Zd„Zd„Zd„Zd„ZRS(uî An abstract base class for base values that define a custom unification method. The custom unification method of ``CustomFeatureValue`` will be used during unification if: - The ``CustomFeatureValue`` is unified with another base value. - The ``CustomFeatureValue`` is not the value of a customized ``Feature`` (which defines its own unification method). If two ``CustomFeatureValue`` objects are unified with one another during feature structure unification, then the unified base values they return *must* be equal; otherwise, an ``AssertionError`` will be raised. Subclasses must define ``unify()``, ``__eq__()`` and ``__lt__()``. Subclasses may also wish to define ``__hash__()``. cC stdƒ‚dS(uŽ If this base value unifies with ``other``, then return the unified value. Otherwise, return ``UnificationFailure``. uabstract base classN(R(R R&((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyR\~scC stdƒ‚dS(Nuabstract base class(R(R R&((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyR*…scC s ||k S(N((R R&((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyR+ˆscC stdƒ‚dS(Nuabstract base class(R(R R&((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyR/‹scC std|jjƒ‚dS(Nu%s objects or unhashable(RR,R-(R ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyR4Žs(R-RdReR\R*R+R/R4(((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRßks     Rc B sIeZeefeed3d„Zd3d„Ze j dƒZ e j dƒZ e j dƒZ e j dƒZe j dƒZe j dƒZe j dƒZe j d ƒZe j d ƒZe j d eje jejejfƒZd d3d3d „Zd3d„Zd„Zd„Zd„Zd„Zd„Zd„Zde fde j dƒfde j dƒfde j dƒfde j dƒfde j dƒfd e j d!ƒfd"e j d#ƒfd$e j d%ƒfg Zd&„Zd'„Z d(„Z!d)„Z"id3d*6e#d+6e$d,6Z%d-„Z&d.„Z'd/„Z(d0„Z)d1„Z*d2„Z+RS(4cC std„|Dƒƒ|_||_||_d|_d|_xt|D]l}|jdkr}|jrqtdƒ‚n||_n|jdkrD|jr¤tdƒ‚n||_qDqDWg|D]}|j dk r»|^q»|_ |dkr÷t ƒ}n||_ dS(Ncs s|]}|j|fVqdS(N(R’(R˜tf((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pys ˜suslashu"Multiple features w/ display=slashuprefixu#Multiple features w/ display=prefix( Rst _featurest _fdict_classt _flist_classRt_prefix_featuret_slash_featureR–RgR|t_features_with_defaultsRt _logic_parser(R Rt fdict_classt flist_classt logic_parsertfeature((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRq–s&           cC sV|jƒ}|j|di|ƒ\}}|t|ƒkrR|j|d|ƒn|S(uK Convert a string representation of a feature structure (as displayed by repr) into a ``FeatStruct``. This process imposes the following restrictions on the string representation: - Feature names cannot contain any of the following: whitespace, parentheses, quote marks, equals signs, dashes, commas, and square brackets. Feature names may not begin with plus signs or minus signs. - Only the following basic feature value are supported: strings, integers, variables, None, and unquoted alphanumeric strings. - For reentrant values, the first mention must specify a reentrance identifier and a value; and any subsequent mentions must use arrows (``'->'``) to reference the reentrance identifier. iu end of string(tstripRR.t_error(R RR·RƒR((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRo¬s  u$\s*(?:\((\d+)\)\s*)?(\??[\w-]+)?(\[)u\s*]\s*u/u&\s*([+-]?)([^\s\(\)<>"\'\-=\[\],]+)\s*u\s*->\s*u\s*\((\d+)\)\s*u\s*=\s*u\s*,\s*u$\s*(?:\((\d+)\)\s*)?(\??[\w-]+\s*)()u#(%s)|(%s\s*(%s\s*(=|->)|[+-]%s|\]))icC sw|dkri}ny|j||||ƒSWnAtk rr}t|jƒdkr\‚n|j||jŒnXdS(uÑ Helper function that reads in a feature structure. :param s: The string to read. :param position: The position in the string to start parsing. :param reentrances: A dictionary from reentrance ids to values. Defaults to an empty dictionary. :return: A tuple (val, pos) of the feature structure created by parsing and the position where the parsed feature structure ends. :rtype: bool iN(Rt _read_partialRgR.RhR(R RRRQR·te((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRÓs cC s;|dkr?|jj||ƒr0|jƒ}q?|jƒ}n|jj||ƒ}|sŠ|jj||ƒ}|sŠtd|ƒ‚qŠn|jƒ}|j dƒrè|j dƒ}||krÛtd|j dƒƒ‚n|||uread_logic_valueu <(.*?)(?uread_set_valueu{uread_tuple_valueu\(cC s|j|||ƒS(N(R(R RRRQR((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pytread_fstruct_valueÒscC s t||ƒS(N(R(R RRRQR((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pytread_str_valueÕscC st|jƒƒ|jƒfS(N(R@R R (R RRRQR((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pytread_int_valueØscC st|jƒƒ|jƒfS(N(RR R (R RRRQR((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pytread_var_valueÜsuNoneuTrueuFalsecC s2|jƒ|jƒ}}|jj||ƒ|fS(N(R R t _SYM_CONSTSR}(R RRRQRRzR ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pytread_sym_valueàscC s,|jjd|jddƒƒ|jƒfS(u%Mainly included for backwards compat.u%s(%s)ii(RtparseR R (R RRRQR((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pytread_app_valueäscC s€yPy|jj|jdƒƒ}Wntk r>tƒ‚nX||jƒfSWn)tk r{td|jdƒƒ‚nXdS(Niulogic expression(RR@R R RgR R"(R RRRQRtexpr((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pytread_logic_valueès   cC s|j||||dttƒS(Nu)(t_read_seq_valueRôRú(R RRRQR((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pytread_tuple_valueòscC s|j||||dttƒS(Nu}(RDRöR÷(R RRRQR((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pytread_set_valueösc C sWtj|ƒ}|jƒ}tjd|ƒj||ƒ} | rS|ƒ| jƒfSg} t} xñtrRtjd|ƒj||ƒ} | rÂ| r©|| ƒ| jƒfS|| ƒ| jƒfSn|j|||ƒ\} }| j| ƒtjd|ƒj||ƒ} | s%t d||ƒ‚n| j dƒdkrCt} n| jƒ}qbWdS(uN Helper function used by read_tuple_value and read_set_value. u \s*/?\s*%su\s*%su\s*(,|\+|(?=%s))\s*u',' or '+' or '%s'iu+N( RÁtescapeR RRR5R)RR‘RgR ( R RRRQRt close_parent seq_classt plus_classtcpR RŠt seen_plusRz((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyRDús*    N(,R-RdtSLASHtTYPERRRRqRoRÁRR R&R1R.R'R(R/R*R!tpatternRRRR$R#R-R)RRR3R:R;R<R=R)R5R>R?RARCRERFRD(((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyR•sV     , [             u c  s:d|jdƒ}d|jdƒ}t|ƒt|ƒkrxddt|dƒdd}||gt|ƒ7}n7ddt|dƒdd}||gt|ƒ7}x3t||ƒD]"\}}tˆ|d|ƒq¿Wtˆd t|dƒdd t|dƒƒt|dƒdd ‰tˆd jˆƒƒtˆd jˆƒƒtˆd jˆƒƒtˆdjˆƒƒi}|j||ƒ} | dkrÉtˆdjˆƒƒnmtdj‡‡fd†d| jdƒDƒƒƒ|r6t|jƒƒdkr6tt |ƒjˆƒƒn| S(Nu%su u[u iiu]u u-iu| |u+-----UNIFY-----+u|uVu(FAILED)c3 s"|]}ˆ|jˆƒVqdS(N(tcenter(R˜R¡(Rmtlinelen(sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pys 6 s( R7R.tzipRåRPR\RR‹tbound_variablesR( tfs1tfs2Rmt fs1_linest fs2_linest blanklinetfs1_linetfs2_lineRSRØ((RmRQsa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pytdisplay_unification s0  2 cC sddl}ddl}d}tdƒtdƒ|jjƒddddd d d d d dddddg}gtt|ƒƒD]}|t||ƒf^q‚}d„}x^tr d}t|ƒ|krét |j ||ƒƒ} n|} tddƒtdƒ|| ƒddg} x#d.d/fD]\} }x| |dkr>td| t|ƒfddƒy»|jjƒj ƒ} | d0kr‘dS| d1kr¸| }td%|ƒw9n| d2krÞt|t| ƒƒw9n| d3krú||ƒw9nt | ƒd} || d| |(1)]u[obj=?x]u [subj=?x]u[/=None]u[/=NP]u[cat=NP]u[cat=VP]u[cat=PP]u/[subj=[agr=[gender=?y]], obj=[agr=[gender=?y]]]u[gender=masc, agr=?C]u%[gender=?S, agr=[gender=?S,person=3]]cS s{xm|D]e\}}tƒd|jdƒ}td|d|dfƒx |dD]}td|ƒqTWqWtƒdS(Nu%su u%3d: %siiu (RåR7(tfstructstiR·RŸRš((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pyt list_fstructsd siu_iKu'Choose two feature structures to unify:uFirstiuSecondiu%%s feature structure (1-%d,q,t,l,?): R u uquQuxuXutuTu Trace = %suhuHu?uluLuBad sentence numberR]u3 Type "Enter" to continue unifying; or "q" to quit.(uFirsti(uSecondi(uquQuxuX(utuT(uhuHu?(uluL(uquQuxuX(trandomtsysRåtstdintreadlineR­R.RR)R>tsampleRRR@R\R[RR‘(R]R_R`tHELPtfstruct_stringsR]t all_fstructsR^t MAX_CHOICESR\tselectedtnthtinputtnumRØR·((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pytinteractive_demo< s€     2               cC s•ddddddddd d d d d dg}g|D]}t|ƒ^q7}x?|D]7}x.|D]&}td||t||ƒfƒqcWqVWdS(u Just for testing u [agr=[number=sing, gender=masc]]u[agr=[gender=masc, person=3]]u[agr=[gender=fem, person=3]]u[subj=[agr=(1)[]], agr->(1)]u[obj=?x]u [subj=?x]u[/=None]u[/=NP]u[cat=NP]u[cat=VP]u[cat=PP]u/[subj=[agr=[gender=?y]], obj=[agr=[gender=?y]]]u[gender=masc, agr=?C]u%[gender=?S, agr=[gender=?S,person=3]]u: ******************* fs1 is: %s fs2 is: %s result is: %sN(RRåR\(R]RetfssRfRTRU((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pytdemoŸ s    u__main__u FeatStructuFeatDictuFeatListuunifyusubsumesu conflictsuFeatureu SlashFeatureu RangeFeatureuSLASHuTYPEuFeatStructReader(VRet __future__RRRRÁRGtnltk.internalsRRtnltk.sem.logicRRRRR t nltk.compatR R R R RRRfRlRnRsRRªRRRR¶RTRºRUR½RRWR¿RÀR[RÄtobjectRÅRÉR5R)R\t ExceptionRÈRÇRÚRËRÊRÌRÆRÙRàRÍRÎRæR`RïRRRµRñRuRôRùRöR÷RúRøRrRRRMRNRßRR[RlRnR-t__all__(((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/featstruct.pytZsž  ((ÿ½ ÿ2•        8    d S p            E)ÿˆ c