+
    ÖÇÜhl?  ã                   óØ   € ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIHtH	t	H
t
 ^ RIHt ^ RIHt ^ RIHt R tR tR	 t ! R
 R]4      t]R8X  d    ^ RIt]P.                  ! 4        R# R# )é    N)ÚZipFilePathPointer)Úfind_dirÚ	find_fileÚfind_jars_within_path)ÚParserI)ÚDependencyGraph)Útaggedsents_to_conllc                  ó:   € ^ RI Hp  V ! . RO4      pVP                  # )r   )ÚRegexpTagger))z\.$Ú.)z\,$Ú,)z\?$Ú?)z\($Ú()z\)$Ú))z\[$Ú[)z\]$Ú])z^-?[0-9]+(\.[0-9]+)?$ÚCD)z(The|the|A|a|An|an)$ÚDT)z&(He|he|She|she|It|it|I|me|Me|You|you)$ÚPRP)z(His|his|Her|her|Its|its)$úPRP$)z(my|Your|your|Yours|yours)$r   )z (on|On|in|In|at|At|since|Since)$ÚIN)z (for|For|ago|Ago|before|Before)$r   )z(till|Till|until|Until)$r   )z(by|By|beside|Beside)$r   )z(under|Under|below|Below)$r   )z(over|Over|above|Above)$r   )z (across|Across|through|Through)$r   )z(into|Into|towards|Towards)$r   )z(onto|Onto|from|From)$r   )z.*able$ÚJJ)z.*ness$ÚNN)z.*ly$ÚRB)z.*s$ÚNNS)z.*ing$ÚVBG)z.*ed$ÚVBD)z.*r   )Únltk.tagr   Útag)r   Ú_taggers     Ú1/usr/lib/python3/dist-packages/nltk/parse/malt.pyÚmalt_regex_taggerr"      s!   € Ý%áò	
ó€Gð@ �;‰;Ðó    c                óœ  € \         P                  P                  V 4      '       d   T pM\        V RR7      p. ROp\	        \        V4      4      pV Uu0 uF)  p\         P                  P                  V4      ^,          kK+  	  pp0 RmpVP                  V4      '       g   Q h\        \        R V4      4      '       g   Q h\        V4      # u upi )z=
A module to find MaltParser .jar file and its dependencies.
)Úenv_varsc                 óV   € V P                  R 4      ;'       d    V P                  R4      # )zmaltparser-z.jar)Ú
startswithÚendswith)Úis   &r!   Ú<lambda>Ú!find_maltparser.<locals>.<lambda>M   s!   € ˜Ÿ™ mÓ4×KÐK¸¿¹ÀFÓ9KÐKr#   )ÚMALT_PARSER)Ú r-   r-   >   ú	log4j.jarú
libsvm.jarúliblinear-1.8.jar)ÚosÚpathÚexistsr   Úsetr   ÚsplitÚissubsetÚanyÚfilterÚlist)Úparser_dirnameÚ	_malt_dirÚmalt_dependenciesÚ
_malt_jarsÚjarÚ_jarss   &     r!   Úfind_maltparserr@   =   s¹   € ô 
‡w�w‡~�~�n×%Ò%Ø"‰	ä˜^Ð6FÔGˆ	â$ÐÜÔ*¨9Ó5Ó6€JÙ.8Ó9©j sŒR�W‰W�]‰]˜3Ó ×"Ð"©j€EÐ9ÚHÐà×%Ñ% e×,Ò,Ð,Ð,ÜÜÑKÈUÓS÷ò ð ð ô �
ÓÐùò :s   Á/C	c                óx   € V f   R# \         P                  P                  V 4      '       d   V # \        V RRR7      # )z0
A module to find pre-trained MaltParser model.
úmalt_temp.mcoF)r%   Úverbose)Ú
MALT_MODEL)r1   r2   r3   r   )Úmodel_filenames   &r!   Úfind_malt_modelrF   R   s5   € ð ÒÙÜ	�‰�‰˜×	'Ò	'ØÐä˜°/È5ÔQÐQr#   c                   ót   a € ] tR t^^t o RtRR ltRR ltRR ltRR lt]	RR l4       t
RR ltRR	 ltR
tV tR# )Ú
MaltParsera   
A class for dependency parsing with MaltParser. The input is the paths to:
- (optionally) a maltparser directory
- (optionally) the path to a pre-trained MaltParser .mco model file
- (optionally) the tagger to use for POS tagging before parsing
- (optionally) additional Java arguments

