JL iTdZddlZddlmZmZddlmZGddeZdZ dZ dgZ y) zh Class for representing hierarchical language structures, such as syntax trees and morphological trees. N) Nonterminal Production) deprecatedceZdZdZd5dZdZdZdZdZdZ d Z d Z d Z d Z d ZdZdZdZeddZeddZeeeZdZdZdZdZdZd6dZd5dZdZdZdZ dZ! d7d Z" d8d!Z#d9d"Z$e%d#Z&d$Z'd%Z(d:d&Z)d'Z*d5d(Z+e% d;d)Z,e%d*Z-e%d+Z.d,Z/dTreeai A Tree represents a hierarchical grouping of leaves and subtrees. For example, each constituent in a syntax tree is represented by a single Tree. A tree's children are encoded as a list of leaves and subtrees, where a leaf is a basic (non-tree) value; and a subtree is a nested Tree. >>> from nltk.tree import Tree >>> print(Tree(1, [2, Tree(3, [4]), 5])) (1 2 (3 4) 5) >>> vp = Tree('VP', [Tree('V', ['saw']), ... Tree('NP', ['him'])]) >>> s = Tree('S', [Tree('NP', ['I']), vp]) >>> print(s) (S (NP I) (VP (V saw) (NP him))) >>> print(s[1]) (VP (V saw) (NP him)) >>> print(s[1,1]) (NP him) >>> t = Tree.fromstring("(S (NP I) (VP (V saw) (NP him)))") >>> s == t True >>> t[1][1].set_label('X') >>> t[1][1].label() 'X' >>> print(t) (S (NP I) (VP (V saw) (X him))) >>> t[0], t[1,1] = t[1,1], t[0] >>> print(t) (S (X him) (VP (V saw) (NP I))) The length of a tree is the number of children it has. >>> len(t) 2 The set_label() and label() methods allow individual constituents to be labeled. For example, syntax trees use this label to specify phrase tags, such as "NP" and "VP". Several Tree methods use "tree positions" to specify children or descendants of a tree. Tree positions are defined as follows: - The tree position *i* specifies a Tree's *i*\ th child. - The tree position ``()`` specifies the Tree itself. - If *p* is the tree position of descendant *d*, then *p+i* specifies the *i*\ th child of *d*. I.e., every tree position is either a single index *i*, specifying ``tree[i]``; or a sequence *i1, i2, ..., iN*, specifying ``tree[i1][i2]...[iN]``. Construct a new tree. This constructor can be called in one of two ways: - ``Tree(label, children)`` constructs a new tree with the specified label and list of children. - ``Tree.fromstring(s)`` constructs a new tree by parsing the string ``s``. Nc|!tdt|jzt|tr!tdt|jzt j ||||_y)Nz)%s: Expected a node value and child list z.%s() argument 2 should be a list, not a string) TypeErrortype__name__ isinstancestrlist__init___label)selfnodechildrens T/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/nltk/tree/tree.pyrz Tree.__init__\sn  ;d4j>Q>QQ # &:../  MM$ )DKc|j|juxr/|jt|f|jt|fk(SN) __class__rrrothers r__eq__z Tree.__eq__nsD~~0 dkk4:5N LL KS 6  rcdt|ts-|jj|jjkS|j|jur/|jt |f|jt |fkS|jj|jjkSr)r rrr rrrs r__lt__z Tree.__lt__ts%&>>**U__-E-EE E ^^u .KKd, d5k/JJ J>>**U__-E-EE Erc||k( Srrs rz Tree.s TU]!2rc||kxs||k( Srrrs rr z Tree.sdUl&Cdem!Drc||kxs||k(Srrrs rr z Tree.s!>rc||k Srrrs rr z Tree.s TE\!1rctdNz$Tree does not support multiplicationr rvs r__mul__z Tree.__mul__>??rctdr%r&r's r__rmul__z Tree.__rmul__r*rctdNzTree does not support additionr&r's r__add__z Tree.__add__899rctdr.r&r's r__radd__z Tree.__radd__r0rcZt|ttfrtj ||St|tt fr4t |dk(r|St |dk(r||dS||d|ddStt|jdt|j)Nr indices must be integers, not ) r intslicer __getitem__tuplelenr r r rindexs rr8zTree.__getitem__s ec5\ *##D%0 0 e} -5zQ UqE!H~%E!H~eABi00:&&U (<(<> rcrt|ttfrtj |||St|tt fr?t |dk(r tdt |dk(r |||d<y|||d|dd<ytt|jdt|j)Nrz,The tree position () may not be assigned to.r4r5) r r6r7r __setitem__r9r: IndexErrorr r r )rr<values rr>zTree.__setitem__s ec5\ *##D%7 7 e} -5zQ !RSSUq!&U1X,1U1XuQRy):&&U (<(<> rcht|ttfrtj ||St|tt fr;t |dk(r tdt |dk(r||d=y||d|dd=ytt|jdt|j)Nrz(The tree position () may not be deleted.r4r5) r r6r7r __delitem__r9r:r?r r r r;s rrBzTree.__delitem__s ec5\ *##D%0 0 e} -5zQ !KLLUqqNqN59-:&&U (<(<> rzUse label() insteadcy)zIOutdated method to access the node value; use the label() method instead.Nrrs r _get_nodezTree._get_noderzUse set_label() insteadcy)zJOutdated method to set the node value; use the set_label() method instead.Nr)rr@s r _set_nodezTree._set_noderFrc|jS)a Return the node label of the tree. >>> t = Tree.fromstring('(S (NP (D the) (N dog)) (VP (V chased) (NP (D the) (N cat))))') >>> t.label() 'S' :return: the node label (typically a string) :rtype: any rrDs rlabelz Tree.labels{{rc||_y)ao Set the node label of the tree. >>> t = Tree.fromstring("(S (NP (D the) (N dog)) (VP (V chased) (NP (D the) (N cat))))") >>> t.set_label("T") >>> print(t) (T (NP (D the) (N dog)) (VP (V chased) (NP (D the) (N cat)))) :param label: the node label (typically a string) :type label: any NrJ)rrKs r set_labelzTree.set_labels  rcg}|D]C}t|tr |j|j3|j |E|S)a Return the leaves of the tree. >>> t = Tree.fromstring("(S (NP (D the) (N dog)) (VP (V chased) (NP (D the) (N cat))))") >>> t.leaves() ['the', 'dog', 'chased', 'the', 'cat'] :return: a list containing this tree's leaves. The order reflects the order of the leaves in the tree's hierarchical structure. :rtype: list )r rextendleavesappend)rrPchilds rrPz Tree.leavessG %E%& elln- e$  %  rcRt|j|jS)a Return a flat version of the tree, with all non-root non-terminals removed. >>> t = Tree.fromstring("(S (NP (D the) (N dog)) (VP (V chased) (NP (D the) (N cat))))") >>> print(t.flatten()) (S the dog chased the cat) :return: a tree consisting of this tree's root connected directly to its leaves, omitting all intervening non-terminal nodes. :rtype: Tree )rrKrPrDs rflattenz Tree.flattensDJJL$++-00rcd}|D]9}t|trt||j}.t|d};d|zS)aG Return the height of the tree. >>> t = Tree.fromstring("(S (NP (D the) (N dog)) (VP (V chased) (NP (D the) (N cat))))") >>> t.height() 5 >>> print(t[0,0]) (D the) >>> t[0,0].height() 2 :return: The height of this tree. The height of a tree containing no children is 1; the height of a tree containing only leaves is 2; and the height of any other tree is one plus the maximum of its children's heights. :rtype: int rr4)r rmaxheight)rmax_child_heightrRs rrWz Tree.heightsS& >> t = Tree.fromstring("(S (NP (D the) (N dog)) (VP (V chased) (NP (D the) (N cat))))") >>> t.treepositions() # doctest: +ELLIPSIS [(), (0,), (0, 0), (0, 0, 0), (0, 1), (0, 1, 0), (1,), (1, 0), (1, 0, 0), ...] >>> for pos in t.treepositions('leaves'): ... t[pos] = t[pos][::-1].upper() >>> print(t) (S (NP (D EHT) (N GOD)) (VP (V DESAHC) (NP (D EHT) (N TAC)))) :param order: One of: ``preorder``, ``postorder``, ``bothorder``, ``leaves``. )preorder bothorderrc3*K|] }f|z ywrr).0pis r z%Tree.treepositions..Bs >> t = Tree.fromstring("(S (NP (D the) (N dog)) (VP (V chased) (NP (D the) (N cat))))") >>> for s in t.subtrees(lambda t: t.height() == 2): ... print(s) (D the) (N dog) (V chased) (D the) (N cat) :type filter: function :param filter: the function to filter all local trees N)r rsubtrees)rfilterrRs rrhz Tree.subtreesIsD"J 2E%& >>&111 21s$AAAAct|jts tdt t |jt |g}|D]&}t|ts||jz }(|S)a) Generate the productions that correspond to the non-terminal nodes of the tree. For each subtree of the form (P: C1 C2 ... Cn) this produces a production of the form P -> C1 C2 ... Cn. >>> t = Tree.fromstring("(S (NP (D the) (N dog)) (VP (V chased) (NP (D the) (N cat))))") >>> t.productions() # doctest: +NORMALIZE_WHITESPACE [S -> NP VP, NP -> D N, D -> 'the', N -> 'dog', VP -> V NP, V -> 'chased', NP -> D N, D -> 'the', N -> 'cat'] :rtype: list(Production) zPProductions can only be generated from trees having node labels that are strings) r rr r rr _child_namesr productions)rprodsrRs rrlzTree.productions`st$++s+b K 4l46HIJ -E%&**,, - rcg}|D]O}t|tr |j|j3|j ||j fQ|S)a Return a sequence of pos-tagged words extracted from the tree. >>> t = Tree.fromstring("(S (NP (D the) (N dog)) (VP (V chased) (NP (D the) (N cat))))") >>> t.pos() [('the', 'D'), ('dog', 'N'), ('chased', 'V'), ('the', 'D'), ('cat', 'N')] :return: a list of tuples containing leaves and pre-terminals (part-of-speech tags). The order reflects the order of the leaves in the tree's hierarchical structure. :rtype: list(tuple) )r rrOposrQr)rrorRs rrozTree.posysP 1E%& 599;' E4;;/0  1  rc|dkr td|dfg}|rk|j\}}t|ts |dk(r|S|dz}n8t t |dz ddD]}|j ||||fzf|rktd)a, :return: The tree position of the ``index``-th leaf in this tree. I.e., if ``tp=self.leaf_treeposition(i)``, then ``self[tp]==self.leaves()[i]``. :raise IndexError: If this tree contains fewer than ``index+1`` leaves, or if ``index<0``. rzindex must be non-negativerr4z-index must be less than or equal to len(self))r?popr rranger:rQ)rr<stackr@treeposr_s rleaf_treepositionzTree.leaf_treepositions 199: : "YY[NE7eT*A:"NQJEs5zA~r26=ALL%(GqdN!;<=HIIrc||kr td|j|}|j|dz }tt|D]"}|t|k(s ||||k7s|d|cS|S)z :return: The tree position of the lowest descendant of this tree that dominates ``self.leaves()[start:end]``. :raise ValueError: if ``end <= start`` zend must be greater than startr4N) ValueErrorrvrsr:)rstartend start_treepos end_treeposr_s rtreeposition_spanning_leavesz!Tree.treeposition_spanning_leavess %<=> >..u5 ,,S1W5 s=)* )AC $$ a(8KN(J$Ra(( )rc*ddlm}|||||||y)a This method can modify a tree in three ways: 1. Convert a tree into its Chomsky Normal Form (CNF) equivalent -- Every subtree has either two non-terminals or one terminal as its children. This process requires the creation of more"artificial" non-terminal nodes. 2. Markov (vertical) smoothing of children in new artificial nodes 3. Horizontal (parent) annotation of nodes :param factor: Right or left factoring method (default = "right") :type factor: str = [left|right] :param horzMarkov: Markov order for sibling smoothing in artificial nodes (None (default) = include all siblings) :type horzMarkov: int | None :param vertMarkov: Markov order for parent smoothing (0 (default) = no vertical annotation) :type vertMarkov: int | None :param childChar: A string used in construction of the artificial nodes, separating the head of the original subtree from the child nodes that have yet to be expanded (default = "|") :type childChar: str :param parentChar: A string used to separate the node representation from its vertical annotation :type parentChar: str r)chomsky_normal_formN)nltk.tree.transformsr)rfactor horzMarkov vertMarkov childChar parentCharrs rrzTree.chomsky_normal_forms> =D&*j)ZXrc(ddlm}||||||y)am This method modifies the tree in three ways: 1. Transforms a tree in Chomsky Normal Form back to its original structure (branching greater than two) 2. Removes any parent annotation (if it exists) 3. (optional) expands unary subtrees (if previously collapsed with collapseUnary(...) ) :param expandUnary: Flag to expand unary or not (default = True) :type expandUnary: bool :param childChar: A string separating the head node from its children in an artificial node (default = "|") :type childChar: str :param parentChar: A string separating the node label from its parent annotation (default = "^") :type parentChar: str :param unaryChar: A string joining two non-terminals in a unary production (default = "+") :type unaryChar: str r)un_chomsky_normal_formN)rr)r expandUnaryrr unaryCharrs rrzTree.un_chomsky_normal_forms* @t[)ZSrc&ddlm}|||||y)a Collapse subtrees with a single child (ie. unary productions) into a new non-terminal (Tree node) joined by 'joinChar'. This is useful when working with algorithms that do not allow unary productions, and completely removing the unary productions would require loss of useful information. The Tree is modified directly (since it is passed by reference) and no value is returned. :param collapsePOS: 'False' (default) will not collapse the parent of leaf nodes (ie. Part-of-Speech tags) since they are always unary productions :type collapsePOS: bool :param collapseRoot: 'False' (default) will not modify the root production if it is unary. For the Penn WSJ treebank corpus, this corresponds to the TOP -> productions. :type collapseRoot: bool :param joinChar: A string used to connect collapsed node values (default = "+") :type joinChar: str r)collapse_unaryN)rr)r collapsePOS collapseRootjoinCharrs rrzTree.collapse_unarys& 8t[,Arct|tr1|Dcgc]}|j|}}||j|S|Scc}w)a Convert a tree between different subtypes of Tree. ``cls`` determines which class will be used to encode the new tree. :type tree: Tree :param tree: The tree that should be converted. :return: The new Tree. )r rconvertr)clstreerRrs rrz Tree.convertsE dD !8<=u E*=H=t{{H- -K>sAc"|jSrcopyrDs r__copy__z Tree.__copy__$syy{rc&|jdS)NTdeepr)rmemos r __deepcopy__zTree.__deepcopy__'syydy##rcr|st||j|St|j|Sr)r rr)rrs rrz Tree.copy*s14:dkk40 0:%%d+ +rcddlm}|S)Nr) ImmutableTree)nltk.tree.immutabler)rrs r _frozen_classzTree._frozen_class0s 5rc|j}||j|}nG|jd}|jdD]}|||||<|j|}t ||S)NTrrP)rrrrchash)r leaf_freezer frozen_classnewcopyros rfreezez Tree.freeze5s~))+  "**40GiiTi*G,,X6 :+GCL9  :"**73G W rc Pt|trt|dk7r tdt j d|r td|\}} t j |t j | } } |d| | d}|d| | d}t j| d|d | d |d } dgfg} | j|D]D}|j}|d |k(rft| d k(r't| d d d kDr|j||d|d dj}|||}| j|gf|| k(r|t| d k(r;t| d d d k(r|j|||n|j||d| j\}}| dd j|||t| d k(r|j||||||}| dd j|Gt| d kDr|j|d| nHt| d d d k(r|j|d|n | d d Jt| d d d k(sJ| d d d }|r"|jdk(rt|d k(r|d }|S)a' Read a bracketed tree string and return the resulting tree. Trees are represented as nested brackettings, such as:: (S (NP (NNP John)) (VP (V runs))) :type s: str :param s: The string to read :type brackets: str (length=2) :param brackets: The bracket characters used to mark the beginning and end of trees and subtrees. :type read_node: function :type read_leaf: function :param read_node, read_leaf: If specified, these functions are applied to the substrings of ``s`` corresponding to nodes and leaves (respectively) to obtain the values for those nodes and leaves. They should have the following signature: read_node(str) -> value For example, these functions could be used to process nodes and leaves whose values should be some type other than string (such as ``FeatStruct``). Note that by default, node strings and leaf strings are delimited by whitespace and brackets; to override this default, use the ``node_pattern`` and ``leaf_pattern`` arguments. :type node_pattern: str :type leaf_pattern: str :param node_pattern, leaf_pattern: Regular expression patterns used to find node and leaf substrings in ``s``. By default, both nodes patterns are defined to match any sequence of non-whitespace non-bracket characters. :type remove_empty_top_bracketing: bool :param remove_empty_top_bracketing: If the resulting tree has an empty node label, and is length one, then return its single child instead. This is useful for treebank trees, which sometimes contain an extra level of bracketing. :return: A tree corresponding to the string representation ``s``. If this class method is called using a subclass of Tree, then it will return a tree of that type. :rtype: Tree z"brackets must be a length-2 stringz\szwhitespace brackets not allowedNz[^\sz]+z\s*(z)?|z|()rr4 end-of-stringrq)r r r:r researchescapecompilefinditergroup _parse_errorlstriprQrrr)rsbrackets read_node read_leaf node_pattern leaf_patternremove_empty_top_bracketingopen_bclose_b open_pattern close_patterntoken_rertmatchtokenrKrrs r fromstringzTree.fromstringEsx(C(CMQ,>@A A 99UH %=> >"')yy'8"))G:Lm  "<.rBL  "<.rBL::\=, H   &&q) +EKKMEQx6!u:?s58A;'7!';$$Q?ab ((*(%e,E eR[)'!u:?58A;'1,((E6:((E?C"'))+xb ! ##Cx$89u:?$$Qv6(%e,Eb ! ##E*3 +8 u:>   Q 9 q!  "   Q 88A;& &&uQx{#q( ((Qx{1~ '4;;"+<Ta7D rc|dk(rt|d}}n |j|j}}d|j||d|fz}|j ddj dd}|}t||dzkDr |d|dzd z}|dkDr d ||dz dz}d }|d j d |dd |zzz }t |)z Display a friendly error message when parsing a tree string fails. :param s: The string we're parsing. :param match: regexp match of the problem token. :param expecting: what we expected to see instead. rz0%s.read(): expected %r but got %r %sat index %d.z    Nz... z {}"{}" {}^z )r:ryrr replaceformatrx)rrr expectingrormsgoffsets rrzTree._parse_errors O #QC CA LL     E   IIdC ( (s 3 q6C"H *C"H %A 8#(* %AF %%h3"v+3FGGorc t|tk(rYt|dkDrJt|d}t|dkDr,t ||ddDcgc]}|j |c}S|Syycc}w)z :type l: list :param l: a tree represented as nested lists :return: A tree corresponding to the list representation ``l``. :rtype: Tree Convert nested lists to a NLTK Tree rr4N)r rr:reprrfromlist)rlrKrRs rrz Tree.fromlistsj 7d?s1vz1JE1vzEQqrU#KECLL$7#KLL *?$Ls A- c ddlm}||y)zP Open a new window containing a graphical diagram of this tree. r) draw_treesN)nltk.draw.treer)rrs rdrawz Tree.draws .4rc Zddlm}t||||jdi||y)z Pretty-print this tree as ASCII or Unicode art. For explanation of the arguments, see the documentation for `nltk.tree.prettyprinter.TreePrettyPrinter`. r)TreePrettyPrinterfileNr)nltk.tree.prettyprinterrprinttext)rsentence highlightstreamkwargsrs r pretty_printzTree.pretty_prints- > ?h :??I&IPVWrcdjd|D}djt|jt |j |S)Nz, c32K|]}t|ywr)r)r]cs rr`z Tree.__repr__..s3T!W3sz {}({}, [{}]))joinrr r rr)rchildstrs r__repr__z Tree.__repr__sE993d33$$ J       rc:ddlm}||jS)Nr) draw_tree)svglingr _repr_svg_)rrs rrzTree._repr_svg_ s%))++rc"|jSr)pformatrDs r__str__z Tree.__str__s||~rc \d|vr |d}|d=nd}t|jdi||y)zH Print a string representation of this Tree to 'stream' rNrr)rr)rrrs rpprintz Tree.pprints; v H%Fx F ldll$V$62rc \|j|||}t||z|kr|St|jtr|d|j|}n|dt |j|}|D]}t|t r(|dd|dzzz|j||dz|||zz };t|tr!|dd|dzzzdj|zz }lt|tr|s|dd|dzzzd|zzz }|dd|dzzzt |zz }||dzS)aI :return: A pretty-printed string representation of this tree. :rtype: str :param margin: The right margin at which to do line-wrapping. :type margin: int :param indent: The indentation level at which printing begins. This number is used to decide how far to indent subsequent lines. :type indent: int :param nodesep: A string that is used to separate the node from the children. E.g., the default value ``':'`` gives trees like ``(S: (NP: I) (VP: (V: saw) (NP: it)))``. rrrr/%sr4) _pformat_flatr:r rr rrrr9r)rmarginindentnodesepparensquotesrrRs rrz Tree.pformat!s[   w 7 q6F?V #H dkk3 '!9+dkk]7)4A!9+d4;;/0 :A =E%&VaZ()mmFFQJPQ E5)TC6A:..%@@E3'TC6A:..==TC6A:..e<< =6!9}rctjd}|jddd}dtj|d|zS)a Returns a representation of the tree compatible with the LaTeX qtree package. This consists of the string ``\Tree`` followed by the tree represented in bracketed notation. For example, the following result was generated from a parse tree of the sentence ``The announcement astounded us``:: \Tree [.I'' [.N'' [.D The ] [.N' [.N announcement ] ] ] [.I' [.V'' [.V' [.V astounded ] [.N'' [.N' [.N us ] ] ] ] ] ] ] See https://www.ling.upenn.edu/advice/latex.html for the LaTeX style file for the qtree package. :return: A latex qtree representation of this tree. :rtype: str z([#\$%&~_\{\}])r)z[.z ])rrrz\Tree z\\\1)rrrsub)rreserved_charsrs rpformat_latex_qtreezTree.pformat_latex_qtreeIs?$$67,,aL,I266.'7CCCrctg}|D]}t|tr#|j|j|||6t|tr!|jdj |gt|t r|s|jd|z|jt|t|jt r4dj|d|j|dj ||dSdj|dt|j|dj ||dS)Nrrz {}{}{} {}{}rrr4) r rrQrr9rr rrr)rrrr childstrsrRs rrzTree._pformat_flat`s  .E%&  !4!4Wff!MNE5)  %1E3'  .  e- . dkk3 ' ''q  #q  !''q T[[!#q  rr)rZ)rightNr|^)Trr+)FFr)F)()NNNNF)NrN)FrrrF)8r __module__ __qualname____doc__rrr__ne____gt____le____ge__r)r,r/r2r8r>rBrrErHpropertyrrKrMrPrTrWrcrhrlrorvr}rrr classmethodrrrrrrrrrrrrrrrrrrrrrrrs=~ $ F3F DF >F 1F @@::  &%&X'X)*Y+Y Iy )D  * 1$642.2(J40 !YHJMT2B6  $,   $)vvp<*X ,  3&PD.rrcg}|D]H}t|tr%|jt|j8|j|J|Sr)r rrQrr)rnamesrRs rrkrk}sH E  eT " LLU\\2 3 LL   Lrcddlm}m}d}|j|}t dt |t |j t dt |j t |dt |dt |jt |jt |dt |dt |d|d}|jd|jd t d t ||jd |d <t |t t d |jt |t d|jt |t |dddgd}t dt |t |j|j}t dt |t t dt |jt t dt |jt |jdt |y)z A demonstration showing how Trees and Trees can be used. This demonstration creates a Tree, and loads a Tree from the Treebank corpus, and shows the results of calling several of their methods. r)ProbabilisticTreerzA(S (NP (DT the) (NN cat)) (VP (VBD ate) (NP (DT a) (NN cookie))))z#Convert bracketed string into tree:zDisplay tree properties:r4)r4r4)r4r4rz(JJ big)zTree modification:z (NN cake))r4r4r4zCollapse unary:zChomsky normal form:xyzg?)probzProbabilistic Tree:z0Convert tree to bracketed string and back again:z LaTeX output:zProduction output:)testN)nltkrrrrrrKrWrPinsertrrrrrlrM)rrrtthe_catpts rdemor s- LA A /0 !H !**, $% !'') !A$K !A$K !((* !((* !A$K !D'N !G*dG NN1dooj12  !H-AgJ !H G  !H ! !H G 3c  5B   "I G  $A <= !H G / !   !" G  !--/ GKK  !Hr) r r nltk.grammarrrnltk.internalsrrrrkr __all__rrrr$s<  0%^ 4^ BE R  r