text:
=pod

=head1 NAME

Bio::EnsEMBL::Compara::RunnableDB::CreateAlignmentChainsJobs

=cut

=head1 SYNOPSIS

my $db      = Bio::EnsEMBL::Compara::DBAdaptor->new($locator);
my $runnableDB = Bio::EnsEMBL::Compara::RunnableDB::CreateAlignmentChainsJobs->new (
                                                    -input_id   => $input_id
                                                    -analysis   => $analysis );
$runnableDB->fetch_input(); #reads from DB
$runnableDB->run();
$runnableDB->output();
$runnableDB->write_output(); #writes to DB

=cut

=head1 DESCRIPTION

=cut

=head1 CONTACT

Abel Ureta-Vidal <abel@ebi.ac.uk>

=cut

=head1 APPENDIX

The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _

=cut

package Bio::EnsEMBL::Compara::Production::GenomicAlignBlock::CreateAlignmentChainsJobs;

use strict;

use Bio::EnsEMBL::Compara::Production::DBSQL::DBAdaptor;
use Bio::EnsEMBL::Hive::DBSQL::AnalysisJobAdaptor;
use Bio::EnsEMBL::Hive::Process;
use Bio::EnsEMBL::Utils::Exception;

our @ISA = qw(Bio::EnsEMBL::Hive::Process);

#my $DEFAULT_DUMP_MIN_SIZE = 11500000;
my $DEFAULT_OUTPUT_METHOD_LINK = "BLASTZ_CHAIN";

sub fetch_input {
  my $self = shift;

  #
  # parameters which can be set either via
  # $self->parameters OR
  # $self->input_id
  #
  $self->{'query_collection'} = undef;
  $self->{'target_collection'} = undef;
  $self->{'query_genome_db'} = undef;
  $self->{'target_genome_db'} = undef;
  $self->{'method_link_species_set'} = undef;
  $self->{'output_method_link'} = undef;

  $self->get_params($self->parameters);
  $self->get_params($self->input_id);

  # create a Compara::DBAdaptor which shares my DBConnection
  $self->{'comparaDBA'} = Bio::EnsEMBL::Compara::Production::DBSQL::DBAdaptor->new(-DBCONN => $self->db->dbc);

  # get DnaCollection of query
  throw("must specify 'query_collection_name' to identify DnaCollection of query")
    unless(defined($self->{'query_collection_name'}));
  $self->{'query_collection'} = $self->{'comparaDBA'}->get_DnaCollectionAdaptor->
                                fetch_by_set_description($self->{'query_collection_name'});
  throw("unable to find DnaCollection with name : ". $self->{'query_collection_name'})
    unless(defined($self->{'query_collection'}));

  # get DnaCollection of target
  throw("must specify 'target_collection_name' to identify DnaCollection of query")
    unless(defined($self->{'target_collection_name'}));
  $self->{'target_collection'} = $self->{'comparaDBA'}->get_DnaCollectionAdaptor->
                                fetch_by_set_description($self->{'target_collection_name'});
  throw("unable to find DnaCollection with name : ". $self->{'target_collection_name'})
    unless(defined($self->{'target_collection'}));

  # get genome_db of query
  throw("must specify 'query_genome_db_id' to identify DnaCollection of query")
    unless(defined($self->{'query_genome_db_id'}));
  $self->{'query_genome_db'} = $self->{'comparaDBA'}->get_GenomeDBAdaptor->
                                fetch_by_dbID($self->{'query_genome_db_id'});
  throw("unable to find genome_db with dbID : ". $self->{'query_genome_db_id'})
    unless(defined($self->{'query_genome_db'}));

  # get genome_db of target
  throw("must specify 'target_genome_db_id' to identify DnaCollection of target")
    unless(defined($self->{'target_genome_db_id'}));
  $self->{'target_genome_db'} = $self->{'comparaDBA'}->get_GenomeDBAdaptor->
                                fetch_by_dbID($self->{'target_genome_db_id'});
  throw("unable to find genome_db with dbID : ". $self->{'target_genome_db_id'})
    unless(defined($self->{'target_genome_db'}));

  # get the MethodLinkSpeciesSet
  throw("must specify a method_link to identify a MethodLinkSpeciesSet")
    unless(defined($self->{'method_link'}));
  if ($self->{'query_genome_db'}->dbID == $self->{'target_genome_db'}->dbID) {
    $self->{'method_link_species_set'} = $self->{'comparaDBA'}->get_MethodLinkSpeciesSetAdaptor->fetch_by_method_link_type_genome_db_ids($self->{'method_link'}, [$self->{'query_genome_db'}->dbID] );
  } else {
    $self->{'method_link_species_set'} = $self->{'comparaDBA'}->get_MethodLinkSpeciesSetAdaptor->fetch_by_method_link_type_genome_db_ids($self->{'method_link'}, [$self->{'query_genome_db'}->dbID, $self->{'target_genome_db'}->dbID] );
  }
  throw("unable to find method_link_species_set for method_link=",$self->{'method_link'}," and the following genome_db_ids ",$self->{'query_genome_db_id'},", ",$self->{'target_genome_db_id'},"\n")
    unless(defined($self->{'method_link_species_set'}));

  $self->print_params;

  return 1;
}

sub run
{
  my $self = shift;
  $self->createAlignmentChainsJobs();
  return 1;
}

sub write_output
{
  my $self = shift;
  my $output_id = "{\'query_genome_db_id\' => \'" . $self->{'query_genome_db_id'} . "\',\'target_genome_db_id\' => \'" . $self->{'target_genome_db_id'} . "\'}";
  $self->dataflow_output_id($output_id, 2);
  return 1;
}

##################################
#
# subroutines
#
##################################

sub get_params {
  my $self         = shift;
  my $param_string = shift;

  return unless($param_string);
  print("parsing parameter string : ",$param_string,"\n");

  my $params = eval($param_string);
  return unless($params);

  foreach my $key (keys %$params) {
    print("  $key : ", $params->{$key}, "\n");
  }

  # from input_id
  $self->{'query_genome_db_id'} = $params->{'query_genome_db_id'} if(defined($params->{'query_genome_db_id'}));
  $self->{'target_genome_db_id'} = $params->{'target_genome_db_id'} if(defined($params->{'target_genome_db_id'}));
  $self->{'query_collection_name'} = $params->{'query_collection_name'} if(defined($params->{'query_collection_name'}));
  $self->{'target_collection_name'} = $params->{'target_collection_name'} if(defined($params->{'target_collection_name'}));
  $self->{'logic_name'} = $params->{'logic_name'} if(defined($params->{'logic_name'}));

  # from parameters
  ## method_link alias for input_method_link, for backwards compatibility
  $self->{'method_link'} = $params->{'method_link'} if(defined($params->{'method_link'}));
  $self->{'method_link'} = $params->{'input_method_link'} if(defined($params->{'input_method_link'}));
  $self->{'output_method_link'} = $params->{'output_method_link'} if(defined($params->{'output_method_link'}));

  return;
}

sub print_params {
  my $self = shift;

  printf(" params:\n");
  printf("   method_link_species_set_id : %d\n", $self->{'method_link_species_set'}->dbID);
  printf("   query_collection           : (%d) %s\n",
         $self->{'query_collection'}->dbID, $self->{'query_collection'}->description);
  printf("   target_collection          : (%d) %s\n",
         $self->{'target_collection'}->dbID, $self->{'target_collection'}->description);
  printf("   query_genome_db           : (%d) %s\n",
         $self->{'query_genome_db'}->dbID, $self->{'query_genome_db'}->name);
  printf("   target_genome_db          : (%d) %s\n",
         $self->{'target_genome_db'}->dbID, $self->{'target_genome_db'}->name);
}

sub createAlignmentChainsJobs
{
  my $self = shift;

  #my $analysis = $self->db->get_AnalysisAdaptor->fetch_by_logic_name('AlignmentChains');
  my $analysis = $self->db->get_AnalysisAdaptor->fetch_by_logic_name($self->{'logic_name'});

  my (%qy_dna_hash, %tg_dna_hash);

  foreach my $obj (@{$self->{'query_collection'}->get_all_dna_objects}) {
    my @dna_chunks;
    if ($obj->isa("Bio::EnsEMBL::Compara::Production::DnaFragChunkSet")) {
      push @dna_chunks, @{$obj->get_all_DnaFragChunks};
    } else {
      push @dna_chunks, $obj;
    }
    foreach my $chunk (@dna_chunks) {
      my $dnafrag = $chunk->dnafrag;
      if (not exists $qy_dna_hash{$dnafrag->dbID}) {
        $qy_dna_hash{$dnafrag->dbID} = $dnafrag;
      }
    }
  }
  my %target_dna_hash;
  foreach my $dna_object (@{$self->{'target_collection'}->get_all_dna_objects}) {
    my @dna_chunks;
    if ($dna_object->isa('Bio::EnsEMBL::Compara::Production::DnaFragChunkSet')) {
      push @dna_chunks, @{$dna_object->get_all_DnaFragChunks};
    } else {
      push @dna_chunks, $dna_object;
    }
    foreach my $chunk (@dna_chunks) {
      my $dnafrag = $chunk->dnafrag;
      if (not exists $tg_dna_hash{$dnafrag->dbID}) {
        $tg_dna_hash{$chunk->dnafrag->dbID} = $dnafrag;
      }
    }
  }

  my $count=0;

  my $sql = "select g2.dnafrag_id from genomic_align g1, genomic_align g2 where g1.method_link_species_set_id = ? and g1.genomic_align_block_id=g2.genomic_align_block_id and g1.dnafrag_id = ? and g1.genomic_align_id != g2.genomic_align_id group by g2.dnafrag_id";
  my $sth = $self->{'comparaDBA'}->dbc->prepare($sql);

  my $reverse_pairs; # used to avoid getting twice the same results for self-comparisons
  foreach my $qy_dnafrag_id (keys %qy_dna_hash) {
    $sth->execute($self->{'method_link_species_set'}->dbID, $qy_dnafrag_id);

    my $tg_dnafrag_id;
    $sth->bind_columns(\$tg_dnafrag_id);
    while ($sth->fetch()) {

      next unless exists $tg_dna_hash{$tg_dnafrag_id};
      next if (defined($reverse_pairs->{$qy_dnafrag_id}->{$tg_dnafrag_id}));

      my $input_hash = {};
      $input_hash->{'qyDnaFragID'} = $qy_dnafrag_id;
      $input_hash->{'tgDnaFragID'} = $tg_dnafrag_id;

      if ($self->{'query_collection'}->dump_loc) {
        my $nib_file = $self->{'query_collection'}->dump_loc
            . "/"
            . $qy_dna_hash{$qy_dnafrag_id}->name
            . ".nib";
        if (-e $nib_file) {
          $input_hash->{'query_nib_dir'} = $self->{'query_collection'}->dump_loc;
        }
      }
      if ($self->{'target_collection'}->dump_loc) {
        my $nib_file = $self->{'target_collection'}->dump_loc
            . "/"
            . $tg_dna_hash{$tg_dnafrag_id}->name
            . ".nib";
        if (-e $nib_file) {
          $input_hash->{'target_nib_dir'} = $self->{'target_collection'}->dump_loc;
        }
      }
      $reverse_pairs->{$tg_dnafrag_id}->{$qy_dnafrag_id} = 1;

      Bio::EnsEMBL::Hive::DBSQL::AnalysisJobAdaptor->CreateNewJob(
            -input_id       => $input_hash,
            -analysis       => $analysis,
            -input_job_id   => $self->input_job->dbID,
      );
      $count++;
    }
  }
  $sth->finish;

  if ($count == 0) {
    # No alignments have been found. Remove the control rule to unblock following analyses
    my $analysis_ctrl_rule_adaptor = $self->db->get_AnalysisCtrlRuleAdaptor;
    $analysis_ctrl_rule_adaptor->remove_by_condition_analysis_url($analysis->logic_name);
    print "No jobs created. Deleting analysis ctrl rule for " . $analysis->logic_name . "\n";
  } else {
    printf("created %d jobs for AlignmentChains\n", $count);
  }

  ## Create new MethodLinkSpeciesSet
  # Use the value set in the parameters or the input_id
  my $output_method_link = $self->{'output_method_link'};
  # Use the output_method_link from the target analysis if the previous is not set
  if (!$output_method_link and $self->{'logic_name'}) {
    my $params = eval($analysis->parameters);
    if ($params->{'output_method_link'}) {
      $output_method_link = $params->{'output_method_link'}
    }
  }
  # Use the default value otherwise
  if (!$output_method_link) {
    $output_method_link = $DEFAULT_OUTPUT_METHOD_LINK;
  }
  my $new_mlss = new Bio::EnsEMBL::Compara::MethodLinkSpeciesSet(
      -species_set => $self->{'method_link_species_set'}->species_set,
      -method_link_type => $output_method_link
    );
  $self->{'comparaDBA'}->get_MethodLinkSpeciesSetAdaptor->store($new_mlss);

}