Example:
    >>> from nltk.parse import malt
    >>> # With MALT_PARSER and MALT_MODEL environment set.
    >>> mp = malt.MaltParser(model_filename='engmalt.linear-1.7.mco') # doctest: +SKIP
    >>> mp.parse_one('I shot an elephant in my pajamas .'.split()).tree() # doctest: +SKIP
    (shot I (elephant an) (in (pajamas my)) .)
    >>> # Without MALT_PARSER and MALT_MODEL environment.
    >>> mp = malt.MaltParser('/home/user/maltparser-1.9.2/', '/home/user/engmalt.linear-1.7.mco') # doctest: +SKIP
    >>> mp.parse_one('I shot an elephant in my pajamas .'.split()).tree() # doctest: +SKIP
    (shot I (elephant an) (in (pajamas my)) .)
Nc                óò   € \        V4      V n        Ve   TM. V n        \        V4      V n        V P                  R8g  V n        \        P                  ! 4       V n        Ve	   W0n
        R# \        4       V n
        R# )aŠ  
An interface for parsing with the Malt Parser.

:param parser_dirname: The path to the maltparser directory that
    contains the maltparser-1.x.jar
:type parser_dirname: str
:param model_filename: The name of the pre-trained model with .mco file
    extension. If provided, training will not be required.
    (see http://www.maltparser.org/mco/mco.html and
    see http://www.patful.com/chalk/node/185)
:type model_filename: str
:param tagger: The tagger used to POS tag the raw string before
    formatting to CONLL format. It should behave like `nltk.pos_tag`
:type tagger: function
:param additional_java_args: This is the additional Java arguments that
    one can use when calling Maltparser, usually this is the heapsize
    limits, e.g. `additional_java_args=['-Xmx1024m']`
    (see https://javarevisited.blogspot.com/2011/05/java-heap-space-memory-size-jvm.html)
:type additional_java_args: list
NrB   )r@   Ú	malt_jarsÚadditional_java_argsrF   ÚmodelÚ_trainedÚtempfileÚ
gettempdirÚworking_dirr"   Útagger)Úselfr:   rE   rQ   rK   s   &&&&&r!   Ú__init__ÚMaltParser.__init__r   sh   € ô: )¨Ó8ˆŒð %9Ò$DÑ È"ð 	Ô!ô % ^Ó4ˆŒ
ØŸ
™
 oÑ5ˆŒä#×.Ò.Ó0ˆÔà &Ò 2�fŽÔ8IÓ8KˆŽr#   c              #  ó  "  € V P                   '       g   \        R4      h\        P                  ! RV P                  RRR7      ;_uu_ 4       p\        P                  ! RV P                  RRR7      ;_uu_ 4       p\        V4       F  pVP                  \        V4      4       K  	  VP                  4        V P                  VP                  VP                  RR7      p\        P                  ! 4       p \        P                  ! \        P                  P                  V P                   4      ^ ,          4       T P#                  Yr4      p	\        P                  ! T4       T	^ 8w  d$   \        R	R
P%                  T4      T	3,          4      h\'        TP                  4      ;_uu_ 4       p
T
P)                  4       P                  R4       F  p\+        \-        Y³R7      .4      x € K  	  RRR4       RRR4       RRR4       \        P.                  ! XP                  4       \        P.                  ! XP                  4       R#     EL; i  + '       g   i     Lj; i  + '       g   i     Lu; i  + '       g   i     L€; i5i)a{  
Use MaltParser to parse multiple POS tagged sentences. Takes multiple
sentences where each sentence is a list of (word, tag) tuples.
The sentences must have already been tokenized and tagged.

:param sentences: Input sentences to parse
:type sentence: list(list(tuple(str, str)))
:return: iter(iter(``DependencyGraph``)) the dependency graph
    representation of each sentence
z0Parser has not been trained. Call train() first.zmalt_input.conll.ÚwF©ÚprefixÚdirÚmodeÚdeletezmalt_output.conll.Úparse©rZ   z0MaltParser parsing (%s) failed with exit code %dÚ z

