Return a recursive representation of the given pluralization node or tree.
433625
public static String print(Node<PluralType> node) {
    StringBuilder buf = new StringBuilder();
    print(buf, node);
    return buf.toString();
  }
754848
def reverse_toctree(app, doctree, docname):
    """"""
    if docname == "changes":
        for node in doctree.traverse():
            if node.tagname == "toctree" and node.get("glob"):
                node["entries"].reverse()
                break
932389
def pluralize(word, pos=NOUN, gender=MALE, role=SUBJECT, custom={}):
    
    w = word.lower().capitalize()
    if word in custom:
        return custom[word]
    if pos == NOUN:
        for a, b in plural_inflections:
            if w.endswith(a):
                return w[:-len(a)] + b
        # Default rules (baseline = 69%).
        if w.startswith("ge"):
            return w
        if w.endswith("gie"):
            return w
        if w.endswith("e"):
            return w + "n"
        if w.endswith("ien"):
            return w[:-2] + "um"
        if w.endswith(("au", "ein", "eit", "er", "en", "el", "chen", "mus", u"tät", "tik", "tum", "u")):
            return w
        if w.endswith(("ant", "ei", "enz", "ion", "ist", "or", "schaft", "tur", "ung")):
            return w + "en"
        if w.endswith("in"):
            return w + "nen"
        if w.endswith("nis"):
            return w + "se"
        if w.endswith(("eld", "ild", "ind")):
            return w + "er"
        if w.endswith("o"):
            return w + "s"
        if w.endswith("a"):
            return w[:-1] + "en"
        # Inflect common umlaut vowels: Kopf => Köpfe.
        if w.endswith(("all", "and", "ang", "ank", "atz", "auf", "ock", "opf", "uch", "uss")):
            umlaut = w[-3]
            umlaut = umlaut.replace("a", u"ä")
            umlaut = umlaut.replace("o", u"ö")
            umlaut = umlaut.replace("u", u"ü")
            return w[:-3] + umlaut + w[-2:] + "e"
        for a, b in (
          ("ag",  u"äge"), 
          ("ann", u"änner"), 
          ("aum", u"äume"), 
          ("aus", u"äuser"), 
          ("zug", u"züge")):
            if w.endswith(a):
                return w[:-len(a)] + b
        return w + "e"
    return w
66181
def to_tree_s
      str = ''

      each do |node, mode, stack|
        if mode == :on_enter
          begin
            branch_mark = node.parent.nil? ? '' :
              node.parent.smaller == node ? '<' :
              node.parent.equal == node ? '=' :
              node.parent.larger == node ? '>' : '@'

            str += "#{node.text_tree_prefix}#{branch_mark}-" +
              "#{node.smaller || node.equal || node.larger ? 'v-' : '--'}" +
              "#{node.to_s}\n"
          rescue
            str += "#{node.text_tree_prefix}- @@@@@@@@@@\n"
          end
        end
      end

      str
    end
991225
def rule_factory(plural, singular):
    """"""
    @rules.rule(plural)
    def f(path, values):
        for v in values:
            if v:
                elem = etree.Element(
                    '{{http://purl.org/dc/elements/1.1/}}{0}'.format(singular))
                elem.text = v
                yield elem
    f.__name__ = plural
    return f
1356096
def _to_dict(self, node):
        
        if node == BLANK_NODE:
            return {}

        node_type = self._get_node_type(node)

        if is_key_value_type(node_type):
            nibbles = without_terminator(unpack_to_nibbles(node[0]))
            key = b'+'.join([to_string(x) for x in nibbles])
            if node_type == NODE_TYPE_EXTENSION:
                sub_dict = self._to_dict(self._decode_to_node(node[1]))
            else:
                sub_dict = {to_string(NIBBLE_TERMINATOR): node[1]}

            # prepend key of this node to the keys of children
            res = {}
            for sub_key, sub_value in sub_dict.items():
                full_key = (key + b'+' + sub_key).strip(b'+')
                res[full_key] = sub_value
            return res

        elif node_type == NODE_TYPE_BRANCH:
            res = {}
            for i in range(16):
                sub_dict = self._to_dict(self._decode_to_node(node[i]))

                for sub_key, sub_value in sub_dict.items():
                    full_key = (
                        str_to_bytes(
                            str(i)) +
                        b'+' +
                        sub_key).strip(b'+')
                    res[full_key] = sub_value

            if node[16]:
                res[to_string(NIBBLE_TERMINATOR)] = node[-1]
            return res
368504
def get_type_plural(self):
        
        t = self.get_type()
        if t:
            if hasattr(t, 'get_plural'):
                return t.get_plural()
            if t == type(self)._meta.verbose_name:
                return unicode(type(self)._meta.verbose_name_plural)
            return u"{0}s".format(t)

        return unicode(type(self)._meta.verbose_name_plural)