1;


text:
Explicit lifetimes are also required in structs that hold references.

{struct.play}

redpajama_set_name: RedPajamaGithub


text:
package org.apache.zeppelin.elasticsearch.client;

import org.apache.zeppelin.elasticsearch.action.ActionResponse;

/**
 * Interface that must be implemented by any kind of Elasticsearch client (transport, ...).
 */
public interface ElasticsearchClient {

  ActionResponse get(String index, String type, String id);

  ActionResponse index(String index, String type, String id, String data);

  ActionResponse delete(String index, String type, String id);

  ActionResponse search(String[] indices, String[] types, String query, int size);

  void close();
}


text:
<?xml version="1.0" encoding="utf-8"?>

    <info><title>View Helpers</title></info>

    <para>
        In your view scripts, often it is necessary to perform certain complex functions over and
        over: e.g., formatting a date, generating form elements, or displaying action links. You can
        use helper, or plugin, classes to perform these behaviors for you.
    </para>

    <para>
        A helper is simply a class that implements the interface <classname>Zend\View\Helper</classname>.
        <classname>Helper</classname> simply defines two methods,
        <methodname>setView()</methodname>, which accepts a
        <classname>Zend\View\Renderer</classname> instance/implementation, and
        <methodname>getView()</methodname>, used to retrieve that instance.
        <classname>Zend\View\PhpRenderer</classname> composes a <link
            linkend="zend.loader.plugin-broker">plugin broker</link>, allowing you to
        retrieve helpers, and also provides some method overloading capabilities that allow proxying
        method calls to helpers.
    </para>

    <para>
        As an example, let's say we have a helper class named
        <classname>My\Helper\LowerCase</classname>, which we map in our plugin broker to the name
        "lowercase". We can retrieve or invoke it in one of the following ways:
    </para>

    <programlisting language="php"><![CDATA[
// $view is a PhpRenderer instance

// Via the plugin broker:
$broker = $view->getBroker();
$helper = $broker->load('lowercase');

// Retrieve the helper instance, via the method "plugin",
// which proxies to the plugin broker:
$helper = $view->plugin('lowercase');

// If the helper does not define __invoke(), the following also retrieves it:
$helper = $view->lowercase();

// If the helper DOES define __invoke, you can call the helper
// as if it is a method:
$filtered = $view->lowercase('some value');
]]></programlisting>

    <para>
        The last two examples demonstrate how the <classname>PhpRenderer</classname> uses method
        overloading to retrieve and/or invoke helpers directly, offering a convenience API for end
        users.
    </para>

    <para>
        A large number of helpers are provided in the standard distribution of Zend Framework.  You
        can also register helpers by adding them to the <link
            linkend="zend.loader.plugin-broker">plugin broker</link>, or the plugin locator the
        broker composes. Please refer to the <link linkend="zend.loader.plugin-broker">plugin broker
            documentation</link> for details.
    </para>

        <info><title>Included Helpers</title></info>

        <para>
            Zend Framework comes with an initial set of helper classes, most of which relate to form
            element generation and perform the appropriate output escaping automatically. In
            addition, there are helpers for creating route-based <acronym>URL</acronym>s and
            <acronym>HTML</acronym> lists, as well as declaring variables. Additionally, there are a
            rich set of helpers for providing values for, and rendering, the various HTML
            <head> tags, such as <classname>HeadTitle</classname>,
            <classname>HeadLink</classname>, and <classname>HeadScript</classname>. The currently
            shipped helpers include:
        </para>

        <itemizedlist>
            <listitem>
                <para>
                    <methodname>fieldset($name, $content, $attribs)</methodname>: Creates an
                    <acronym>XHTML</acronym> fieldset. If <varname>$attribs</varname> contains a
                    'legend' key, that value will be used for the fieldset legend. The
                    fieldset will surround the <varname>$content</varname> as provided to
                    the helper.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>form($name, $attribs, $content)</methodname>: Generates an
                    <acronym>XHTML</acronym> form. All <varname>$attribs</varname> are escaped and
                    rendered as <acronym>XHTML</acronym> attributes of the form tag. If
                    <varname>$content</varname> is present and not a boolean
                    <constant>FALSE</constant>, then that content is rendered within the start and
                    close form tags; if <varname>$content</varname> is a boolean
                    <constant>FALSE</constant> (the default), only the opening form tag is
                    generated.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>formButton($name, $value, $attribs)</methodname>: Creates an
                    <button /> element.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>formCheckbox($name, $value, $attribs, $options)</methodname>:
                    Creates an <input type="checkbox" /> element.
                </para>

                <para>
                    By default, when no $value is provided and no $options are
                    present, '0' is assumed to be the unchecked value, and '1'
                    the checked value. If a $value is passed, but no $options
                    are present, the checked value is assumed to be the value
                    passed.
                </para>

                <para>
                    $options should be an array. If the array is indexed, the
                    first value is the checked value, and the second the
                    unchecked value; all other values are ignored. You may also
                    pass an associative array with the keys 'checked' and
                    'unChecked'.
                </para>

                <para>
                    If $options has been passed, if $value matches the checked
                    value, then the element will be marked as checked. You may
                    also mark the element as checked or unchecked by passing a
                    boolean value for the attribute 'checked'.
                </para>

                <para>
                    The above is probably best summed up with some examples:
                </para>

                <programlisting language="php"><![CDATA[
// '1' and '0' as checked/unchecked options; not checked
echo $this->formCheckbox('foo');

// '1' and '0' as checked/unchecked options; checked
echo $this->formCheckbox('foo', null, array('checked' => true));

// 'bar' and '0' as checked/unchecked options; not checked
echo $this->formCheckbox('foo', 'bar');

// 'bar' and '0' as checked/unchecked options; checked
echo $this->formCheckbox('foo', 'bar', array('checked' => true));

// 'bar' and 'baz' as checked/unchecked options; unchecked
echo $this->formCheckbox('foo', null, null, array('bar', 'baz'));

// 'bar' and 'baz' as checked/unchecked options; unchecked
echo $this->formCheckbox('foo', null, null, array(
    'checked' => 'bar',
    'unChecked' => 'baz'
));

// 'bar' and 'baz' as checked/unchecked options; checked
echo $this->formCheckbox('foo', 'bar', null, array('bar', 'baz'));
echo $this->formCheckbox('foo',
                         null,
                         array('checked' => true),
                         array('bar', 'baz'));

// 'bar' and 'baz' as checked/unchecked options; unchecked
echo $this->formCheckbox('foo', 'baz', null, array('bar', 'baz'));
echo $this->formCheckbox('foo',
                         null,
                         array('checked' => false),
                         array('bar', 'baz'));
]]></programlisting>

                <para>
                    In all cases, the markup prepends a hidden element with the
                    unchecked value; this way, if the value is unchecked, you
                    will still get a valid value returned to your form.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>formErrors($errors, $options)</methodname>: Generates an
                    <acronym>XHTML</acronym> unordered list to show errors.
                    <varname>$errors</varname> should be a string or an array of strings;
                    <varname>$options</varname> should be any attributes you want
                    placed in the opening list tag.
                </para>

                <para>
                    You can specify alternate opening, closing, and separator
                    content when rendering the errors by calling several methods
                    on the helper:
                </para>

                <itemizedlist>
                    <listitem>
                        <para>
                            <methodname>setElementStart($string)</methodname>; default is
                            '<ul class="errors"%s"><li>', where %s
                            is replaced with the attributes as specified in
                            <varname>$options</varname>.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <methodname>setElementSeparator($string)</methodname>; default
                            is '</li><li>'.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <methodname>setElementEnd($string)</methodname>; default is
                            '</li></ul>'.
                        </para>
                    </listitem>
                </itemizedlist>
            </listitem>

            <listitem>
                <para>
                    <methodname>formFile($name, $attribs)</methodname>: Creates an
                    <input type="file" /> element.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>formHidden($name, $value, $attribs)</methodname>: Creates an
                    <input type="hidden" /> element.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>formLabel($name, $value, $attribs)</methodname>: Creates a
                    <label> element, setting the <property>for</property> attribute to
                    <varname>$name</varname>, and the actual label text to
                    <varname>$value</varname>. If <emphasis>disable</emphasis> is passed in
                    <property>attribs</property>, nothing will be returned.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>formMultiCheckbox($name, $value, $attribs, $options,
                        $listsep)</methodname>: Creates a list of checkboxes.
                    <varname>$options</varname> should be an associative array, and may be
                    arbitrarily deep. <varname>$value</varname> may be a single value or
                    an array of selected values that match the keys in the
                    <varname>$options</varname> array. <varname>$listsep</varname> is an
                    <acronym>HTML</acronym> break ("<br />") by default. By default, this
                    element is treated as an array; all checkboxes share the same name, and are
                    submitted as an array.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>formPassword($name, $value, $attribs)</methodname>: Creates an
                    <input type="password" /> element.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>formRadio($name, $value, $attribs, $options)</methodname>:
                    Creates a series of <input type="radio" /> elements, one
                    for each of the $options elements. In the $options array, the
                    element key is the radio value, and the element value is the
                    radio label. The $value radio will be preselected for you.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>formReset($name, $value, $attribs)</methodname>: Creates an
                    <input type="reset" /> element.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>formSelect($name, $value, $attribs, $options)</methodname>:
                    Creates a <select>...</select> block, with one
                    <option>one for each of the $options elements. In the
                    $options array, the element key is the option value, and the
                    element value is the option label. The $value option(s) will be
                    preselected for you.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>formSubmit($name, $value, $attribs)</methodname>: Creates an
                    <input type="submit" /> element.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>formText($name, $value, $attribs)</methodname>: Creates an
                    <input type="text" /> element.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>formTextarea($name, $value, $attribs)</methodname>: Creates a
                    <textarea>...</textarea> block.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>url($urlOptions, $name, $reset)</methodname>: Creates a
                    <acronym>URL</acronym> string based on a named route.
                    <varname>$urlOptions</varname> should be an associative array of key/value pairs
                    used by the particular route.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>htmlList($items, $ordered, $attribs, $escape)</methodname>:
                    generates unordered and ordered lists based on the <varname>$items</varname>
                    passed to it. If <varname>$items</varname> is a multidimensional
                    array, a nested list will be built. If the <varname>$escape</varname>
                    flag is <constant>TRUE</constant> (default), individual items will be escaped
                    using the view objects registered escaping mechanisms; pass a
                    <constant>FALSE</constant> value if you want to allow markup in your lists.
                </para>
            </listitem>
        </itemizedlist>

        <para>
            Using these in your view scripts is very easy, here is an example.
            Note that you all you need to do is call them; they will load
            and instantiate themselves as they are needed.
        </para>

        <programlisting language="php"><![CDATA[
// Inside this view script, $this refers to the Zend\View\Renderer\PhpRenderer
// instance rendering the view script.
//
// Say that you have already assigned a series of select options under
// the name $countries as array('us' => 'United States', 'il' =>
// 'Israel', 'de' => 'Germany').
?>
<form action="action.php" method="post">

Your Email:
<?php echo $this->formText('email', 'you@example.com', array('size' => 32)) ?>

Your Country:
<?php echo $this->formSelect('country', 'us', null, $this->countries) ?>

Would you like to opt in?
<?php echo $this->formCheckbox('opt_in', 'yes', null, array('yes', 'no')) ?>

</form>
]]></programlisting>

        <para>
            The resulting output from the view script will look something like this:
        </para>

        <programlisting language="php"><![CDATA[
<form action="action.php" method="post">

Your Email:
        <input type="text" name="email" value="you@example.com" size="32" />

Your Country:
        <select name="country">
            <option value="us" selected="selected">United States</option>
            <option value="il">Israel</option>
            <option value="de">Germany</option>
        </select>

Would you like to opt in?
        <input type="hidden" name="opt_in" value="no" />
        <input type="checkbox" name="opt_in" value="yes" checked="checked" />

</form>
]]></programlisting>

        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Zend_View-Helpers-Action.xml"/>
        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Zend_View-Helpers-BaseUrl.xml"/>
        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Zend_View-Helpers-Currency.xml"/>
        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Zend_View-Helpers-Cycle.xml"/>
        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Zend_View-Helpers-Partial.xml"/>
        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Zend_View-Helpers-Placeholder.xml"/>
        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Zend_View-Helpers-Doctype.xml"/>
        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Zend_View-Helpers-HeadLink.xml"/>
        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Zend_View-Helpers-HeadMeta.xml"/>
        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Zend_View-Helpers-HeadScript.xml"/>
        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Zend_View-Helpers-HeadStyle.xml"/>
        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Zend_View-Helpers-HeadTitle.xml"/>
        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Zend_View-Helpers-HtmlObject.xml"/>
        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Zend_View-Helpers-InlineScript.xml"/>
        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Zend_View-Helpers-Json.xml"/>
        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Zend_View-Helpers-Navigation.xml"/>
        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Zend_View-Helpers-Translator.xml"/>

        <info><title>Registering Helpers</title></info>

        <para>
            <classname>Zend\View\Renderer\PhpRenderer</classname> composes a <link
                linkend="zend.loader.plugin-broker">plugin broker</link> for managing helpers,
            specifically an instance of <classname>Zend\View\HelperBroker</classname>, which extends
            the base plugin broker in order to ensure we have valid helpers available. The
            <classname>HelperBroker</classname> by default uses
            <classname>Zend\View\HelperLoader</classname> as its helper locator. The
            <classname>HelperLoader</classname> is a map-based loader, which means that you will
            simply map the helper/plugin name by which you wish to refer to it to the actual class
            name of the helper/plugin.
        </para>

        <para>
            Programmatically, this is done as follows:
        </para>

        <programlisting language="php"><![CDATA[
// $view is an instance of PhpRenderer
$broker = $view->getBroker();
$loader = $broker->getClassLoader();

// Register singly:
$loader->registerPlugin('lowercase', 'My\Helper\LowerCase');

// Register several:
$loader->registerPlugins(array(
    'lowercase' => 'My\Helper\LowerCase',
    'uppercase' => 'My\Helper\UpperCase',
));
]]></programlisting>

        <para>
            Within an MVC application, you will typically simply pass a map of plugins to the class
            via your configuration.
        </para>

        <programlisting language="php"><![CDATA[
// From within a configuration file
return array(
    'di' => array('instance' => array(
        'Zend\View\HelperLoader' => array('parameters' => array(
            'map' => array(
                'lowercase' => 'My\Helper\LowerCase',
                'uppercase' => 'My\Helper\UpperCase',
            ),
        )),
    )),
);
]]></programlisting>

        <para>
            The above can be done in each module that needs to register helpers with the
            <classname>PhpRenderer</classname>; however, be aware that another module can register
            helpers with the same name, so order of modules can impact which helper class will
            actually be registered!
        </para>

        <info><title>Writing Custom Helpers</title></info>

        <para>
            Writing custom helpers is easy. We recommend extending
            <classname>Zend\View\Helper\AbstractHelper</classname>, but at the minimum, you need
            only implement the <classname>Zend\View\Helper</classname> interface:
        </para>

        <programlisting language="php"><![CDATA[
namespace Zend\View;

interface Helper
{
    /**
     * Set the View object
     *
     * @param  Renderer $view
     * @return Helper
     */
    public function setView(Renderer $view);

    /**
     * Get the View object
     *
     * @return Renderer
     */
    public function getView();
}
]]></programlisting>

        <para>
            If you want your helper to be capable of being invoked as if it were a method call of
            the <classname>PhpRenderer</classname>, you should also implement an
            <methodname>__invoke()</methodname> method within your helper.
        </para>

        <para>
            As previously noted, we recommend extending
            <classname>Zend\View\Helper\AbstractHelper</classname>, as it implements the methods
            defined in <classname>Helper</classname>, giving you a headstart in your development.
        </para>

        <para>
            Once you have defined your helper class, make sure you can autoload it, and then <link
                linkend="zend.view.helpers.register">register it with the plugin broker</link>.
        </para>

        <para>
            Here is an example helper, which we're titling "SpecialPurpose"
        </para>

        <programlisting language="php"><![CDATA[
namespace My\View\Helper;

use Zend\View\Helper\AbstractHelper;

class SpecialPurpose extends AbstractHelper
{
    protected $count = 0;

    public function __invoke()
    {
        $this->count++;
        $output = sprintf("I have seen 'The Jerk' %d time(s).", $this->count);
        return htmlspecialchars($output, ENT_QUOTES, 'UTF-8');
    }
}
]]></programlisting>

        <para>
            Then assume that when we <link
                linkend="zend.view.helpers.register">register it with the plugin broker</link>, we
            map it to the string "specialpurpose".
        </para>

        <para>
            Within a view script, you can call the <classname>SpecialPurpose</classname> helper as
            many times as you like; it will be instantiated once, and then it persists for the life
            of that <classname>PhpRenderer</classname> instance.
        </para>

        <programlisting language="php"><![CDATA[
// remember, in a view script, $this refers to the Zend_View instance.
echo $this->specialPurpose();
echo $this->specialPurpose();
echo $this->specialPurpose();
]]></programlisting>

        <para>
            The output would look something like this:
        </para>

        <programlisting language="php"><![CDATA[
I have seen 'The Jerk' 1 time(s).
I have seen 'The Jerk' 2 time(s).
I have seen 'The Jerk' 3 time(s).
]]></programlisting>

        <para>
            Sometimes you will need access to the calling <classname>PhpRenderer</classname> object --
            for instance, if you need to use the registered encoding, or want to render another view
            script as part of your helper. This is why we define the
            <methodname>setView()</methodname> and <methodname>getView()</methodname> methods. As an
            example, we could rewrite the <classname>SpecialPurpose</classname> helper as follows to
            take advantage of the <classname>Escape</classname> helper:
        </para>

        <programlisting language="php"><![CDATA[
namespace My\View\Helper;

use Zend\View\Helper\AbstractHelper;

class SpecialPurpose extends AbstractHelper
{
    protected $count = 0;

    public function __invoke()
    {
        $this->count++;
        $output  = sprintf("I have seen 'The Jerk' %d time(s).", $this->count);
        $escaper = $this->getView()->plugin('escape');
        return $escaper($output);
    }
}
]]></programlisting>

        <info><title>Registering Concrete Helpers</title></info>

        <para>
            Sometimes it is convenient to instantiate a view helper, and then register it with the
            renderer. This can be done by injecting it directly into the plugin broker.
        </para>

        <programlisting language="php"><![CDATA[
// $view is a PhpRenderer instance

$helper = new My_Helper_Foo();
// ...do some configuration or dependency injection...

$view->getBroker()->register('foo', $helper);
]]></programlisting>

        <para>
            When registered, the plugin broker will inject the <classname>PhpRenderer</classname>
            instance into the helper.
        </para>