©Útop_relation_labelN)rM   Ú	ExceptionrN   ÚNamedTemporaryFilerP   r	   ÚwriteÚstrÚcloseÚgenerate_malt_commandÚnamer1   ÚgetcwdÚchdirr2   r5   rL   Ú_executeÚjoinÚopenÚreadÚiterr   Úremove)rR   Ú	sentencesrC   r`   Ú
input_fileÚoutput_fileÚlineÚcmdÚ_current_pathÚretÚinfileÚtree_strs   &&&&        r!   Úparse_tagged_sentsÚMaltParser.parse_tagged_sentsœ   sê  é € ð �}�}ˆ}ÜÐNÓOÐOä×(Ò(Ø&¨D×,<Ñ,<À3Èu÷
õ 
àÜ×,Ò,Ø+Ø×$Ñ$ØØ÷	õ ð
 ä0°Ö;�DØ×$Ñ$¤S¨£YÖ/ñ <à× Ñ Ô"ð ×0Ñ0Ø—O‘O [×%5Ñ%5¸Gð 1ó �ô !#§	¢	£�ðÜ—H’HœRŸW™WŸ]™]¨4¯:©:Ó6°qÕ9Ô:ð —m‘m CÓ1�Ü—’˜Ô'à˜!”8Ü#ð"Ø%(§X¡X¨c£]°CÐ$8õ9óð ô ˜+×*Ñ*×+Ô+¨vØ$*§K¡K£M×$7Ñ$7¸Ö$?˜ä ä$3Ø(0ô%&ð!"óôñ %@÷ ,÷E÷
ôb 	�	Š	�*—/‘/Ô"Ü
�	Š	�+×"Ñ"Ö#øð3Úú÷ ,×+ú÷E÷ ú÷
÷ 
üsj   ‚A
J Á-I-Á9A:I	Ã4AH?Ä8A.I	Æ&?IÇ%I	Ç-I-Ç5A
J È?IÉI	ÉIÉI	ÉI*É%I-É-I=	É8J c                óB   a € V 3R lV 4       pS P                  WBVR7      # )a.  
Use MaltParser to parse multiple sentences.
Takes a list of sentences, where each sentence is a list of words.
Each sentence will be automatically tagged with this
MaltParser instance's tagger.

:param sentences: Input sentences to parse
:type sentence: list(list(str))
:return: iter(DependencyGraph)
c              3   óF   <"  € T F  pSP                  V4      x € K  	  R # 5i)N)rQ   )Ú.0ÚsentencerR   s   & €r!   Ú	<genexpr>Ú)MaltParser.parse_sents.<locals>.<genexpr>é   s   øé € ÐLÁ)°h˜DŸK™K¨×1Ð1Ã)ùs   ƒ!r_   )ry   )rR   rp   rC   r`   Útagged_sentencess   f&&& r!   Úparse_sentsÚMaltParser.parse_sentsÞ   s/   ø€ ô MÁ)ÓLÐØ×&Ñ&ØÐ:Lð 'ó 
ð 	
r#   c                ó*  € R.pW@P                   ,          p\        P                  P                  R4      '       d   RMRpVRVP	                  V P
                  4      .,          pVR.,          p\        P                  P                  V P                  4      '       d;   VR\        P                  P                  V P                  4      R,          .,          pMVRV P                  .,          pVRV.,          pVR	8X  d   VR
V.,          pVRV.,          pV# )zÕ
This function generates the maltparser command use at the terminal.

:param inputfilename: path to the input file
:type inputfilename: str
:param outputfilename: path to the output file
:type outputfilename: str
ÚjavaÚwinÚ;Ú:z-cpzorg.maltparser.Maltz-cz-ir\   z-oz-méÿÿÿÿ)rK   ÚsysÚplatformr'   rk   rJ   r1   r2   r3   rL   r5   )rR   ÚinputfilenameÚoutputfilenamerZ   rt   Úclasspaths_separators   &&&&  r!   rf   Ú MaltParser.generate_malt_commandî   sò   € ð ˆhˆØ×(Ñ(Õ(ˆä&)§l¡l×&=Ñ&=¸e×&DÒ&D™sÈ#ÐØØØ ×%Ñ% d§n¡nÓ5ð
õ 	
ˆð 	Ð%Ð&Õ&ˆô �7‰7�>‰>˜$Ÿ*™*×%Ò%Ø�Dœ"Ÿ'™'Ÿ-™-¨¯
©
Ó3°BÕ7Ð8Õ8‰Cà�D˜$Ÿ*™*Ð%Õ%ˆCà��mÐ$Õ$ˆØ�7Œ?Ø�D˜.Ð)Õ)ˆCØ��dˆ|ÕˆØˆ
r#   c                ó†   € V'       d   R M\         P                  p\         P                  ! WVR7      pVP                  4       # )N)ÚstdoutÚstderr)Ú
subprocessÚPIPEÚPopenÚwait)rt   rC   ÚoutputÚps   &&  r!   rj   ÚMaltParser._execute  s,   € ç ‘¤j§o¡oˆÜ×Ò˜S¸Ô?ˆØ�v‰v‹xˆr#   c                ót  € \         P                  ! RV P                  RRR7      ;_uu_ 4       pRP                  R V 4       4      pVP	                  \        V4      4       RRR4       V P                  XP                  VR7       \        P                  ! VP                  4       R#   + '       g   i     LO; i)	z­
Train MaltParser from a list of ``DependencyGraph`` objects

