ó <¿CVc@sQdZddlmZmZdZyddlZWnek rEnXddlZddlZddl m Z ddl m Z ddl mZddlmZdd lmZdd lmZdd lmZmZmZdd lmZmZmZdd lmZmZm Z e j!defd„ƒYƒZ"e"Z#de$fd„ƒYZ%de%fd„ƒYZ&de%fd„ƒYZ'de'fd„ƒYZ(de'fd„ƒYZ)de%fd„ƒYZ*dddd„Z,d„Z-d„Z.dddd „Z/d!„Z0d"„Z1dddd#d$„Z2d%e"fd&„ƒYZ3d'„Z4e5d(krMe4ƒndS()uä A classifier model based on maximum entropy modeling framework. This framework considers all of the probability distributions that are empirically consistent with the training data; and chooses the distribution with the highest entropy. A probability distribution is "empirically consistent" with a set of training data if its estimated frequency with which a class and a feature vector value co-occur is equal to the actual frequency in the data. Terminology: 'feature' ====================== The term *feature* is usually used to refer to some property of an unlabeled token. For example, when performing word sense disambiguation, we might define a ``'prevword'`` feature whose value is the word preceding the target word. However, in the context of maxent modeling, the term *feature* is typically used to refer to a property of a "labeled" token. In order to prevent confusion, we will introduce two distinct terms to disambiguate these two different concepts: - An "input-feature" is a property of an unlabeled token. - A "joint-feature" is a property of a labeled token. In the rest of the ``nltk.classify`` module, the term "features" is used to refer to what we will call "input-features" in this module. In literature that describes and discusses maximum entropy models, input-features are typically called "contexts", and joint-features are simply referred to as "features". Converting Input-Features to Joint-Features ------------------------------------------- In maximum entropy models, joint-features are required to have numeric values. Typically, each input-feature ``input_feat`` is mapped to a set of joint-features of the form: | joint_feat(token, label) = { 1 if input_feat(token) == feat_val | { and label == some_label | { | { 0 otherwise For all values of ``feat_val`` and ``some_label``. This mapping is performed by classes that implement the ``MaxentFeatureEncodingI`` interface. iÿÿÿÿ(tprint_functiontunicode_literalsu epytext enN(t defaultdict(tcompat(tgzip_open_unicode(t OrderedDict(tDictionaryProbDist(t ClassifierI(t CutoffCheckertaccuracytlog_likelihood(t call_megamtwrite_megam_filetparse_megam_weights(t call_tadmtwrite_tadm_filetparse_tadm_weightstMaxentClassifiercBs›eZdZed„Zd„Zd„Zd„Zd„Zd„Z dd„Z d d d „Z d „Z d dddgZ edddddd„ƒZRS(uî A maximum entropy classifier (also known as a "conditional exponential classifier"). This classifier is parameterized by a set of "weights", which are used to combine the joint-features that are generated from a featureset by an "encoding". In particular, the encoding maps each ``(featureset, label)`` pair to a vector. The probability of each label is then computed using the following equation:: dotprod(weights, encode(fs,label)) prob(fs|label) = --------------------------------------------------- sum(dotprod(weights, encode(fs,l)) for l in labels) Where ``dotprod`` is the dot product:: dotprod(a,b) = sum(x*y for (x,y) in zip(a,b)) cCs=||_||_||_|jƒt|ƒks9t‚dS(u{ Construct a new maxent classifier model. Typically, new classifier models are created using the ``train()`` method. :type encoding: MaxentFeatureEncodingI :param encoding: An encoding that is used to convert the featuresets that are given to the ``classify`` method into joint-feature vectors, which are used by the maxent classifier model. :type weights: list of float :param weights: The feature weight vector for this classifier. :type logarithmic: bool :param logarithmic: If false, then use non-logarithmic weights. N(t _encodingt_weightst _logarithmictlengthtlentAssertionError(tselftencodingtweightst logarithmic((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyt__init__ds   cCs |jjƒS(N(Rtlabels(R((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyR{scCs.||_|jjƒt|ƒks*t‚dS(u¨ Set the feature weight vector for this classifier. :param new_weights: The new feature weight vector. :type new_weights: list of float N(RRRRR(Rt new_weights((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyt set_weights~s cCs|jS(ug :return: The feature weight vector for this classifier. :rtype: list of float (R(R((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyR‡scCs|j|ƒjƒS(N(t prob_classifytmax(Rt featureset((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pytclassifyŽsc CsÒi}x°|jjƒD]Ÿ}|jj||ƒ}|jryd}x)|D]!\}}||j||7}qGW|||³su u-icstˆj|dƒS(Ni(tabsR(tfid__(R(sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyt¸su and label is iu (%s)i/i,u...u iu TOTAL:c3s|]}dˆ|VqdS(u%8.3fN((R1R2(tsums(sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pys Çsu PROBS:c3s"|]}dˆj|ƒVqdS(u%8.3fN(tprob(R1R2(tpdist(sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pys ÉsN(tstrR tsortedtsamplesR7R'tprinttljusttjoinRRtintt enumerateRR&tsortRRtdescribetsplit( RR"tcolumnst descr_widthtTEMPLATERtiR)R*R,R-tscoretdescr((R8RR6sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pytexplain¦s:! $  $i uallcsìttttˆjƒƒƒd‡fd†dtƒ}|dkrqg|D]}ˆj|dkrI|^qI}n;|dkr¬g|D]}ˆj|dkr„|^q„}nx9|| D]-}tdˆj|ˆjj|ƒfƒq·WdS( uT :param show: all, neg, or pos (for negative-only or positive-only) R/cstˆj|ƒS(N(R3R(tfid(R(sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyR5ÐsR0uposiunegu%8.3f %sN( R:tlisttrangeRRR'R<RRB(RtntshowtfidsRK((Rsf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pytshow_most_informative_featuresËs  / /cCs&dt|jjƒƒ|jjƒfS(Nu:(RRRR(R((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyt__repr__ÚsuGISuIISuMEGAMuTADMiic Ks|dkrd}nx-|D]%}|dkrtd |ƒ‚qqW|jƒ}|dkrst|||||S|d kr•t|||||S|d krºt||||||S|dkr|} || d<|| d<|| d<|| d feature_vector This sparse joint feature vector (``feature_vector``) is a list of ``(index,value)`` tuples. :type length: int :param length: The size of the fixed-length joint-feature vectors that are generated by this encoding. :type labels: list :param labels: A list of the "known labels" for this encoding -- i.e., all labels ``l`` such that ``self.encode(fs,l)`` can be a nonzero joint-feature vector for some value of ``fs``. N(t_lengtht_funct_labels(RtfuncRR((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyR‰s  cCs|j||ƒS(N(Rl(RR"R)((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyR&¥scCs|jS(N(Rk(R((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyR¨scCs|jS(N(Rm(R((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyR«scCsdS(Nuno description available((RRK((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyRB®s(RcRdReRR&RRRB(((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyRj„s     tBinaryMaxentFeatureEncodingcBsVeZdZeed„Zd„Zd„Zd„Zd„Ze ddd„ƒZ RS( uø A feature encoding that generates vectors containing a binary joint-features of the form: | joint_feat(fs, l) = { 1 if (fs[fname] == fval) and (l == label) | { | { 0 otherwise Where ``fname`` is the name of an input-feature, ``fval`` is a value for that input-feature, and ``label`` is a label. Typically, these features are constructed based on a training corpus, using the ``train()`` method. This method will create one feature for each combination of ``fname``, ``fval``, and ``label`` that occurs at least once in the training corpus. The ``unseen_features`` parameter can be used to add "unseen-value features", which are used whenever an input feature has a value that was not encountered in the training corpus. These features have the form: | joint_feat(fs, l) = { 1 if is_unseen(fname, fs[fname]) | { and l == label | { | { 0 otherwise Where ``is_unseen(fname, fval)`` is true if the encoding does not contain any joint features that are true when ``fs[fname]==fval``. The ``alwayson_features`` parameter can be used to add "always-on features", which have the form:: | joint_feat(fs, l) = { 1 if (l == label) | { | { 0 otherwise These always-on features allow the maxent model to directly model the prior probabilities of each label. cst|jƒƒttt|ƒƒƒkr9tdƒ‚nt|ƒˆ_|ˆ_t|ƒˆ_dˆ_ dˆ_ |r¸t ‡fd†t |ƒDƒƒˆ_ ˆjtˆj ƒ7_n|rtd„|Dƒƒ}t ‡fd†t |ƒDƒƒˆ_ ˆjt|ƒ7_ndS(u» :param labels: A list of the "known labels" for this encoding. :param mapping: A dictionary mapping from ``(fname,fval,label)`` tuples to corresponding joint-feature indexes. These indexes must be the set of integers from 0...len(mapping). If ``mapping[fname,fval,label]=id``, then ``self.encode(..., fname:fval, ..., label)[id]`` is 1; otherwise, it is 0. :param unseen_features: If true, then include unseen value features in the generated joint-feature vectors. :param alwayson_features: If true, then include always-on features in the generated joint-feature vectors. uHMapping values must be exactly the set of integers from 0...len(mapping)c3s(|]\}}||ˆjfVqdS(N(Rk(R1RGR)(R(sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pys ÿscss|]\}}}|VqdS(N((R1tfnametfvalR)((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pys sc3s(|]\}}||ˆjfVqdS(N(Rk(R1RGRp(R(sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pys sN(tsettvaluesRMRR[RLRmt_mappingRkRSt _alwaysont_unseentdictR@(RRtmappingtunseen_featurestalwayson_featurestfnames((Rsf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyRÙs *   cCsg}xÀ|jƒD]²\}}|||f|jkr]|j|j|||fdfƒq|jrx\|jD]"}|||f|jkrpPqpqpW||jkrÅ|j|j|dfƒqÅqqW|jrþ||jkrþ|j|j|dfƒn|S(Ni(titemsRttappendRvRmRu(RR"R)RRpRqtlabel2((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyR& s& $cCs|t|tjƒs!tdƒ‚ny |jWnWtk r…dgt|jƒ|_x.|jjƒD]\}}||j|’siN(RoRRSRRrt_C(RRRxRyRztC((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyR‡s  #cCs|jS(uOThe non-negative constant that all encoded feature vectors will sum to.(R(R((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyRŽ•scCsvtj|||ƒ}tj|ƒ}td„|Dƒƒ}||jkrXtdƒ‚n|j||j|fƒ|S(Ncss|]\}}|VqdS(N((R1tftv((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pys ¡su&Correction feature is not high enough!(RoR&RtsumRR[R}(RR"R)Rt base_lengthR+((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyR&›scCstj|ƒdS(Ni(RoR(R((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyR©scCs4|tj|ƒkr d|jStj||ƒSdS(NuCorrection feature (%s)(RoRRRB(RR,((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyRB¬s N( RcRdReR‹RSRtpropertyRŽR&RRB(((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyRŒys    tTadmEventMaxentFeatureEncodingcBsPeZeed„Zd„Zd„Zd„Zd„Zeddd„ƒZ RS(cCs;t|ƒ|_tƒ|_tj|||j||ƒdS(N(RRtt_label_mappingRoR(RRRxRyRz((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyR´s  cCsÉg}x¼|jƒD]®\}}||f|jkrSt|jƒ|j||fIscss|]\}}}|VqdS(N((R1RpRqR)((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pys Nsc3s(|]\}}||ˆjfVqdS(N(Rk(R1RGRp(R(sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pys OsN(RrRsRMRR[RLRmRtRkRSRuRvRwR@(RRRxRyRzR{((Rsf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyR#s *   cCsgg}x%|jƒD]\}}t|tjtfƒr„|t|ƒ|f|jkr*|j|j|t|ƒ|f|fƒq*q|||f|jkrÂ|j|j|||fdfƒq|jrx\|j D]"}|||f|jkrÕPqÕqÕW||jkr*|j|j|dfƒq*qqW|j rc||j krc|j|j |dfƒn|S(Ni( R|RRR€tfloatttypeRtR}RvRmRu(RR"R)RRpRqR~((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyR&Ss"& $cCs|t|tjƒs!tdƒ‚ny |jWnWtk r…dgt|jƒ|_x.|jjƒD]\}}||j| Training (%d iterations)iu- Iteration Log Likelihood Accuracyu- ---------------------------------------u %9d %14.5f %9.3fiu* Training stopped: keyboard interruptu! Final %14.5f %9.3fN(t setdefaultRRSRŒRZthasattrRTRŽtcalculate_empirical_fcountRrtnumpytnonzerotzerosRtNINFt ConditionalExponentialClassifiertlog2R<R'tllR taccR titertcalculate_estimated_fcountRRtchecktKeyboardInterrupt(R]R_RRRat cutoffcheckertCinvtempirical_fcountt unattestedRRKt classifiertlog_empirical_fcounttll_oldtacc_oldR¤R¥titernumtestimated_fcounttlog_estimated_fcount((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyRWÕsd                   cCsftj|jƒdƒ}xG|D]?\}}x0|j||ƒD]\}}||c|7WqW|S(Nud(RžR RR&(R]RtfcountRŠR)tindextval((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyR7s c CsŸtj|jƒdƒ}x€|D]x\}}|j|ƒ}xZ|jƒD]L}|j|ƒ}x4|j||ƒD] \}} ||c|| 7 Training (%d iterations)iu- Iteration Log Likelihood Accuracyu- ---------------------------------------u %9d %14.5f %9.3fu* Training stopped: keyboard interruptu! Final %14.5f %9.3fN(R›RRSRoRZRRtcalculate_nfmapRžtarrayR:t __getitem__treshapeRrRŸR R¡R¢R<R'R¤R R¥R R¦tcalculate_deltasRRR¨R©(R]R_RRRaRªtempirical_ffreqtnfmaptnfarrayt nftransposeR­RRKR®R°R±R¤R¥R²tdeltas((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyRVQs\     !                cCsztƒ}xT|D]L\}}x=|jƒD]/}|jtd„|j||ƒDƒƒƒq)WqWtd„t|ƒDƒƒS(uó Construct a map that can be used to compress ``nf`` (which is typically sparse). *nf(feature_vector)* is the sum of the feature values for *feature_vector*. This represents the number of features that are active for a given labeled text. This method finds all values of *nf(t)* that are attested for at least one token in the given list of training tokens; and constructs a dictionary mapping these attested values to a continuous range *0...N*. For example, if the only values of *nf()* that were attested were 3, 5, and 7, then ``_nfmap`` might return the dictionary ``{3:0, 5:1, 7:2}``. :return: A map that can be used to compress ``nf`` to a dense vector. :rtype: dict(int -> int) css|]\}}|VqdS(N((R1tidR·((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pys Ãscss!|]\}}||fVqdS(N((R1RGtnf((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pys Äs(RrRR…R‘R&RwR@(R]RtnfsetRŠt_R)((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyR¸«s  1cCsÞd}d} tj|jƒdƒ} tjt|ƒ|jƒfdƒ} x |D]˜\} } |j| ƒ}xz|jƒD]l} |j| | ƒ}td„|Dƒƒ}x;|D]3\}}| |||fc|j | ƒ|7 int) :param nfarray: An array that can be used to uncompress ``nf`` from a dense vector. :type nfarray: array(float) :param nftranspose: The transpose of ``nfarray`` :type nftranspose: array(float) gê-™—q=i,udcss|]\}}|VqdS(N((R1RÂR·((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pys sitaxisii( RžtonesRR RR RR&R‘R7RMtouterR3(R]R®R­tffreq_empiricalR¾R¿RÀRtNEWTON_CONVERGEt MAX_NEWTONRÁtARŠR)tdistR*RÃRÂR·trangenumtnf_deltat exp_nf_deltatnf_exp_nf_deltatsum1tsum2RKtn_error((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyR¼Æs4A$3     ic KsÄt}t}d|kr%|d}nd|kr>|d}n|d kr}|jddƒ}tj||d|dtƒ}n|d k r˜tdƒ‚ny]tjdd ƒ\} } t| d ƒ#} t ||| d |d |ƒWd QXt j | ƒWn,t t tfk r#} td| ƒ‚nXg} | dddg7} |rS| dg7} n|si| dg7} n|r€d|d}nd}| dd|dg7} |dkr¹| dg7} nd|krà| dd|dg7} nd|kr | ddt|dƒg7} nt|d ƒr,| d!g7} n| d"| g7} t| ƒ}yt j| ƒWn-t t fk rˆ} td#| | fƒnXt||jƒ|ƒ}|tjtjƒ9}t||ƒS($u› Train a new ``ConditionalExponentialClassifier``, using the given training samples, using the external ``megam`` library. This ``ConditionalExponentialClassifier`` will encode the model that maximizes entropy from all the models that are empirically consistent with ``train_toks``. :see: ``train_maxent_classifier()`` for parameter descriptions. :see: ``nltk.classify.megam`` uexplicitu bernoulliu count_cutoffiRRzu$Specify encoding or labels, not bothtprefixunltk-uwtexplicitt bernoulliNu,Error while creating megam training file: %su-nobiasu-repeatu10u -explicitu-fvalsgð?iu-lambdau%.2fu-tuneiu-quietumax_iteru-maxiu%sull_deltau-dppucostu -multilabelu multiclassu Warning: unable to delete %s: %s(R'RStgetRoRZR[ttempfiletmkstemptopenR tostclosetOSErrortIOErrorR3RœR tremoveR<R RRžR£teR(R]R_RRR`RbRÖR×R†tfdttrainfile_namet trainfileRáR‡t inv_variancetstdoutR((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyRXDs`          ! RYcBseZed„ƒZRS(cKs]|jddƒ}|jddƒ}|jddƒ}|jddƒ}|jddƒ}|jd dƒ}|jd ƒ} |jd ƒ} |s«tj||d |ƒ}ntjd dddƒ\} } tjd dƒ\} }t| dƒ}t|||ƒ|jƒg}|j dgƒ|j d|gƒ|rW|j dd|dgƒn| rw|j dd| gƒn| r|j ddt | ƒgƒn|j d| gƒ|j d|gƒ|dkrâ|j dgƒn|j dgƒt |ƒt |dƒ}t |ƒ}WdQXtj| ƒtj|ƒ|tjtjƒ9}|||ƒS( Nu algorithmutao_lmvmutraceiuencodingulabelsugaussian_prior_sigmaiu count_cutoffumax_iteru min_lldeltaRRÕunltk-tadm-events-tsuffixu.gzunltk-tadm-weights-uwu-monitoru-methodu-l2u%.6fiu-max_itu%du-fatolu -events_inu -params_outu2>&1u-summaryur(RØRSR”RZRÙRÚRRRÝtextendR3RRÛRRÜRàRžR£Rá(R\R]RbR^R_RRtsigmaR†tmax_itertll_deltat trainfile_fdRãt weightfile_fdtweightfile_nameRäR‡t weightfileR((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyRZžsL        (RcRdRgRZ(((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyRYscCs#ddlm}|tjƒ}dS(Niÿÿÿÿ(t names_demo(tnltk.classify.utilRðRRZ(RðR®((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pytdemoÙsu__main__(6Ret __future__RRt __docformat__Ržt ImportErrorRÙRÜt collectionsRtnltkRt nltk.dataRt nltk.utilRtnltk.probabilityRtnltk.classify.apiRRñRR R tnltk.classify.megamR R R tnltk.classify.tadmRRRtpython_2_unicode_compatibleRR¢tobjectRhRjRoRŒR”R˜RSRWRR§RVR¸R¼RXRYRòRc(((sf/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/classify/maxent.pyt5sP    äG-È:8ê a  Y  ~X<