text:
from bson import ObjectId
from pymongo import MongoClient

from helpers import helpers
from config import (
    mongouri,
    collection_
)

class db(object):
    """db object to interact with data store"""

    def __init__(self):
        self.mongouri = mongouri
        self.client = self.get_client(self.mongouri)
        self.collection_ = collection_
        self.allowed_keys = [
            ("key",          helpers.vnull),
            ("lastmodified", helpers.date_),
            ("etag",         helpers.vnull),
        ]
        pass

    def get_client(self, mongouri):
        """returns mongoclient"""

        client = MongoClient(mongouri)
        return client

    def ingest_(self, data):
        """ingests data to db collection"""

        self.client.renewable_energy_2015[self.collection_].save(data)

    def count_(self):
        """returns count of items in db collection"""

        return self.client.renewable_energy_2015[self.collection_].count()

    def remove_all(self):
        """truncates the db collection"""

        self.client.renewable_energy_2015[self.collection_].remove({})

    def query(self, args):
        """queries the db"""

        q = {}
        args = args.__dict__
        for key, func in self.allowed_keys:
            if args.get(key):
                val = func(args[key])
                q[key] = val
        return [each for each in self.client.renewable_energy_2015[self.collection_].find(q)]


text:
<?php

  namespace osCommerce\OM\Core\Site\Admin\Application\TaxClasses\SQL\ANSI;

  use osCommerce\OM\Core\Registry;

/**
 * @since v3.0.3
 */

  class Delete {
    public static function execute($data) {
      $OSCOM_PDO = Registry::get('PDO');

      $Qclass = $OSCOM_PDO->prepare('delete from :table_tax_class where tax_class_id = :tax_class_id');
      $Qclass->bindInt(':tax_class_id', $data['id']);
      $Qclass->execute();

      return ( $Qclass->rowCount() === 1 );
    }
  }
?>