:param depgraphs: list of ``DependencyGraph`` objects for training input data
:type depgraphs: DependencyGraph
úmalt_train.conll.rV   FrW   Ú
c              3   óB   "  € T F  qP                  ^
4      x € K  	  R# 5i)é
   N)Úto_conll)r}   Údgs   & r!   r   Ú#MaltParser.train.<locals>.<genexpr>   s   é € Ð!F¹I°b§+¡+¨b§/ /»Iùs   ‚N©rC   )
rN   rb   rP   rk   rc   rd   Útrain_from_filerg   r1   ro   )rR   Ú	depgraphsrC   rq   Ú	input_strs   &&&  r!   ÚtrainÚMaltParser.train  sˆ   € ô ×(Ò(Ø&¨D×,<Ñ,<À3Èu÷
õ 
àØŸ	™	Ñ!F¹IÓ!FÓFˆIØ×ÑœS ›^Ô,÷	
ð 	×Ñ˜ZŸ_™_°gÐÔ>ä
�	Š	�*—/‘/Ö"÷
÷ 
ús   ­3B'Â'B7	c           	     óf  € \        V\        4      '       d    \        P                  ! RV P                  RRR7      ;_uu_ 4       pVP                  4       ;_uu_ 4       pVP                  4       pVP                  \        V4      4       RRR4       V P                  VP                  VR7      uuRRR4       # V P                  VRR7      pV P                  Wb4      pV^ 8w  d$   \        R	R
P                  V4      V3,          4      hRV n        R#   + '       g   i     LŽ; i  + '       g   i     Lz; i)zw
Train MaltParser from a file
:param conll_file: str for the filename of the training input data
:type conll_file: str
r›   rV   FrW   Nr¢   Úlearnr]   z1MaltParser training (%s) failed with exit code %dr^   T)Ú
isinstancer   rN   rb   rP   rl   rm   rc   rd   r£   rg   rf   rj   ra   rk   rM   )rR   Ú
conll_filerC   rq   Úconll_input_fileÚ	conll_strrt   rv   s   &&&     r!   r£   ÚMaltParser.train_from_file'  s   € ô �jÔ"4×5Ò5Ü×,Ò,Ø*°×0@Ñ0@ÀsÐSX÷õ àØ—_‘_×&Ô&Ð*:Ø 0× 5Ñ 5Ó 7�IØ×$Ñ$¤S¨£^Ô4÷ 'ð ×+Ñ+¨J¯O©OÀWÐ+ÓM÷ò ð ×(Ñ(¨¸'Ð(ÓBˆØ�m‰m˜CÓ)ˆØ�!Œ8ÜðØ ŸX™X c›]¨CÐ0õ1óð ð ˆŽ÷ '×&ú÷÷ ús$   ÁD Á+D	Â$D ÄDÄD Ä D0	)rM   rK   rJ   rL   rQ   rP   )r-   NNN)FÚnull)NN)F)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rS   ry   r‚   rf   Ústaticmethodrj   r¦   r£   Ú__static_attributes__Ú__classdictcell__)Ú__classdict__s   @r!   rH   rH   ^   sF   ø‡ € ñô&(LôT@$ôD
ô ð@ óó ðô
#÷&ò r#   rH   Ú__main__)Úinspectr1   r“   rŠ   rN   Ú	nltk.datar   Únltk.internalsr   r   r   Únltk.parse.apir   Únltk.parse.dependencygraphr   Únltk.parse.utilr	   r"   r@   rF   rH   r°   ÚdoctestÚtestmod© r#   r!   Ú<module>rÃ      sn   ðó Û 	Û Û 
Û å (ß EÑ EÝ "Ý 6Ý 0ò#òLò*	Rôc�ô cðL ˆzÔð@óD à‡O‚OÖñK r#   