848832
def get_children_treepos(self, treepos):
        """"""
        children_treepos = []
        for i, child in enumerate(self.dgtree[treepos]):
            if isinstance(child, nltk.Tree):
                children_treepos.append(child.treeposition())
            elif is_leaf(child):
                # we can't call .treeposition() on a leaf node
                treepos_list = list(treepos)
                treepos_list.append(i)
                leaf_treepos = tuple(treepos_list)
                children_treepos.append(leaf_treepos)
        return children_treepos
1341445
def lazy_gettext(self, singular, plural=None, n=1, locale=None) -> LazyProxy:
        
        return LazyProxy(self.gettext, singular, plural, n, locale)
512459
def tree_to_dict(cls, tree):
        
        specs = {}
        for k in tree.keys():
            spec_key = '.'.join(k)
            specs[spec_key] = {}
            for grp in tree[k].groups:
                kwargs = tree[k].groups[grp].kwargs
                if kwargs:
                    specs[spec_key][grp] = kwargs
        return specs
1077742
def visit_ellipsis(self, node, parent):
        """"""
        return nodes.Ellipsis(
            getattr(node, "lineno", None), getattr(node, "col_offset", None), parent
        )
1036547
def _make_node(self, singular, plural, variables, plural_expr,
                   vars_referenced, num_called_num):
        """"""
        # no variables referenced?  no need to escape for old style
        # gettext invocations only if there are vars.
        if not vars_referenced and not self.environment.newstyle_gettext:
            singular = singular.replace('%%', '%')
            if plural:
                plural = plural.replace('%%', '%')

        # singular only:
        if plural_expr is None:
            gettext = nodes.Name('gettext', 'load')
            node = nodes.Call(gettext, [nodes.Const(singular)],
                              [], None, None)

        # singular and plural
        else:
            ngettext = nodes.Name('ngettext', 'load')
            node = nodes.Call(ngettext, [
                nodes.Const(singular),
                nodes.Const(plural),
                plural_expr
            ], [], None, None)

        # in case newstyle gettext is used, the method is powerful
        # enough to handle the variable expansion and autoescape
        # handling itself
        if self.environment.newstyle_gettext:
            for key, value in iteritems(variables):
                # the function adds that later anyways in case num was
                # called num, so just skip it.
                if num_called_num and key == 'num':
                    continue
                node.kwargs.append(nodes.Keyword(key, value))

        # otherwise do that here
        else:
            # mark the return value as safe if we are in an
            # environment with autoescaping turned on
            node = nodes.MarkSafeIfAutoescape(node)
            if variables:
                node = nodes.Mod(node, nodes.Dict([
                    nodes.Pair(nodes.Const(key), value)
                    for key, value in variables.items()
                ]))
        return nodes.Output([node])
1058526
def pluralize(locale, entry, count)
      return entry unless entry.is_a?(Hash) and count
      key = :zero if count == 0 && entry.has_key?(:zero)
      key ||= count <= 1 ? :one : :other
      raise InvalidPluralizationData.new(entry, count) unless entry.has_key?(key)
      entry[key]
    end
390266
def get_relname_and_parent(self, treepos):
        
        node = self.dgtree[treepos]
        node_type = get_node_type(node)
        assert node_type in (TreeNodeTypes.relation_node, TreeNodeTypes.leaf_node)

        parent_pos = self.get_parent_treepos(treepos)
        if parent_pos is None:  # a root node has no upward relation
            return None, None
        else:
            parent_label = self.get_parent_label(treepos)
            grandparent_pos = self.get_parent_treepos(parent_pos)

            if grandparent_pos is None:
                # a tree with only one EDU/leaf and a 'N' parent but no relation
                return None, None
            else:
                grandparent_id = self.get_node_id(grandparent_pos)
                grandparent_label = self.get_parent_label(parent_pos)
                reltype = self.get_reltype(grandparent_label)

                if reltype == 'rst':
                    if parent_label == 'N':
                        return 'span', grandparent_id
                    elif parent_label == 'S':
                        cousins_pos = self.get_cousins_treepos(treepos)
                        assert len(cousins_pos) == 1
                        cousin_id = self.get_node_id(cousins_pos[0])
                        return grandparent_label, cousin_id
                elif reltype == 'multinuc':
                    return grandparent_label, grandparent_id
319706
def to_qtree(self, instring, schema):
        
        root_list = self.to_syntax_tree(instring, schema)
        return qtree_translator.translate(root_list)
418428
def get_raw(tree):
    
    if isinstance(tree, Tree):
        words = []
        for child in tree:
            words.append(get_raw(child))
        return ' '.join(words)
    else:
        return tree
372965
def tree(self, level=0, prefix=''):
        
        text = '%s%s\n' % (prefix, self.value.text)
        prefix = '%s└── ' % ('    ' * level)
        if self._lesser:
            text += self._lesser.tree(level+1, prefix)
        if self._greater:
            text += self._greater.tree(level+1, prefix)
        return text