text:
/**
 * Onshape REST API
 * The Onshape REST API consumed by all clients.
 *
 * OpenAPI spec version: 1.93
 * Contact: api-support@onshape.zendesk.com
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

export class BTModelTessellationParams {
    'partIds'?: Array<string>;
    'partQuery'?: string;
    'angleTolerance'?: number;
    'chordTolerance'?: number;
    'maxFacetWidth'?: number;
    'outputVertexNormals'?: boolean;
    'outputFacetNormals'?: boolean;
    'outputTextureCoordinates'?: boolean;
    'outputIndexTable'?: boolean;
    'entityIds'?: Array<string>;
    'outputErrorFaces'?: boolean;
    'partId'?: string;
    'elementMicroversionId'?: string;
    'configuration'?: string;
    'documentId'?: string;
    'workspaceId'?: string;
    'elementId'?: string;

    static discriminator: string | undefined = undefined;

    static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
        {
            "name": "partIds",
            "baseName": "partIds",
            "type": "Array<string>"
        },
        {
            "name": "partQuery",
            "baseName": "partQuery",
            "type": "string"
        },
        {
            "name": "angleTolerance",
            "baseName": "angleTolerance",
            "type": "number"
        },
        {
            "name": "chordTolerance",
            "baseName": "chordTolerance",
            "type": "number"
        },
        {
            "name": "maxFacetWidth",
            "baseName": "maxFacetWidth",
            "type": "number"
        },
        {
            "name": "outputVertexNormals",
            "baseName": "outputVertexNormals",
            "type": "boolean"
        },
        {
            "name": "outputFacetNormals",
            "baseName": "outputFacetNormals",
            "type": "boolean"
        },
        {
            "name": "outputTextureCoordinates",
            "baseName": "outputTextureCoordinates",
            "type": "boolean"
        },
        {
            "name": "outputIndexTable",
            "baseName": "outputIndexTable",
            "type": "boolean"
        },
        {
            "name": "entityIds",
            "baseName": "entityIds",
            "type": "Array<string>"
        },
        {
            "name": "outputErrorFaces",
            "baseName": "outputErrorFaces",
            "type": "boolean"
        },
        {
            "name": "partId",
            "baseName": "partId",
            "type": "string"
        },
        {
            "name": "elementMicroversionId",
            "baseName": "elementMicroversionId",
            "type": "string"
        },
        {
            "name": "configuration",
            "baseName": "configuration",
            "type": "string"
        },
        {
            "name": "documentId",
            "baseName": "documentId",
            "type": "string"
        },
        {
            "name": "workspaceId",
            "baseName": "workspaceId",
            "type": "string"
        },
        {
            "name": "elementId",
            "baseName": "elementId",
            "type": "string"
        }    ];

    static getAttributeTypeMap() {
        return BTModelTessellationParams.attributeTypeMap;
    }
}


text:
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <link rel="icon" href="<?=base_url('assets/images/logotitle.png')?>" type="image/gif">
  <title>SI BIMBEL | <?php echo $title; ?></title>

  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">

  <?php echo link_tag('assets/bootstrap/css/bootstrap.min.css');
        echo link_tag('assets/plugins/datatables/jquery.dataTables.min.css"');
        echo link_tag('assets/plugins/datatables/dataTables.bootstrap.css');
  ?>

  <?php echo link_tag('assets/plugins/font-awesome-4.7.0/css/font-awesome.min.css');?>

  <?php echo link_tag('assets/dist/css/AdminLTE.min.css'); ?>

  <?php echo link_tag('assets/dist/css/skins/skin-blue.min.css'); ?>

    <a href="<?php echo current_url();?>" class="logo">

        BFG

      Bimbel Forum Guru

        Toggle navigation

               <img src="<?php echo base_url('assets/images/'.$this->session->foto);?>" class="user-image" alt="User Image"/>
               <?php echo $this->session->nama;?>

                <img src="<?php echo base_url('assets/images/'.$this->session->foto);?>" class="img-circle" alt="User Image"/>

                <?php echo $this->session->nama;?> - Administrator

                   <a href="<?php echo base_url('login/logout')?>" class="btn btn-default btn-flat">Logout

         <img src="<?php echo base_url('assets/images/'.$this->session->foto);?>" class="img-circle" alt="User Image" />s

<?php echo $this->session->nama;?>

           Online

MENU

<a href="<?php echo base_url('dashboard/show')?>"> DASHBOARD

           DATA PENDAFTARAN

<a href="<?php echo base_url('data/siswa/show')?>"> Siswa Bimbel

<a href="<?php echo base_url('data/wali/show')?>"> Wali / Orang Tua

<a href="<?php echo base_url('data/tentor/show')?>"> Tentor / Pengajar

<a href="<?php echo base_url('data/bimbel/show')?>"> DATA BIMBEL

<a href="<?php echo base_url('data/pembayaran/show')?>"> PEMBAYARAN

<a href="<?php echo base_url('data/penjadwalan/show')?>"> PENJADWALAN

           SETUP

<a href="<?php echo base_url('setup/program-pilihan/show')?>"> Program & Pilihan

<a href="<?php echo base_url('setup/biaya-diskon/show')?>"> Biaya & Diskon

<a href="<?php echo base_url('setup/tahun-ajaran/show')?>"> Tahun Ajaran

<a href="<?php echo base_url('laporan/bimbel-pembayaran')?>"> LAPORAN - LAPORAN

           ADMINISTRATOR

<a href="<?php echo base_url('administrator/show')?>"> Data Administrator

<a href="<?php echo base_url('administrator/setup-akun')?>"> Setup Akun

<a href="<?php echo base_url('login/logout')?>"> LOGOUT

 Home

<?php echo $title ?>

Data Siswa Bimbel

                          <button type="button" class="btn btn-primary btn-sm" onclick="add()"> Data Siswa</button>

                                  Nama Lengkap
                                  Asal Sekolah
                                  Tools

    Copyright © BIMBEL FORUM GURU Malang


text:
from django import template
register = template.Library()

@register.filter(name='get_class')
def get_class(value):
    return value.__class__.__name__


text:
- Run dartfmt.

## 0.1.1
- Add link to medium article in README.

## 0.1.0

- Add a big tournament example.
- Add a tiny drive example.
- Fix some linter complaints.

## 0.0.1+3

- Fix the sheet example.

## 0.0.1+2

- Update README (removing the example and adding the issue tracker).

## 0.0.1+1

- Rename the example file so it's recognized by pub.dartlang.org.

## 0.0.1

- Initial version.


text:
<?php

namespace Sts\Bundle\AppBundle\Entity;

/**
 * Relation between match an players
 */
class PlayerMatch
{
    protected $id;
    protected $player;
    protected $match;
    protected $playerRanking;
    protected $score;
    protected $wins = false;
    protected $draw = false;

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set score
     *
     * @param integer $score
     * @return PlayerMatch
     */
    public function setScore($score)
    {
        $this->score = $score;

        return $this;
    }

    /**
     * Get score
     *
     * @return integer
     */
    public function getScore()
    {
        return $this->score;
    }

    /**
     * Set wins
     *
     * @param boolean $wins
     * @return PlayerMatch
     */
    public function setWins($wins)
    {
        $this->wins = !empty($wins);

        return $this;
    }

    /**
     * Get wins
     *
     * @return boolean
     */
    public function getWins()
    {
        return $this->wins;
    }

    /**
     * Set draw
     *
     * @param boolean $draw
     * @return PlayerMatch
     */
    public function setDraw($draw)
    {
        $this->draw = !empty($draw);

        return $this;
    }

    /**
     * Get draw
     *
     * @return boolean
     */
    public function getDraw()
    {
        return $this->draw;
    }

    /**
     * Set match
     *
     * @param \Sts\Bundle\AppBundle\Entity\Match $match
     * @return PlayerMatch
     */
    public function setMatch(\Sts\Bundle\AppBundle\Entity\Match $match = null)
    {
        $this->match = $match;

        return $this;
    }

    /**
     * Get match
     *
     * @return \Sts\Bundle\AppBundle\Entity\Match
     */
    public function getMatch()
    {
        return $this->match;
    }

    /**
     * Set player
     *
     * @param \Sts\Bundle\AppBundle\Entity\Player $player
     * @return PlayerMatch
     */
    public function setPlayer(\Sts\Bundle\AppBundle\Entity\Player $player = null)
    {
        $this->player = $player;

        return $this;
    }

    /**
     * Get player
     *
     * @return \Sts\Bundle\AppBundle\Entity\Player
     */
    public function getPlayer()
    {
        return $this->player;
    }

    /**
     * Set playerRanking
     *
     * @param \Sts\Bundle\AppBundle\Entity\PlayerRanking $playerRanking
     * @return PlayerMatch
     */
    public function setPlayerRanking(\Sts\Bundle\AppBundle\Entity\PlayerRanking $playerRanking = null)
    {
        $this->playerRanking = $playerRanking;

        return $this;
    }

    /**
     * Get playerRanking
     *
     * @return \Sts\Bundle\AppBundle\Entity\PlayerRanking
     */
    public function getPlayerRanking()
    {
        return $this->playerRanking;
    }
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated by org.testng.reporters.JUnitReportReporter -->
<testsuite hostname="Lana-laptop" name="category.Wishlist_red" tests="1" failures="0" timestamp="30 Jun 2014 11:24:46 GMT" time="45.912" errors="0">
  <testcase name="testUntitled2" time="45.912" classname="category.Wishlist_red"/>
</testsuite> <!-- category.Wishlist_red -->


text:
import React, {Component} from 'react';

export default class IncludeProductMassUpload extends Component {
  render() {
    const styles = require('./includeProductMassUpload.scss');

    return (

            Upload of Specific item or group from SKU/Bin number

        Support file format…"Lorem ipsum dolar"

            <input type="text" className="form-control" placeholder="Choose file" aria-describedby="basic-addon2"/>
            Browse

             Click here to download  format of mass upload

    );
  }
}


text:
ClassHdTP(TBowDocBs, PBowDocBs);

/////////////////////////////////////////////////
// BagOfWords-Keywords-Set
ClassTP(TBowKWordSet, PBowKWordSet)//{
private:
  TStr Nm;
  THash<TStr, TFlt> WStrToWWgtH;
public:
  TBowKWordSet(const TStr& _Nm=""): Nm(_Nm), WStrToWWgtH(){}
  static PBowKWordSet New(const TStr& Nm=""){return new TBowKWordSet(Nm);}
  TBowKWordSet(const TBowKWordSet& BowKWordSet):
    Nm(BowKWordSet.Nm), WStrToWWgtH(BowKWordSet.WStrToWWgtH){}
  TBowKWordSet(TSIn& SIn): Nm(SIn), WStrToWWgtH(SIn){}
  static PBowKWordSet Load(TSIn& SIn){return new TBowKWordSet(SIn);}
  void Save(TSOut& SOut) const {Nm.Save(SOut); WStrToWWgtH.Save(SOut);}

  TBowKWordSet& operator=(const TBowKWordSet& BowKWordSet){
    Nm=BowKWordSet.Nm; WStrToWWgtH=BowKWordSet.WStrToWWgtH; return *this;}

  void PutNm(const TStr& _Nm){Nm=_Nm;}
  TStr GetNm() const {return Nm;}

  void AddKWord(const TStr& KWordStr, const double& KWordWgt){
    WStrToWWgtH.AddDat(KWordStr, KWordWgt);}
  int GetKWords() const {return WStrToWWgtH.Len();}
  bool IsKWordStr(const TStr& KWordStr) const {return WStrToWWgtH.IsKey(KWordStr);}
  int GetKWordN(const TStr& KWordStr) const {return WStrToWWgtH.GetKeyId(KWordStr);}
  TStr GetKWordStr(const int& KWordN) const {return WStrToWWgtH.GetKey(KWordN);}
  double GetKWordWgt(const int& KWordN) const {return WStrToWWgtH[KWordN];}
  void GetWordStrV(TStrV& WordStrV) const;
  TStr GetKWordsStr() const;

  // postprocessing
  void SortByStr();
  void SortByWgt();
  PBowKWordSet GetTopKWords(const int& MxKWords, const double& WgtSumPrc) const;

  // files
  void SaveTxt(const PSOut& SOut) const;
  void SaveTxt(const TStr& FNm) const {
    PSOut SOut=TFOut::New(FNm); SaveTxt(SOut);}
  void SaveXml(const PSOut& SOut) const;
  void SaveXml(const TStr& FNm) const {
    PSOut SOut=TFOut::New(FNm); SaveXml(SOut);}
  void SaveBin(const PSOut& SOut) const {
    Save(*SOut);}
  void SaveBin(const TStr& FNm) const {
    PSOut SOut=TFOut::New(FNm); SaveBin(SOut);}
};

/////////////////////////////////////////////////
// BagOfWords-Keywords-Base
ClassTP(TBowKWordBs, PBowKWordBs)//{
private:
  THash<TStr, PBowKWordSet> SetNmToSetH;
public:
  TBowKWordBs(): SetNmToSetH(){}
  static PBowKWordBs New(){return new TBowKWordBs();}
  TBowKWordBs(const TBowKWordBs& BowKWordBs):
    SetNmToSetH(BowKWordBs.SetNmToSetH){}
  TBowKWordBs(TSIn& SIn): SetNmToSetH(SIn){}
  static PBowKWordBs Load(TSIn& SIn){return new TBowKWordBs(SIn);}
  void Save(TSOut& SOut) const {SetNmToSetH.Save(SOut);}

  TBowKWordBs& operator=(const TBowKWordBs& BowKWordBs){
    SetNmToSetH=BowKWordBs.SetNmToSetH; return *this;}

  // keyword-sets
  void AddKWordSet(const TStr& KWordSetNm, const PBowKWordSet& KWordSet){
    SetNmToSetH.AddDat(KWordSetNm, KWordSet);}
  void AddKWordSet(const PBowKWordSet& KWordSet){
    SetNmToSetH.AddDat(KWordSet->GetNm(), KWordSet);}
  int GetKWordSets() const {return SetNmToSetH.Len();}
  bool IsKWordSset(const TStr& KWordSetNm) const {return SetNmToSetH.IsKey(KWordSetNm);}
  PBowKWordSet GetKWordSet(const int& KWordSetN) const {return SetNmToSetH[KWordSetN];}
  PBowKWordSet GetKWordSet(const TStr& KWordSetNm) const {return SetNmToSetH.GetDat(KWordSetNm);}

  // files
  void SaveTxt(const PSOut& SOut) const;
  void SaveTxt(const TStr& FNm) const {
    PSOut SOut=TFOut::New(FNm); SaveTxt(SOut);}
  void SaveXml(const PSOut& SOut) const;
  void SaveXml(const TStr& FNm) const {
    PSOut SOut=TFOut::New(FNm); SaveXml(SOut);}
  static PBowKWordBs LoadBin(const TStr& FNm){
    TFIn SIn(FNm); return Load(SIn);}
  void SaveBin(const PSOut& SOut) const {
    Save(*SOut);}
  void SaveBin(const TStr& FNm) const {
    PSOut SOut=TFOut::New(FNm); SaveBin(SOut);}
};

/////////////////////////////////////////////////
// BagOfWords-WordId-Weight-Types
typedef TIntSFltKd TBowWIdWgtKd;
typedef TBowWIdWgtKd* PBowWIdWgtKd;
typedef TVec<TBowWIdWgtKd> TBowWIdWgtKdV;
typedef TVec<TBowWIdWgtKdV> TBowWIdWgtKdVV;

/////////////////////////////////////////////////
// BagOfWords-Sparse-Vector
ClassTPV(TBowSpV, PBowSpV, TBowSpVV)//{
private:
  TInt DId;
  TFlt Norm;
  TBowWIdWgtKdV WIdWgtKdV;
  UndefCopyAssign(TBowSpV);
public:
  TBowSpV(const int& _DId=-1, const int& ExpWIds=0):
    DId(_DId), Norm(-1), WIdWgtKdV(ExpWIds, 0){}
  static PBowSpV New(const int& DId=-1, const int& ExpWIds=0){
    return PBowSpV(new TBowSpV(DId, ExpWIds));}
  TBowSpV(const int& DId, const TFltV& FullVec, const double& Eps=1e-14);
  static PBowSpV New(const int& DId, const TFltV& FullVec,
    const double& Eps=1e-14) { return PBowSpV(new TBowSpV(DId, FullVec, Eps));}
  TBowSpV(const int& DId, const TIntFltKdV& SpV);
  static PBowSpV New(const int& DId, const TIntFltKdV& SpV) {
    return PBowSpV(new TBowSpV(DId, SpV));}
  TBowSpV(TSIn& SIn):
    DId(SIn), Norm(SIn), WIdWgtKdV(SIn){}
  static PBowSpV Load(TSIn& SIn){return new TBowSpV(SIn);}
  void Save(TSOut& SOut) const {
    DId.Save(SOut); Norm.Save(SOut); WIdWgtKdV.Save(SOut);}

  // general
  void Clr(){DId=-1; WIdWgtKdV.Clr();}
  void GenMx(const int& MxWIds){WIdWgtKdV.Gen(MxWIds, 0);}
  void Sort(){WIdWgtKdV.Sort();}
  void Trunc(){WIdWgtKdV.Trunc();}
  int Len() const {return WIdWgtKdV.Len();}
  int Reserved() const {return WIdWgtKdV.Reserved();}

  // doc-id
  void PutDId(const int& _DId){DId=_DId;}
  int GetDId() const {return DId;}
  bool IsDId() const {return DId!=-1;}

  // iterators
  PBowWIdWgtKd BegI() const {return WIdWgtKdV.BegI();}
  PBowWIdWgtKd EndI() const {return WIdWgtKdV.EndI();}
  PBowWIdWgtKd GetI(const int& ValN) const {return WIdWgtKdV.GetI(ValN);}

  // normal
  void AssignNorm(const double& _Norm){Norm=_Norm;}
  void PutUnitNorm();
  double GetNorm();

  // word-id/weights
  void AddWIdWgt(const int& WId, const double& Wgt){
    WIdWgtKdV.Add(TBowWIdWgtKd(WId, (sdouble)Wgt));}
  int GetWIds() const {return WIdWgtKdV.Len();}
  int GetWIdN(const int& WId) const {return WIdWgtKdV.SearchForw(TBowWIdWgtKd(WId));}
  bool IsWId(const int& WId) const {return WIdWgtKdV.SearchForw(TBowWIdWgtKd(WId))!=-1;}
  int GetWId(const int& WIdN) const {return WIdWgtKdV[WIdN].Key;}
  TSFlt& GetWgt(const int& WIdN){return WIdWgtKdV[WIdN].Dat;}
  void GetWIdWgt(const int& WIdN, int& WId, double& Wgt) const {
    const TBowWIdWgtKd& WIdWgtKd=WIdWgtKdV[WIdN];
    WId=WIdWgtKd.Key; Wgt=WIdWgtKd.Dat;}
  void GetWordStrWgtPrV(const PBowDocBs& BowDocBs,
   const int& TopWords, const double& TopWordsWgtPrc,
   TStrFltPrV& WordStrWgtPrV) const;
  PBowKWordSet GetKWordSet(const PBowDocBs& BowDocBs) const;
  int GetLastWId() const { return WIdWgtKdV.Last().Key; }
  void GetIntFltKdV(TIntFltKdV& SpV) const;

  // cut low frequency words
  void CutLowWgtWords(const double& CutWordWgtSumPrc);

  // strings
  TStr GetStr(const PBowDocBs& BowDocBs,
   const int& TopWords=-1, const double& TopWordsWgtPrc=1, const TStr& SepStr=" ",
   const bool& ShowWeightsP=true, const bool& KeepUndelineP=true) const;

  // files
  void SaveTxt(const PSOut& SOut, const PBowDocBs& BowDocBs,
   const int& TopWords=-1, const double& TopWordsWgtPrc=1,
   const char& SepCh=' ') const;
  void SaveXml(const PSOut& SOut, const PBowDocBs& BowDocBs) const;
};

/////////////////////////////////////////////////
// BagOfWords-Similarity-Matrix
ClassTP(TBowSimMtx, PBowSimMtx)//{
private:
  TIntV MtxDIdV;
  TIntPrFltH DIdPrToSimH;
public:
  TBowSimMtx(): MtxDIdV(), DIdPrToSimH(){}
  static PBowSimMtx New(){return new TBowSimMtx();}
  TBowSimMtx(TSIn& SIn): MtxDIdV(SIn), DIdPrToSimH(SIn){}
  static PBowSimMtx Load(TSIn& SIn){return new TBowSimMtx(SIn);}
  void Save(TSOut& SOut) const {MtxDIdV.Save(SOut); DIdPrToSimH.Save(SOut);}

  TBowSimMtx& operator=(const TBowSimMtx&){Fail; return *this;}

  // doc-ids
  int GetDocs() const {return MtxDIdV.Len();}
  int GetMtxDId(const int& MtxDIdN) const {return MtxDIdV[MtxDIdN];}
  void GetDIdV(TIntV& _MtxDIdV) const {_MtxDIdV=MtxDIdV;}

  // similarity
  double GetSim(const int& DId1, const int& DId2) const;

  // files
  static PBowSimMtx LoadTxt(const TStr& FNm);
};

/////////////////////////////////////////////////
// BagOfWords-Similarity
typedef enum {bstUndef, bstBlock, bstEucl, bstCos, bstMtx} TBowSimType;

ClassTP(TBowSim, PBowSim)//{
private:
  TInt SimType; // TBowSimType
  PBowSimMtx SimMtx;
public:
  TBowSim(const TBowSimType& _Type=bstUndef, const PBowSimMtx& _SimMtx=NULL):
    SimType(_Type), SimMtx(_SimMtx){}
  static PBowSim New(const TBowSimType& SimType, const PBowSimMtx& SimMtx=NULL){
    return new TBowSim(SimType, SimMtx);}
  TBowSim(TSIn& SIn): SimType(SIn), SimMtx(SIn){}
  static PBowSim Load(TSIn& SIn){return new TBowSim(SIn);}
  void Save(TSOut& SOut) const {SimType.Save(SOut); SimMtx.Save(SOut);}

  TBowSim& operator=(const TBowSim&){Fail; return *this;}

  // typed similarity
  TBowSimType GetSimType() const {return TBowSimType(int(SimType));}
  double GetSim(const int& DId1, const int& DId2) const;
  double GetSim(const PBowSpV& SpV1, const PBowSpV& SpV2) const;
  double GetSim(const TBowSpVV& SpVV1, const TBowSpVV& SpVV2) const;

  // similarity functions
  static double GetBlockSim(const PBowSpV& SpV1, const PBowSpV& SpV2);
  static double GetEuclSim(const PBowSpV& SpV1, const PBowSpV& SpV2);
  static double GetCosSim(const PBowSpV& SpV1, const PBowSpV& SpV2);
  static double GetCosSim(const PBowSpV& SpV1, const PBowSpV& SpV2,
   TFltIntPrV& WgtWIdPrV);

  // similarity functions
  static TBowSimType GetSimType(const TStr& Nm);
};

/////////////////////////////////////////////////
// BagOfWords-Document-Weights-Base
typedef enum {bwwtUndef,
  bwwtEq, // vectors directly copied from BowDocBs
  bwwtNrmEq, // + normalized to norm 1.0
  bwwtBin, // features changed to binary (1.0 if nonzero, else 0.0)
  bwwtNrmBin, // + normalized
  bwwtNrm01, // each feature is normalized between 0.0 and 1.0
  bwwtNrmTFIDF, // x[i] = TF[i] * log(Docs/DF[i]) and normalized
  bwwtLogDFNrmTFIDF, // x[i] = log(1+DF[i]) * TF[i] * log(Docs/DF[i]) and normalized
  bwwtNrmTFICF, //
  bwwtPreCalc, // weights are passed as a parameter (use function NewPreCalcWgt)
  bwwtSvm // wegiths are calculated using SVM (use function NewSvmWgt)
} TBowWordWgtType;

ClassTP(TBowDocWgtBs, PBowDocWgtBs)//{
private:
  TInt Sig; // signature
  TInt BowDocBsSig; // corresponding BowDocBs signature
  TInt WordWgtType;
  TFlt CutWordWgtSumPrc;
  TInt MnWordFq;
  TIntV DIdV;
  TFltV WordFqV;
  TBowSpVV DocSpVV;
public:
  TBowDocWgtBs(const int& _BowDocBsSig):
    Sig(TSecTm::GetCurTm().GetAbsSecs()), BowDocBsSig(_BowDocBsSig),
    WordWgtType(), CutWordWgtSumPrc(), MnWordFq(),
    DIdV(), WordFqV(), DocSpVV(){}
  static PBowDocWgtBs New(const int& BowDocBsSig){
    return PBowDocWgtBs(new TBowDocWgtBs(BowDocBsSig));}
  static PBowDocWgtBs New(
   const PBowDocBs& BowDocBs, const TBowWordWgtType& _WordWgtType,
   const double& _CutWordWgtSumPrc=0, const int& _MnWordFq=0,
   const TIntV& _DIdV=TIntV(), const TIntV& BaseDIdV=TIntV(),
   const PNotify& Notify=TNotify::NullNotify);
  // generates weighted bow from precalculated sparse vectors
  static PBowDocWgtBs New(const TVec<PBowSpV>& BowSpVV);
  // generates weighted bow from precalculated word weights
  static PBowDocWgtBs NewPreCalcWgt(const PBowDocBs& BowDocBs,
   const TFltV& WordWgtV, const bool& PutUniteNorm = false,
   const double& _CutWordWgtSumPrc=0, const int& _MnWordFq=0,
   const TIntV& _DIdV=TIntV());
  // generates weighted bow using SVM to generate word weights
  // (uses category information for all documents, therefor
  // not usefull for classification but only for clustering)
  static PBowDocWgtBs NewSvmWgt(
   const PBowDocBs& BowDocBs,
   const PBowDocWgtBs& BowDocWgtBs,
   const TIntV& _TrainDIdV = TIntV(),
   const double& SvmCostParam = 1.0,
   const int& MxTimePerCat = 60,
   const bool& NegFeaturesP = false,
   const TIntV& _DIdV = TIntV(),
   const bool& PutUniteNormP = false,
   const double& _CutWordWgtSumPrc = 0.0,
   const int& _MnWordFq = 0);
  // generates weighted bow using SVM to generate word weights
  // weights are optimized for the given category
  static PBowDocWgtBs NewBinSvmWgt(
   const PBowDocBs& BowDocBs,
   const PBowDocWgtBs& BowDocWgtBs,
   const TStr& CatNm,
   const TIntV& TrainDIdV = TIntV(),
   const double& SvmCostParam = 1.0,
   const double& SvmUnbalanceParam = 1.0,
   const double& MnWgt = 0.0,
   const bool& NegFeaturesP = false,
   const bool& PutUniteNormP = true,
   const bool& AvgNormalP = true,
   const TIntV& _DIdV = TIntV(),
   const double& _CutWordWgtSumPrc = 0.0,
   const int& _MnWordFq = 0);
  TBowDocWgtBs(TSIn& SIn):
    Sig(SIn), BowDocBsSig(SIn),
    WordWgtType(SIn), CutWordWgtSumPrc(SIn), MnWordFq(SIn),
    DIdV(SIn), WordFqV(SIn), DocSpVV(SIn){}
  static PBowDocWgtBs Load(TSIn& SIn){return new TBowDocWgtBs(SIn);}
  void Save(TSOut& SOut) const {
    Sig.Save(SOut); BowDocBsSig.Save(SOut);
    WordWgtType.Save(SOut); CutWordWgtSumPrc.Save(SOut); MnWordFq.Save(SOut);
    DIdV.Save(SOut); WordFqV.Save(SOut); DocSpVV.Save(SOut);}

  TBowDocWgtBs& operator=(const TBowDocWgtBs& BowDocWgtBs){
    Sig=BowDocWgtBs.Sig;
    BowDocBsSig=BowDocWgtBs.BowDocBsSig;
    WordWgtType=BowDocWgtBs.WordWgtType;
    CutWordWgtSumPrc=BowDocWgtBs.CutWordWgtSumPrc;
    MnWordFq=BowDocWgtBs.MnWordFq;
    DIdV=BowDocWgtBs.DIdV;
    WordFqV=BowDocWgtBs.WordFqV;
    DocSpVV=BowDocWgtBs.DocSpVV;
    return *this;}

  // added for the purpose of propagating weights in clustering algorithms
  PBowDocWgtBs GetSubSet(const TIntV& IdSubSet){
    PBowDocWgtBs BowDocWgtBs=TBowDocWgtBs::New(BowDocBsSig);
    *BowDocWgtBs=*this;
    BowDocWgtBs->DIdV=IdSubSet;
    return BowDocWgtBs;}

  // signatures
  int GetSig() const {return Sig;}
  int GetBowDocBsSig() const {return BowDocBsSig;}

  // word weighting functions
  TBowWordWgtType GetWordWgtType() const {
    return TBowWordWgtType(int(WordWgtType));}
  static TBowWordWgtType GetWordWgtTypeFromStr(const TStr& Nm);

  // create-parameters
  double GetCutWordWgtSumPrc() const {return CutWordWgtSumPrc;}
  int GetMnWordFq() const {return MnWordFq;}

  // documents
  int GetDocs() const {return DIdV.Len();}
  int GetDId(const int& DIdN) const {return DIdV[DIdN];}
  PBowSpV GetSpV(const int& DId) const {return DocSpVV[DId];}
  void SetSpV(const int& DId, PBowSpV DocSpV) { DocSpVV[DId] = DocSpV; } //B:

  void GetDIdV(TIntV& _DIdV) const {_DIdV=DIdV;}
  void SetDIdV(const TIntV& _DIdV){DIdV=_DIdV;}

  const TBowSpVV& GetDocSpVV() const { return DocSpVV; }

  // words
  int GetWords() const {return WordFqV.Len();}
  double GetWordFq(const int& WId) const {return WordFqV[WId];}

  // similarity search
  void GetSimDIdV(
   const PBowSpV& RefBowSpV, const PBowSim& BowSim,
   TFltIntKdV& SimDIdKdV, const bool& RefBowSpVInclude=false) const;
  void SaveTxtSimDIdV(
   const PSOut& SOut, const PBowDocBs& BowDocBs,
   const PBowSpV& RefBowSpV, const TFltIntKdV& SimDIdKdV,
   const int& TopHits=-1, const double& MnSim=0, const int& TopDocWords=-1,
   const char& SepCh=' ') const;
  void SaveXmlSimDIdV(
   const PSOut& SOut, const PBowDocBs& BowDocBs,
   const PBowSpV& RefBowSpV, const TFltIntKdV& SimDIdKdV,
   const int& TopHits=-1, const double& MnSim=0) const;

  // statistics files
  void SaveTxtStat(
   const TStr& StatFNm, const PBowDocBs& BowDocBs,
   const bool& SaveWordsP=true, const bool& SaveCatsP=true,
   const bool& SaveDocsP=true) const;

  // binary files
  static const TStr BowDocWgtBsFExt;
  static PBowDocWgtBs LoadBin(const TStr& FNm){
    TFIn SIn(FNm); return Load(SIn);}
  void SaveBin(const TStr& FNm) const {
    TFOut SOut(FNm); Save(SOut);}
};

/////////////////////////////////////////////////
// BagOfWords-Word-Description
class TBowWordDesc{
public:
  TInt Fq;
  TFlt MnVal;
  TFlt MxVal;
public:
  TBowWordDesc():
    Fq(0), MnVal(0), MxVal(0){}
  TBowWordDesc(const int& _Fq, const double& _MnVal, const double& _MxVal):
    Fq(_Fq), MnVal(_MnVal), MxVal(_MxVal){}

  TBowWordDesc(TSIn& SIn):
    Fq(SIn), MnVal(SIn), MxVal(SIn){}
  void Save(TSOut& SOut) const {
    Fq.Save(SOut); MnVal.Save(SOut); MxVal.Save(SOut);}

  TBowWordDesc& operator=(const TBowWordDesc& BowWordDesc){
    Fq=BowWordDesc.Fq; MnVal=BowWordDesc.MnVal; MxVal=BowWordDesc.MxVal;
    return *this;}
  bool operator==(const TBowWordDesc& BowWordDesc) const {
    return Fq==BowWordDesc.Fq;}
  bool operator<(const TBowWordDesc& BowWordDesc) const {
    return Fq<BowWordDesc.Fq;}
};
typedef TPair<TBowWordDesc, TStr> TBowWordDescStrPr;
typedef TVec<TBowWordDescStrPr> TBowWordDescStrPrV;

/////////////////////////////////////////////////
// BagOfWords-Document-Base
ClassTP(TBowDocBs, PBowDocBs)//{
private:
  TInt Sig; // signature
  PNGramBs NGramBs; // ngram-base
  PSwSet SwSet; // stop-words
  PStemmer Stemmer; // stemmer
  TStrStrH DocNmToDescStrH; // document-names & descriptions (key-id==doc-id)
  THash<TStr, TBowWordDesc> WordStrToDescH; // word-strings (key-id==word-id)
  //THash<TStr, TBowWordDesc, TStrHashF_OldGLib> WordStrToDescH; // word-strings (key-id==word-id) ...for old GLib
  TStrIntH CatNmToFqH; // category-name to frequency (key-id==cat-id)
  TBowSpVV DocSpVV; // vector of document word-id vectors (DocSpVV[DId])
  TStrV DocStrV; // vector of original document strings
  TVec<TIntV> DocCIdVV; // vector of cat-id vectors (DocCIdVV[DId])
  TIntV TrainDIdV; // vector of training doc-ids
  TIntV TestDIdV; // vector of testing doc-ids
public:
  TBowDocBs():
    Sig(TSecTm::GetCurTm().GetAbsSecs()),
    NGramBs(), SwSet(), Stemmer(),
    DocNmToDescStrH(), WordStrToDescH(), CatNmToFqH(),
    DocSpVV(), DocStrV(), DocCIdVV(),
    TrainDIdV(), TestDIdV(){}
  static PBowDocBs New(){return new TBowDocBs();}
  static PBowDocBs New(
   const PSwSet& SwSet, const PStemmer& Stemmer, const PNGramBs& NGramBs);
  TBowDocBs(TSIn& SIn):
    Sig(SIn),
    NGramBs(SIn), SwSet(SIn), Stemmer(SIn),
    DocNmToDescStrH(SIn), WordStrToDescH(SIn), CatNmToFqH(SIn),
    DocSpVV(SIn), DocStrV(SIn), DocCIdVV(SIn),
    TrainDIdV(SIn), TestDIdV(SIn){}
  static PBowDocBs Load(TSIn& SIn){return new TBowDocBs(SIn);}
  void Save(TSOut& SOut) const {
    Sig.Save(SOut);
    NGramBs.Save(SOut); SwSet.Save(SOut); Stemmer.Save(SOut);
    DocNmToDescStrH.Save(SOut); WordStrToDescH.Save(SOut); CatNmToFqH.Save(SOut);
    DocSpVV.Save(SOut); DocStrV.Save(SOut); DocCIdVV.Save(SOut);
    TrainDIdV.Save(SOut); TestDIdV.Save(SOut);}

  TBowDocBs& operator=(const TBowDocBs& BowDocBs){
    Sig=BowDocBs.Sig;
    NGramBs=BowDocBs.NGramBs;
    SwSet=BowDocBs.SwSet;
    Stemmer=BowDocBs.Stemmer;
    DocNmToDescStrH=BowDocBs.DocNmToDescStrH;
    WordStrToDescH=BowDocBs.WordStrToDescH;
    CatNmToFqH=BowDocBs.CatNmToFqH;
    DocSpVV=BowDocBs.DocSpVV;
    DocStrV=BowDocBs.DocStrV;
    DocCIdVV=BowDocBs.DocCIdVV;
    TrainDIdV=BowDocBs.TrainDIdV;
    TestDIdV=BowDocBs.TestDIdV;
    return *this;}

  // merge two BowDocBs's
  void AddDocs(const PBowDocBs& BowDocBs);

  // testing correctness
  void AssertOk() const;

  // signature
  int GetSig() const {return Sig;}

  // vocabulary
  void PutNGramBs(const PNGramBs& _NGramBs){NGramBs=_NGramBs;}
  PNGramBs GetNGramBs() const {return NGramBs;}
  void PutSwSet(const PSwSet& _SwSet){SwSet=_SwSet;}
  PSwSet GetSwSet() const {return SwSet;}
  void PutStemmer(const PStemmer& _Stemmer){Stemmer=_Stemmer;}
  PStemmer GetStemmer() const {return Stemmer;}

  // words
  int GetWords() const {return WordStrToDescH.Len();}
  int AddWordStr(const TStr& WordStr){return WordStrToDescH.AddKey(WordStr);}
  bool IsWordStr(const TStr& WordStr) const {
    return WordStrToDescH.IsKey(WordStr);}
  bool IsWordStr(const TStr& WordStr, int& WId) const {
    return WordStrToDescH.IsKey(WordStr, WId);}
  bool IsWId(const int& WId) const {
    return WordStrToDescH.IsKeyId(WId);}
  int GetWId(const TStr& WordStr) const {
    return WordStrToDescH.GetKeyId(WordStr);}
  TStr GetWordStr(const int& WId) const {
    return WordStrToDescH.GetKey(WId);}
  double GetWordMnVal(const int& WId) const {
    return WordStrToDescH[WId].MnVal;}
  double GetWordMxVal(const int& WId) const {
    return WordStrToDescH[WId].MxVal;}
  void PutWordFq(const int& WId, const int& Fq){
    WordStrToDescH[WId].Fq=Fq;}
  int GetWordFq(const int& WId) const {
    return WordStrToDescH[WId].Fq;}
  void GetWordStrVFromHtml(const TStr& HtmlStr, TStrV& WordStrV) const;

  // documents
  int AddDoc(const TStr& DocNm,
   const TStrV& CatNmV, const TIntFltPrV& WIdWgtPrV);
  int AddDoc(const TStr& DocNm,
   const TStrV& CatNmV, const TStrV& WordStrV, const TStr& DocStr=TStr());
  int AddDoc(const TStr& DocNm,
   const TStr& CatNm, const TStrV& WordStrV, const TStr& DocStr=TStr()){
    TStrV CatNmV; CatNmV.Add(CatNm);
    return AddDoc(DocNm, CatNmV, WordStrV, DocStr);}
  int AddHtmlDoc(const TStr& DocNm, const TStrV& CatNmV,
   const TStr& HtmlDocStr, const bool& SaveDocP=false);
  int GetDocs() const {return DocSpVV.Len();}
  PBowSpV GetDocSpV(const int& DId) const {return DocSpVV[DId];}
  void PutDocStr(const int& DId, const TStr& DocStr){DocStrV[DId]=DocStr; }
  TStr GetDocStr(const int& DId) const {return DocStrV[DId];}
  bool IsDocNm(const TStr& DocNm) const {
    return DocNmToDescStrH.IsKey(DocNm);}
  bool IsDocNm(const TStr& DocNm, int& DId) const {
    DId=DocNmToDescStrH.GetKeyId(DocNm); return DId!=-1;}
  TStr GetDocNm(const int& DId) const {
    if (DocNmToDescStrH.Empty()){return TInt::GetStr(DId);}
    else {return DocNmToDescStrH.GetKey(DId);}}
  bool IsDId(const int& DId) const {
    return (0<=DId)&&(DId<DocSpVV.Len());}
  int GetDId(const TStr& DocNm) const {
    return DocNmToDescStrH.GetKeyId(DocNm);}
  void GetAllDIdV(TIntV& DIdV) const;
  int GetDocWIds(const int& DId) const {
    return DocSpVV[DId]->GetWIds();}
  void GetDocWIdFq(
   const int& DId, const int& DocWIdN, int& WId, double& WordFq) const {
    DocSpVV[DId]->GetWIdWgt(DocWIdN, WId, WordFq);}
  int GetDocWIdN(const int& DId, const int& DocWId) const {
    return DocSpVV[DId]->GetWId(DocWId);}
  int GetDocWId(const int& DId, const int& DocWIdN) const {
    return DocSpVV[DId]->GetWId(DocWIdN);}
  void PutDocWFq(const int& DId, const int& DocWIdN, double& WordFq){
    DocSpVV[DId]->GetWgt(DocWIdN)=sdouble(WordFq);}
  double GetDocWFq(const int& DId, const int& DocWIdN) const {
    return DocSpVV[DId]->GetWgt(DocWIdN);}
  bool IsDocWordStr(const int& DId, const TStr& WordStr) const;
  int GetDocCIds(const int& DId) const {
    return DocCIdVV.Empty() ? 0 : DocCIdVV[DId].Len();}
  int GetDocCId(const int& DId, const int& DocCIdN) const {
    return DocCIdVV[DId][DocCIdN];}
  bool IsCatInDoc(const int& DId, const int& CId) const {
    return DocCIdVV[DId].IsIn(CId);}
  void PutDocDescStr(const int& DId, const TStr& DocDescStr){
    DocNmToDescStrH[DId]=DocDescStr;}
  TStr GetDocDescStr(const int& DId) const {
    return DocNmToDescStrH[DId];}
  void PutDateStr(const int& DId, const TStr& DateStr){
    PutDocDescStr(DId, DateStr);}
  TStr GetDateStr(const int& DId) const {
    return GetDocDescStr(DId);}

  // categories
  bool IsCats() const {return GetCats()>0;}
  int GetCats() const {return CatNmToFqH.Len();}
  bool IsCatNm(const TStr& CatNm) const {
    return CatNmToFqH.IsKey(CatNm);}
  bool IsCatNm(const TStr& CatNm, int& CId) const {
    return CatNmToFqH.IsKey(CatNm, CId);}
  bool IsCId(const int& CId) const {
    return CatNmToFqH.IsKeyId(CId);}
  int GetCId(const TStr& CatNm) const {
    return CatNmToFqH.GetKeyId(CatNm);}
  TStr GetCatNm(const int& CId) const {
    return CatNmToFqH.GetKey(CId);}
  int GetCatFq(const int& CId) const {
    return CatNmToFqH[CId];}
  void GetTopCatV(const int& TopCats, TIntStrPrV& FqCatNmPrV) const;
  void AddDocCId(const int& DId, const int& CId){
    CatNmToFqH[CId]++; DocCIdVV[DId].AddUnique(CId);}
  int AddCatNm(const TStr& CatNm){
    return CatNmToFqH.AddKey(CatNm);}

    // train & test documents
  void PutTrainDIdV(const TIntV& DIdV){TrainDIdV=DIdV;}
  void PutTestDIdV(const TIntV& DIdV){TestDIdV=DIdV;}
  void PutTrainDocNmV(const TStrV& DocNmV){
    TrainDIdV.Gen(DocNmV.Len(), 0);
    for (int DocNmN=0; DocNmN<DocNmV.Len(); DocNmN++){
      TrainDIdV.Add(GetDId(DocNmV[DocNmN]));}}
  void PutTestDocNmV(const TStrV& DocNmV){
    TestDIdV.Gen(DocNmV.Len(), 0);
    for (int DocNmN=0; DocNmN<DocNmV.Len(); DocNmN++){
      TestDIdV.Add(GetDId(DocNmV[DocNmN]));}}
  void AddTrainDId(const int& DId){TrainDIdV.Add(DId);}
  int GetTrainDocs() const {return TrainDIdV.Len();}
  int GetTrainDId(const int& DIdN) const {return TrainDIdV[DIdN];}
  void GetTrainDIdV(TIntV& _TrainDIdV){_TrainDIdV=TrainDIdV;}
  void AddTestDId(const int& DId){TestDIdV.Add(DId);}
  int GetTestDocs() const {return TestDIdV.Len();}
  int GetTestDId(const int& DIdN) const {return TestDIdV[DIdN];}
  void GetTestDIdV(TIntV& _TestDIdV){_TestDIdV=TestDIdV;}

  // hold-out & cross-validation creation of training & testing documents
  void SetHOTrainTestDIdV(const double& TestDocsPrc, TRnd& Rnd);
  void SetCVTrainTestDIdV(const int& Folds, const int& FoldN, TRnd& Rnd);

  // sampling
  void GetAbsSampleDIdV(const int& Docs, TRnd& Rnd, TIntV& DIdV) const {
    GetAllDIdV(DIdV); DIdV.Shuffle(Rnd); DIdV.Trunc(Docs);}
  void GetRelSampleDIdV(const double& DocsPrc, TRnd& Rnd, TIntV& DIdV) const {
    IAssert((0<=DocsPrc)&&(DocsPrc<=1));
    int Docs=int(DocsPrc*GetDocs()); GetAbsSampleDIdV(Docs, Rnd, DIdV);}

  // transformation
  PBowDocBs GetLimWordRelFqDocBs(
   const double& MnWordFqPrc, const double& MxWordFqPrc) const;
  PBowDocBs GetLimWordAbsFqDocBs(const int& MnWordFq) const;
  PBowDocBs GetSubDocSet(const TIntV& DIdV) const;
  PBowDocBs GetInvDocBs() const;

  // sparse vectors
  PBowSpV GetSpVFromHtmlStr(
   const TStr& HtmlStr, const PBowDocWgtBs& BowDocWgtBs=NULL) const;
  PBowSpV GetSpVFromHtmlFile(
   const TStr& HtmlFNm, const PBowDocWgtBs& BowDocWgtBs=NULL) const;
  PBowSpV GetSpVFromWIdWgtPrV(
   const TIntFltPrV& WIdWgtPrV, const PBowDocWgtBs& BowDocWgtBs=NULL) const;

  // statistics files
  void SaveTxtStat(const TStr& StatFNm, const bool& SaveWordsP=true,
   const bool& SaveCatsP=true, const bool& SaveDocsP=true) const;

  // binary files
  static const TStr BowDocBsFExt;
  static PBowDocBs LoadBin(const TStr& FNm){
    TFIn SIn(FNm); return Load(SIn);}
  void SaveBin(const TStr& FNm) const {
    TFOut SOut(FNm); Save(SOut);}

  friend class TBowFl;
};


text:
/*
 * NodeJS module, included automatically from SourceJS app.js
 * ExpressJS middleware http://expressjs.com
 * */

var deepExtend = require('deep-extend');

// Module configuration
var globalConfig = global.opts.plugins && global.opts.plugins.pluginName ? global.opts.plugins.pluginName : {};
var config = {
    enabled: true,

    // Public object is exposed to Front-end via options API.
    public: {}
};

// Overwriting base options
deepExtend(config, globalConfig);

/*
 * @param {object} req - Request object
 * @param {object} res - Response object
 * @param {function} next - The callback function
 * */
var processRequest = function (req, res, next) {
    if (!config.enabled) {
        next();
        return;
    }

    // Check if request is targeting Spec
    if (req.specData && req.specData.renderedHtml) {
        // Process req data

        next();
    } else {
        next();
    }
};

exports.process = processRequest;


text:
<?xml version="1.0" encoding="UTF-8"?>
<EmploymentItem>
	<JobTitle></JobTitle>
	<StartDate>2007-01-01</StartDate>
	<EndDate>2011-01-01</EndDate>
	<ExperienceYears>5</ExperienceYears>
	<EmployerName>Eniro Sverige Forsaljning AB Malmo</EmployerName>
	<Description></Description>
</EmploymentItem>


text:
using System;

public static class EVT
{
	public const Int32 flagShow = 1;

	public const Int32 flagCollInhC = 2;

	public const Int32 flagCollInhNC = 4;

	public const Int32 flagTalkInh = 8;

	public const Int32 flagLockFreeInh = 16;

	public const Int32 flagHideInh = 32;

	public const Int32 flagTurn = 128;

	public const Int32 cCollScale = 4;

	public const Int32 collModePush = 2;

	public const Int32 collModeTalk = 4;

	public const Single kNeckRad = 500f;

	public const Single kNeckAngle = 640f;

	public const Single kNeckSpeed = 4f;

	public const Single kNeckNear2 = 1000f;

	public const Single kDefaultHeight = 400f;

	public const Single kCollCutOff = 2048f;

	public const Single kWalkSpeed = 30f;

	public const Single kRunSpeed = 60f;
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>
Uses of Class org.apache.wicket.markup.html.form.Button (Wicket Parent 1.5.7 API)
</TITLE>

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../../../stylesheet.css" TITLE="Style">

      Overview
      Package
      Class
    Use
      Tree
      Deprecated
      Index
      Help

 PREV
 NEXT

  FRAMES
 NO FRAMES

  All Classes

Uses of Class
org.apache.wicket.markup.html.form.Button

Packages that use Button

org.apache.wicket.ajax.markup.html.form

org.apache.wicket.extensions.ajax.markup.html

org.apache.wicket.extensions.markup.html.repeater.data.table.filter

org.apache.wicket.extensions.wizard

Package for working with Wizard components.

org.apache.wicket.markup.html.form

HTML Forms and form components.

Uses of Button in org.apache.wicket.ajax.markup.html.form

Subclasses of Button in org.apache.wicket.ajax.markup.html.form

 class
AjaxButton

          A button that submits the form via ajax.

 class
AjaxFallbackButton

          An ajax submit button that will degrade to a normal request if ajax is not available or
 javascript is disabled.

Uses of Button in org.apache.wicket.extensions.ajax.markup.html

Subclasses of Button in org.apache.wicket.extensions.ajax.markup.html

 class
IndicatingAjaxButton

          A variant of the AjaxButton that displays a busy indicator while the ajax request is in
 progress.

Uses of Button in org.apache.wicket.extensions.markup.html.repeater.data.table.filter

Methods in org.apache.wicket.extensions.markup.html.repeater.data.table.filter that return Button

protected  Button
GoAndClearFilter.getClearButton()

protected  Button
GoFilter.getGoButton()

Methods in org.apache.wicket.extensions.markup.html.repeater.data.table.filter with parameters of type Button

protected  void
GoAndClearFilter.onClearSubmit(Button button)

          This method should be implemented by subclasses to provide behavior for the clear button.

protected  void
GoFilter.onGoSubmit(Button button)

          This method can be overridden by subclasses to provide non-standard behavior for the 'go'
 button.

Uses of Button in org.apache.wicket.extensions.wizard

Subclasses of Button in org.apache.wicket.extensions.wizard

 class
CancelButton

          Models a cancel button in the wizard.

 class
FinishButton

          Models a cancel button in the wizard.

 class
LastButton

          Models a 'last' button in the wizard.

 class
NextButton

          Models a next button in the wizard.

 class
PreviousButton

          Models a previous button in the wizard.

 class
WizardButton

          Base class for buttons that work with the wizard component.

Uses of Button in org.apache.wicket.markup.html.form

Subclasses of Button in org.apache.wicket.markup.html.form

 class
ImageButton

          <input type="image"> component - like Button only with an image.

Methods in org.apache.wicket.markup.html.form that return Button

 Button
Button.setDefaultFormProcessing(boolean defaultFormProcessing)

          Sets the defaultFormProcessing property.

      Overview
      Package
      Class
    Use
      Tree
      Deprecated
      Index
      Help

 PREV
 NEXT

  FRAMES
 NO FRAMES

  All Classes

Copyright © 2006-2012 Apache Software Foundation. All Rights Reserved.


text:
var $collectionContainer = $('.album-covers');
$collectionContainer.empty();
for (var i = 0; i < 12; i++) {
    var $newThumbnail = buildCollectionItemTemplate();
    $collectionContainer.append($newThumbnail);
}


text:
from __future__ import unicode_literals

import re

from .common import InfoExtractor

class BloombergIE(InfoExtractor):
    _VALID_URL = r'https?://www\.bloomberg\.com/video/(?P<name>.+?)\.html'

    _TEST = {
        'url': 'http://www.bloomberg.com/video/shah-s-presentation-on-foreign-exchange-strategies-qurhIVlJSB6hzkVi229d8g.html',
        # The md5 checksum changes
        'info_dict': {
            'id': 'qurhIVlJSB6hzkVi229d8g',
            'ext': 'flv',
            'title': 'Shah\'s Presentation on Foreign-Exchange Strategies',
            'description': 'md5:0681e0d30dcdfc6abf34594961d8ea88',
        },
    }

    def _real_extract(self, url):
        mobj = re.match(self._VALID_URL, url)
        name = mobj.group('name')
        webpage = self._download_webpage(url, name)
        f4m_url = self._search_regex(
            r'<source src="(https?://[^"]+\.f4m.*?)"', webpage,
            'f4m url')
        title = re.sub(': Video$', '', self._og_search_title(webpage))

        return {
            'id': name.split('-')[-1],
            'title': title,
            'formats': self._extract_f4m_formats(f4m_url, name),
            'description': self._og_search_description(webpage),
            'thumbnail': self._og_search_thumbnail(webpage),
        }


text:
var exec = require('child_process').exec;
var path = require('path');
var assert = require('assert');
var spawn = require('child_process').spawn;
function execute(command, callback){
  exec(command, { maxBuffer: Infinity }, function(error, stdout, stderr) {
    callback(stdout);
  });
};

var profiler = path.join(__dirname, '../yprof.js');

describe('formatter tests', function () {
  it('should produce yprof-sync-bottlenecks format', function (done) {
    execute(profiler + ' --format=yprof-sync-bottlenecks test/examples/format-sync-offenders.js', function (output) {
      var lines = output.split("\n").map(function (line) {
        return line.replace(/^\s*(.*?)\s*$/, '$1');
      });
      assert.equal(lines.length, 8);
      lines = lines.slice(2, lines.length - 2);

      assert.ok(lines[0].indexOf('<anonymous>') === 0);
      assert.ok(lines[1].indexOf('Object.<anonymous>') === 0);

      done();
    });
  });
});


text:
./configure --prefix=$PREFIX --without-readline
make

cd src/interfaces/libpq
make install

cd ../..
cd bin/pg_config
make install

cd ../../
cd include
make install


text:
using Microsoft.Azure.Management.Reservations.Models;
using System.Collections.Generic;
using System.Linq;

namespace Microsoft.Azure.Commands.Reservations.Models
{
    public class PSCatalog
    {
        public string ResourceType { get; private set; }

        public string Name { get; private set; }

        public IList<string> Terms { get; private set; }

        public IList<string> Locations { get; private set; }

        public IList<SkuProperty> SkuProperties { get; private set; }

        public IList<SkuRestriction> Restrictions { get; private set; }

        public PSCatalog()
        {

        }

        public PSCatalog(Catalog catalog)
        {
            if (catalog != null)
            {
                ResourceType = catalog.ResourceType;
                Name = catalog.Name;
                Terms = catalog.Terms;
                Locations = catalog.Locations;
                SkuProperties = catalog.SkuProperties;
                Restrictions = catalog.Restrictions;
            }
        }

        public string PrintTerms()
        {
            string builder = "";
            foreach (string term in Terms)
            {
                builder += ", " + term;
            }
            if (builder.Length > 2)
                builder = builder.Substring(2);
            return builder;
        }

        public string PrintLocations()
        {
            string builder = "";
            foreach (string location in Locations)
            {
                builder += ", " + location;
            }
            if (builder.Length > 2)
                builder = builder.Substring(2);
            return builder;
        }

        public string PrintSkuProperties()
        {
            bool first = true;
            string builder = "";
            foreach (SkuProperty skuProperty in SkuProperties)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    builder += "\n";
                }
                builder += $"{skuProperty.Name}: {skuProperty.Value}";
            }
            return builder;
        }

        public string PrintRestrictions()
        {
            bool first = true;
            string builder = "";
            foreach (SkuRestriction restriction in Restrictions)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    builder += "\n";
                }
                string values = restriction.Values.Aggregate("", (current, value) => current + ", " + value);
                values = values.Length > 2 ? values.Substring(2) : values;
                builder += $"Type: {restriction.Type}\nValues: {values}\nReasonCode: {restriction.ReasonCode}";
            }
            return builder;
        }
    }
}


text:
package com.gemstone.gemfire.internal.cache;

import com.gemstone.gemfire.cache.EvictionAttributes;
import com.gemstone.gemfire.cache.Region;

import com.gemstone.gemfire.internal.cache.lru.LRUStatistics;

import java.io.Serializable;

/**
 * Class RegionStatus provides information about
 * Regions. This class is used by the monitoring tool.
 *
 * @author Barry Oglesby
 *
 * @since 5.1
 */
public class RegionStatus implements Serializable {
  private static final long serialVersionUID = 3442040750396350302L;

  protected int numberOfEntries;
  protected long heapSize;

  public RegionStatus() {}

  public RegionStatus(Region region) {
    initialize(region);
  }

  public int getNumberOfEntries() {
    return this.numberOfEntries;
  }

  protected void setNumberOfEntries(int numberOfEntries) {
    this.numberOfEntries = numberOfEntries;
  }

  public long getHeapSize() {
    return this.heapSize;
  }

  private void setHeapSize(long heapSize) {
    this.heapSize = heapSize;
  }

  private void initialize(Region region) {
    setNumberOfEntries(region.size());

    EvictionAttributes ea = region.getAttributes().getEvictionAttributes();
    if (ea != null && ea.getAlgorithm().isLRUMemory()) {
      LocalRegion lr = (LocalRegion) region;
      LRUStatistics stats = ((AbstractLRURegionMap) lr.getRegionMap())._getLruList().stats();
      setHeapSize(stats.getCounter());
    } else {
      setHeapSize(-1);
    }
  }

  @Override
  public String toString() {
    StringBuffer buffer = new StringBuffer();
    buffer
      .append("RegionStatus[")
      .append("numberOfEntries=")
      .append(this.numberOfEntries)
      .append("; heapSize=")
      .append(this.heapSize)
      .append("]");
    return buffer.toString();
  }
}


text:
import {postProcessRawData} from 'neuroglancer/sliceview/backend_chunk_decoders/postprocess';
import {VolumeChunk} from 'neuroglancer/sliceview/volume/backend';
import {CancellationToken} from 'neuroglancer/util/cancellation';
import {decodeJpeg} from 'neuroglancer/async_computation/decode_jpeg_request';
import {requestAsyncComputation} from 'neuroglancer/async_computation/request';

export async function decodeJpegChunk(
    chunk: VolumeChunk, cancellationToken: CancellationToken, response: ArrayBuffer) {
  const chunkDataSize = chunk.chunkDataSize!;
  const decoded = await requestAsyncComputation(
      decodeJpeg, cancellationToken, [response], new Uint8Array(response), chunkDataSize[0],
      chunkDataSize[1] * chunkDataSize[2], chunkDataSize[3] || 1, false);
  await postProcessRawData(chunk, cancellationToken, decoded);
}


text:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        android:orientation="vertical">

        <EditText
            android:id="@+id/etName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="16dp"
            android:hint="@string/app_login_username"
            android:inputType="textEmailAddress"
            android:saveEnabled="false" />

        <EditText
            android:id="@+id/etPassword"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="30dp"
            android:hint="@string/app_login_password"
            android:inputType="textPassword"
            android:saveEnabled="false" />

        <TextView
            android:id="@+id/btnLogin"
            android:layout_width="300dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:background="@drawable/regbtn_states"
            android:gravity="center"
            android:text="@string/app_login_btn_login"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="@android:color/white"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tvForgotPassword"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="end"
            android:layout_margin="10dp"
            android:text="@string/new_password_forgot_password_message"
            android:textAppearance="?android:attr/textAppearanceSmall" />

        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:weightSum="4">

            <View
                android:layout_width="85dp"
                android:layout_height="2dp"
                android:layout_gravity="center_vertical"
                android:layout_weight="1"
                android:background="@android:color/darker_gray" />

            <TextView
                android:id="@+id/textView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="10dp"
                android:layout_weight="2"
                android:gravity="center"
                android:text="@string/app_login_login_with_fb"
                android:textAppearance="?android:attr/textAppearanceSmall" />

            <View
                android:layout_width="85dp"
                android:layout_height="2dp"
                android:layout_gravity="center_vertical"
                android:layout_weight="1"
                android:background="@android:color/darker_gray" />

        </LinearLayout>

        <com.facebook.login.widget.LoginButton xmlns:fb="http://schemas.android.com/apk/res-auto"
            android:id="@+id/btnFbLogin"
            android:layout_width="300dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="30dp"
            android:paddingBottom="10dp"
            android:paddingLeft="20dp"
            android:paddingRight="20dp"
            android:paddingTop="10dp"
            fb:com_facebook_login_text="@string/app_login_btn_login_with_fb" />

    </LinearLayout>
</RelativeLayout>