text:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
		android:layout_width="fill_parent"
  		android:layout_height="fill_parent"
  		xmlns:android="http://schemas.android.com/apk/res/android">
	<ImageView
          android:id="@+id/mainMenuBackground"
          android:src="@drawable/title_background"
          android:adjustViewBounds="true"
          android:gravity="center_vertical"
          android:scaleType="fitXY"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"/>

	<ImageView
	      android:id="@+id/mainMenuTitle"
	      android:src="@drawable/title"
	      android:adjustViewBounds="true"
	      android:layout_width="336dp"
	      android:layout_height="153dp"
	      android:layout_gravity="center_horizontal"
	      android:layout_marginTop="20dp"/>

	   <LinearLayout
	     	android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			xmlns:android="http://schemas.android.com/apk/res/android"
	     	android:orientation="vertical"
	     	android:gravity="bottom"
	     	android:id="@+id/mainSectionMenu">

	    <ImageView
	        android:id="@+id/startButton"
	        android:src="@drawable/ui_button_start"
	        android:layout_width="wrap_content"
	        android:layout_height="wrap_content"
	        android:layout_gravity="center_horizontal"
	        android:clickable="true" />

	    <ImageView
	        android:id="@+id/extrasButton"
	        android:src="@drawable/ui_button_extras"
	        android:layout_width="wrap_content"
	        android:layout_height="wrap_content"
	        android:layout_gravity="center_horizontal"
	       	android:paddingTop="10dp"
			android:clickable="true" />

		<ImageView
		    android:id="@+id/optionButton"
		    android:src="@drawable/ui_button_options"
		    android:layout_width="wrap_content"
		    android:layout_height="wrap_content"
		    android:layout_gravity="center_horizontal"
		    android:paddingTop="10dp"
		    android:clickable="true" />

		<TextView
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:ellipsize="marquee"
			android:background="#99000000"
			android:textColor= "#FFFFFF"
			android:textColorHighlight="#FFFFFF"
			android:text="@string/whats_new_ticker"
			android:lines="1"
			android:marqueeRepeatLimit="marquee_forever"
			android:textSize="14sp"
			android:fadingEdge="horizontal"
			android:fadingEdgeLength="5dp"
			android:focusable="false"
			android:id="@+id/ticker"
			android:singleLine="true" android:layout_gravity="bottom|left"/>
	</LinearLayout>

	<ImageView
       	android:id="@+id/extrasNew"
       	android:src="@drawable/ui_new"
       	android:layout_height="wrap_content"
       	android:layout_width="wrap_content"
       	android:paddingLeft="280dp"
       	android:paddingTop="160dp"
       	android:visibility="invisible"/>

</FrameLayout>


text:
using System;
using System.Text;

namespace Zirpl.Mixpanel.Web.Mvc.JavaScript
{
    public class PeopleSetBuilder :CallBuilderBase
    {
        private String _callback;
        private readonly PeopleSetPropertiesBuilder _propertiesBuilder;

        public PeopleSetBuilder()
        {
            this._propertiesBuilder = new PeopleSetPropertiesBuilder(this);
        }

        public PeopleSetBuilder(String instanceName)
            :base(instanceName)
        {
            this._propertiesBuilder = new PeopleSetPropertiesBuilder(this);
        }

        public PeopleSetPropertiesBuilder Properties()
        {
            return this._propertiesBuilder;
        }

        public PeopleSetBuilder Callback(String value)
        {
            this._callback = value;
            return this;
        }

        public override string ToHtmlString()
        {
            var sb = new StringBuilder();
            var properties = this.Properties().ToPartialJavaScriptString();
            if (String.IsNullOrEmpty(properties))
            {
                throw new InvalidOperationException("Cannot call ToHtmlString without setting any properties");
            }
            sb.AppendFormat("{0}.people.set({1}", base.ToHtmlString(), properties);
            if (!String.IsNullOrEmpty(this._callback))
            {
                sb.AppendFormat(", {0}", this._callback);
            }
            sb.Append(");");
            return sb.ToString();
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
package com.spacechase0.minecraft.componentequipment.addon.thaumcraft.modifier;

import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;

import com.spacechase0.minecraft.componentequipment.ComponentEquipment;
import com.spacechase0.minecraft.componentequipment.item.EquipmentItem;
import com.spacechase0.minecraft.componentequipment.tool.Modifier;

public class RevealingGogglesModifier extends Modifier
{
	public RevealingGogglesModifier()
	{
		super( "seeAuraNodes" );
	}

	@Override
	public String getName( ItemStack stack )
	{
		EquipmentItem item = ( EquipmentItem ) stack.getItem();
		return StatCollector.translateToLocal( "componentequipment:modifier.seeAuraNodes.name" );
	}

	@Override
	public String getFormat( ItemStack stack )
	{
		return EnumChatFormatting.LIGHT_PURPLE.toString();
	}

	@Override
	public int getIconColor( int pass )
	{
		return ( pass == 0 ) ? 0x00F2AE00 : 0x003F1171;
	}

	@Override
	public boolean canApplyTo( EquipmentItem item )
	{
		return ( item == ComponentEquipment.items.helmet );
	}
}


text:
<!DOCTYPE html>

One Two Three
Four
Five Six Seven


text:
from django.db import migrations
import phonenumber_field.modelfields

class Migration(migrations.Migration):

    dependencies = [
        ('states', '0008_auto_20170824_1938'),
    ]

    operations = [
        migrations.AlterField(
            model_name='commissioner',
            name='fax_number',
            field=phonenumber_field.modelfields.PhoneNumberField(max_length=128, region=None, verbose_name='Fax number of personnel'),
        ),
        migrations.AlterField(
            model_name='commissioner',
            name='phone_number',
            field=phonenumber_field.modelfields.PhoneNumberField(max_length=128, region=None, verbose_name='Phone number of personnel'),
        ),
    ]


text:
(function ()
{
    window.AgidoMockups = window.AgidoMockups || {};
    AgidoMockups.icons = AgidoMockups.icons || {};

    var PIx2 = (Math.PI * 2) - 0.0001;
    AgidoMockups.icons.search = new Kinetic.Shape({
        name: "searchIcon",
        stroke: '#000',
        drawFunc: function (context)
        {
            context.beginPath();
            context.arc(0, 0, 5, 0, PIx2, false);
            context.closePath();
            context.moveTo(8, 8);
            context.lineTo(3, 3);
            context.fillStrokeShape(this);

        }
    });
})();


text:
#import "ASLayout.h"
#import "ASDimension.h"
#import "ASStackLayoutSpec.h"
#import "ASStackUnpositionedLayout.h"

/** Represents a set of laid out and positioned stack layout children. */
struct ASStackPositionedLayout {
  const std::vector<ASLayout *> sublayouts;
  const CGFloat crossSize;

  /** Given an unpositioned layout, computes the positions each child should be placed at. */
  static ASStackPositionedLayout compute(const ASStackUnpositionedLayout &unpositionedLayout,
                                         const ASStackLayoutSpecStyle &style,
                                         const ASSizeRange &constrainedSize);
};


text:
import unittest

class TestEventProducerLastUpdate(unittest.TestCase):
	pass


text:
game.hinting = true

-- fake gui
game.gui = {
	fading = 4;
	ways_delim = ' | ';
	inv_delim = ' | ';
	hinv_delim = ' | ';
	hideways = false;
	hideinv = false;
	hidetitle = false;
}

-- menu and stat
stat = function(v)
	v.status_type = true
	v.id = false
	return obj(v)
end

function isStatus(v)
	if stead.type(v) ~= 'table' then
		return false
	end
	if v.status_type then
		return true
	end
	return false
end

function isMenu(v)
	if stead.type(v) ~= 'table' then
		return false
	end
	if v.menu_type then
		return true
	end
	return false
end

stead.menu_save = function(self, name, h, need)
	local dsc;
	if need then
		print ("Warning: menu "..name.." can not be saved!");
		return
	end
	stead.savemembers(h, self, name, need);
end

function menu(v)
	v.menu_type = true
	if v.inv == nil then
		v.inv = function(s)
			local r,v
			r, v = stead.call(s, 'menu');
			if v == nil then v = true end
			if r == nil then
				stead.obj_tag(stead.me(), MENU_TAG_ID); -- retag menu field
			end
			return r, v
		end
	end
	if v.act == nil then
		v.act = function(s)
			local r,v
			r,v = stead.call(s, 'menu');
			if v == nil then v = true end
			if r == nil then
				stead.obj_tag(stead.me(), MENU_TAG_ID); -- retag menu field
			end
			return r, v
		end
	end
	if v.save == nil then
		v.save = stead.menu_save;
	end
	return obj(v);
end

-- Audio
stead.get_music = function()
	return game._music, game._music_loop;
end

stead.get_music_loop = function()
	return game._music_loop;
end

stead.save_music = function(s)
	if s == nil then
		s = self
	end
	s.__old_music__ = stead.get_music();
	s.__old_loop__ = stead.get_music_loop();
end

stead.restore_music = function(s)
	if s == nil then
		s = self
	end
	stead.set_music(s.__old_music__, s.__old_loop__);
end

stead.set_music = function(s, count)
	game._music = s;
	if not stead.tonum(count) then
		game._music_loop = 0;
	else
		game._music_loop = stead.tonum(count);
	end
end

stead.set_music_fading = function(o, i)
end

stead.get_music_fading = function()
end

stead.stop_music = function()
	stead.set_music(nil, -1);
end

stead.is_music = function()
	return game._music ~= nil and game._music_loop ~= -1
end

function instead_sound()
	return true
end

--пока нет звуков
stead.is_sound = function()
  return false
end

is_sound = function()
  return false
end

stead.get_sound = function()
	return game._sound, game._sound_channel, game._sound_loop;
end

stead.get_sound_chan = function()
	return game._sound_channel
end

stead.get_sound_loop = function()
	return game._sound_loop
end

stead.stop_sound = function(chan, fo)
	if not stead.tonum(chan) then
		if stead.tonum(fo) then
			stead.set_sound('@-1,'..stead.tostr(fo));
		else
			stead.set_sound('@-1');
		end
		return
	end
	if stead.tonum(fo) then
		stead.add_sound('@'..stead.tostr(chan)..','..stead.tostr(fo));
	else
		stead.add_sound('@'..stead.tostr(chan));
	end
end

stead.add_sound = function(s, chan, loop)
   if stead.type(s) ~= 'string' then
		return
	end
	if stead.type(game._sound) == 'string' then
		if stead.tonum(chan) then
			s = s..'@'..stead.tostr(chan);
		end
		if stead.tonum(loop) then
			s = s..','..stead.tostr(loop)
		end
		stead.set_sound(game._sound..';'..s, stead.get_sound_chan(), stead.get_sound_loop());
	else
		stead.set_sound(s, chan, loop);
	end
end

stead.set_sound = function(s, chan, loop)
  game._sound = s;
	if not stead.tonum(loop) then
		game._sound_loop = 1;
	else
		game._sound_loop = stead.tonum(loop);
	end

	if not stead.tonum(chan) then
		game._sound_channel = -1;
	else
		game._sound_channel = stead.tonum(chan);
	end
end

-- those are sill in global space
add_sound = stead.add_sound
set_sound = stead.set_sound
stop_sound = stead.stop_sound

get_sound = stead.get_sound
get_sound_loop = stead.get_sound_loop
get_sound_chan = stead.get_sound_chan

get_music = stead.get_music
get_music_fading = stead.get_music_fading
get_music_loop = stead.get_music_loop

set_music = stead.set_music
set_music_fading = stead.set_music_fading
stop_music = stead.stop_music

save_music = stead.save_music
restore_music = stead.restore_music

is_music = stead.is_music

--Для космический рейнджеров
unpack = stead.unpack;

stead.set_timer = function() end

stead.timer = function()
	return
end
instead_theme_name = function() return 'default' end

stead.module_init(function(s)
	timer = obj {
		nam = 'timer',
		get = function(s)
			return 0
		end,
		stop = function(s)
		end,
		del = function(s)
		end,
		set = function(s, v)
			return true
		end,
	};
end)

stead.objects.input =  function()
	return obj { -- input object
		system_type = true,
		nam = 'input',
	};
end;

--Место сохранений
function instead_savepath()
    return "../../" --Разрешаем сохранять на 2 уровня выше
end

stead.list_search = function(self, n, dis)
	local i
	if stead.tonum(n) then
		i = self:byid(stead.tonum(n), dis);
	end
	if not i then
		i = self:look(n)
		if not i then
			i = self:name(n, dis);
		end
		if not i then
			return nil
		end
	end
	if not dis and isDisabled(stead.ref(self[i])) then
		return nil
	end
	return self[i], i
end

local dict = {}

iface.xref = function(self, str, obj, ...)
	local cmd = ''
	local o = stead.ref(obj)

	if not isObject(o) or isStatus(o) or (not o.id and not isXaction(o)) then
		if isStatus(o) then
			str = string.gsub(str, "%^", " ")
			return ("[a]"..(str or '').."#0[/a]")
		end
		return str
	end

	if stead.cmd == 'way' then
		cmd = 'go'
	elseif stead.cmd == 'inv' then
		cmd = 'use'
	elseif isSceneUse(o) then
		cmd = 'use'
	elseif isXaction(o) and not o.id then
		cmd = 'act'
	elseif stead.ref(stead.here():srch(obj)) then
		cmd = 'act'
	end

	local a = ''
	local varg = {...}
	for i = 1, stead.table.maxn(varg) do
		a = a..','..varg[i]
	end

	local n = stead.deref(obj)
	local xref = string.format("%s%s", stead.tostr(o.id or n), a)
	if not dict[xref] then
		stead.table.insert(dict, { xref, cmd } )
		dict[xref] = #dict
	end
	xref = dict[xref]

	local n = xref
	if isMenu(o) then
		n = n + 1000 -- ???
	end
--	if isXaction(o) and not o.id then
--		return stead.cat('[a:'..stead.tostr(n)..']',str,'[/a]')
--	end
	return stead.cat('[a]', (str or ''), '#', stead.tostr(n), '[/a]');
end

local tag_all = stead.player_tagall -- save old

stead.player_tagall = function(self)
	dict = {}
	return tag_all(self)
end

local iface_cmd = iface.cmd -- save old

function iface:cmd(inp)
	local cmd, a = stead.getcmd(inp)
	if stead.tonum(cmd) then
		stead.table.insert(a, 1, cmd)
		cmd = 'act'
	end
	if cmd == 'act' or cmd == 'use' or cmd == 'go' then
		if a[1] == '' then -- fix use vs look
			return iface_cmd(self, "look")
		end
		if cmd == 'use' then
			local use = { }
			local c = false
			for i = 1, #a do
				local u = stead.tonum(a[i])
				u = u and dict[u]
				c = c or (u and u[2])
				stead.table.insert(use, u and u[1] or a[i])
			end
			if #a == 1 and c == 'act' then -- fix use 1,2 where 1,2 is object and look
				cmd = 'act'
			end
			inp = cmd .. ','..stead.table.concat(use, ',')
		elseif stead.tonum(a[1]) then
			local d = dict[stead.tonum(a[1])]
			a[1] = d and d[1] or a[1]
			inp = cmd .. ','..stead.table.concat(a, ',')
		end
	end
	return iface_cmd(self, inp)
end

--Форматирование текста
stead.fmt = function(...)
	local res
	local a = {...}

	for i = 1, stead.table.maxn(a) do
		if stead.type(a[i]) == 'string' then
			local s = stead.string.gsub(a[i],'\t', stead.space_delim):gsub('[\n]+', stead.space_delim);
			s = stead.string.gsub(s, '\\?[\\^]', { ['^'] = '\n', ['\\^'] = '^',
				['\\\\'] = '\\' });
			res = stead.par('', res, s);
			--Убирание информации из тегов
			res = stead.string.gsub(res,"(.-)","%1");
			res = stead.string.gsub(res,"(.-)","%1");
			res = stead.string.gsub(res,"<l.->(.-)</l>","%1");
			res = stead.string.gsub(res,"(.-)","%1");
			res = stead.string.gsub(res,"<w:(.-)>","%1");
			res = stead.string.gsub(res,"<c.->(.-)</c>","%1");
		end
	end
	return res
end

function iface:title(t)
	if type(t) ~= 'string' then return end
	return '['..t..']'
end

function iface:imgl()
	return ''
end

function iface:imgr()
	return ''
end

function iface:nb(t)
	return t == '' and ' ' or t
end

function iface:y()
	return ''
end

function iface:tab(str)
	return stead.tostr(str)..' '
end


text:
/**
 * @file    PerceptronTrainer.cc
 * @Author  Miikka Silfverberg
 * @brief   An instance of Trainer that performs averaged perceptron.
 */

///////////////////////////////////////////////////////////////////////////////
//                                                                           //
// (C) Copyright 2014, University of Helsinki                                //
// Licensed under the Apache License, Version 2.0 (the "License");           //
// you may not use this file except in compliance with the License.          //
// You may obtain a copy of the License at                                   //
// http://www.apache.org/licenses/LICENSE-2.0                                //
// Unless required by applicable law or agreed to in writing, software       //
// distributed under the License is distributed on an "AS IS" BASIS,         //
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  //
// See the License for the specific language governing permissions and       //
// limitations under the License.                                            //
//                                                                           //
///////////////////////////////////////////////////////////////////////////////

#include "PerceptronTrainer.hh"

#ifndef TEST_PerceptronTrainer_cc

#include <cassert>

#include "Trellis.hh"

#define STRUCT_SL 1
#define USTRUCT_SL 1

PerceptronTrainer::PerceptronTrainer(unsigned int max_passes,
				     unsigned int max_useless_passes,
				     ParamTable &pt,
				     const LabelExtractor &label_extractor,
				     const LemmaExtractor &lemma_extractor,
				     std::ostream &msg_out,
				     const TaggerOptions &options):
  Trainer(max_passes, max_useless_passes, pt, label_extractor, lemma_extractor, msg_out, options),
  iter(0),
  //use_unstruct_sub_labels(options.use_unstructured_sublabels),
  //use_struct_sub_labels(options.use_structured_sublabels)
  sublabel_order(options.sublabel_order),
  model_order(options.model_order),
  options(options)
{
  pt.set_param_filter(options);
  pos_params = pt;
  neg_params = pt;

  pos_params.set_label_extractor(label_extractor);
  neg_params.set_label_extractor(label_extractor);
}

void PerceptronTrainer::train(const Data &train_data,
			      const Data &dev_data,
			      unsigned int beam,
			      float beam_mass)
{
  Data train_data_copy(train_data);

  Data dev_data_copy(dev_data);
  dev_data_copy.unset_label();

  TrellisVector train_trellises;
  std::cerr << "SL: " << sublabel_order << std::endl;
  for (unsigned int i = 0; i < train_data.size(); ++i)
    {
      train_trellises.push_back(new Trellis(train_data_copy.at(i), boundary_label,
					    sublabel_order, model_order, beam));

      if (beam != static_cast<unsigned int>(-1))
	{ train_trellises.back()->set_beam(beam); }
      if (beam_mass != -1)
	{ train_trellises.back()->set_beam_mass(beam_mass); }
    }

  TrellisVector dev_trellises;

  for (unsigned int i = 0; i < dev_data.size(); ++i)
    {
      dev_trellises.push_back(new Trellis(dev_data_copy.at(i), boundary_label, sublabel_order, model_order, beam));

      if (beam != static_cast<float>(-1))
	{ dev_trellises.back()->set_beam(beam); }
      if (beam_mass != -1)
	{ dev_trellises.back()->set_beam_mass(beam_mass); }
    }

  float best_dev_acc = -1;
  ParamTable best_params;
  best_params.set_param_filter(options);
  best_params.set_label_extractor(label_extractor);

  unsigned int useless_passes = 0;

  for (unsigned int i = 0; i < max_passes; ++i)
    {
      if (useless_passes >= max_useless_passes)
	{ break; }

      msg_out << "  Train pass " << i + 1 << std::endl;

      // Train pass.
      for (unsigned int j = 0; j < train_trellises.size(); ++j)
	{
	  train_trellises[j]->set_maximum_a_posteriori_assignment
	    (pos_params);

	  update(train_data.at(j), train_data_copy.at(j));

	  std::cerr << j << " of " << train_trellises.size() - 1 << "\r";
	}

      std::cerr << std::endl;

      // Average.
      set_avg_params();

      // Tag dev data.
      for (unsigned int j = 0; j < dev_trellises.size(); ++j)
	{
	  dev_trellises[j]->set_maximum_a_posteriori_assignment(pt);
	}

      float acc = dev_data.get_acc(dev_data_copy, lemma_extractor).label_acc;

      msg_out << "    Dev acc: " << acc * 100.00 << "%" << std::endl;

      if (acc > best_dev_acc)
	{
	  useless_passes = 0;
	  best_dev_acc = acc;
	  best_params = pt;
	}
      else
	{
	  ++useless_passes;
	}
    }

  msg_out << "  Final dev acc: " << best_dev_acc * 100.00 << "%" << std::endl;

  pt = best_params;
  pt.set_label_extractor(label_extractor);
  pt.set_trained();
  pt.set_train_iters(iter);

  for (TrellisVector::const_iterator it = train_trellises.begin();
       it != train_trellises.end();
       ++it)
    { delete *it; }

  for (TrellisVector::const_iterator it = dev_trellises.begin();
       it != dev_trellises.end();
       ++it)
    { delete *it; }
}

void PerceptronTrainer::train_lemmatizer(const Data &train_data,
					 const Data &dev_data,
					 LemmaExtractor &lemma_e,
					 const LabelExtractor &label_e)
{
  std::vector<Word> train_words;
  std::vector<Word> dev_words;

  std::unordered_map<unsigned int , unsigned int> class_counts;

  for (unsigned int i = 0; i < train_data.size(); ++i)
    {
      for (unsigned int j = 0; j < train_data.at(i).size(); ++j)
	{
	  Word w = train_data.at(i).at(j);

	  Word * ww = lemma_e.extract_feats(w.get_word_form(),
					    label_e.get_label_string(w.get_label()));

	  unsigned int klass = lemma_e.get_class_number(w.get_word_form(),
							w.get_lemma());

	  ww->set_label(klass);

	  class_counts[klass] += 1;

	  train_words.push_back(*ww);

	  delete ww;

	  for (size_t i = 0; i < w.analyzer_lemmas.size(); ++i)
	    {
	      if (w.analyzer_lemmas[i].first == w.get_label() and
		  w.analyzer_lemmas[i].second == w.get_lemma())
		{ continue; }

	      ww = lemma_e.extract_feats
		(w.get_word_form(),
		 label_e.get_label_string(w.analyzer_lemmas[i].first));

	      ww->set_label(lemma_e.get_class_number(w.get_word_form(),
						     w.analyzer_lemmas[i].second));

	      train_words.push_back(*ww);

	      delete ww;
	      }
	}
    }

  std::vector<Word> train_words_copy;

  for (unsigned int i = 0; i < train_words.size(); ++i)
    {
      if (class_counts[train_words[i].get_label()] > 0)
      	{ train_words_copy.push_back(train_words[i]); }
    }

  train_words = train_words_copy;

  std::srand(0);
  std::random_shuffle(train_words.begin(), train_words.end());

  for (unsigned int i = 0; i < dev_data.size(); ++i)
    {
      for (unsigned int j = 0; j < dev_data.at(i).size(); ++j)
	{
	  const Word &w = dev_data.at(i).at(j);

	  Word * ww = lemma_e.extract_feats(w.get_word_form(),
					    label_e.get_label_string(w.get_label()));

	  ww->set_label(lemma_e.get_class_number(w.get_word_form(),
						 w.get_lemma()));

	  dev_words.push_back(*ww);
	  delete ww;
	}
    }

  float best_dev_acc = -1;
  ParamTable best_params;
  unsigned int useless_passes = 0;

  for (unsigned int i = 0; i < max_passes; ++i)
    {
      if (useless_passes >= max_useless_passes)
	{ break; }

      msg_out << "  Train pass " << i + 1 << ":" << std::endl;

      // Train pass.
      for (unsigned int j = 0; j < train_words.size(); ++j)
	{
	  Word &w = train_words.at(j);

	  unsigned int gold_class = w.get_label();

	  unsigned int sys_class =
	    lemma_e.get_lemma_candidate_class(w, &pos_params);

	  lemmatizer_update(w, sys_class, gold_class, lemma_e, label_e);
	}

      // Average.
      set_avg_params();

      // Tag dev data.
      float correct = 0;
      float total = 0;

      for (unsigned int j = 0; j < dev_words.size(); ++j)
	{
	  Word &w = dev_words.at(j);

	  unsigned int gold_class = w.get_label();

	  unsigned int sys_class =
	    lemma_e.get_lemma_candidate_class(w);

	  correct += (sys_class == gold_class) ? 1 : 0;
	  ++total;
	}

      float acc = (total == 0 ? 0 : correct / total);

      msg_out << "    Dev acc: " << acc * 100.00 << "%" << std::endl;

      if (acc > best_dev_acc)
	{
	  useless_passes = 0;
	  best_dev_acc = acc;
	  best_params = pt;
	}
      else
	{
	  ++useless_passes;
	}
    }

  msg_out << "  Final dev acc: " << best_dev_acc * 100.0 << "%" << std::endl;

  pt = best_params;
  pt.set_trained();
}

void PerceptronTrainer::update(const Sentence &gold_s,
			       const Sentence &sys_s)
{
  ++iter;

  for (unsigned int i = 0; i /*<= max_violation_id*/ < sys_s.size() ; ++i)
    {
      unsigned int gold_label = gold_s.at(i).get_label();
      unsigned int sys_label = sys_s.at(i).get_label();

      unsigned int pgold_label = (i < 1 ? boundary_label : gold_s.at(i - 1).get_label());
      unsigned int psys_label = (i < 1 ? boundary_label : sys_s.at(i - 1).get_label());

      unsigned int ppgold_label = (i < 2 ? boundary_label : gold_s.at(i - 2).get_label());
      unsigned int ppsys_label = (i < 2 ? boundary_label : sys_s.at(i - 2).get_label());

      // Unstruct params.
      //pos_params.update_all_unstruct(gold_s.at(i), gold_label, 1, use_unstruct_sub_labels);
      //neg_params.update_all_unstruct(gold_s.at(i), gold_label, -iter, use_unstruct_sub_labels);
      pos_params.update_all_unstruct(gold_s.at(i), gold_label, 1, sublabel_order);
      neg_params.update_all_unstruct(gold_s.at(i), gold_label, -iter, sublabel_order);

      //pos_params.update_all_unstruct(sys_s.at(i), sys_label, -1, use_unstruct_sub_labels);
      //neg_params.update_all_unstruct(sys_s.at(i), sys_label, iter, use_unstruct_sub_labels);
      pos_params.update_all_unstruct(sys_s.at(i), sys_label, -1, sublabel_order);
      neg_params.update_all_unstruct(sys_s.at(i), sys_label, iter, sublabel_order);

      // Struct params.
      //pos_params.update_all_struct_fw(ppgold_label, pgold_label, gold_label, 1, use_struct_sub_labels);
      //neg_params.update_all_struct_fw(ppgold_label, pgold_label, gold_label, -iter, use_struct_sub_labels);
      pos_params.update_all_struct_fw(ppgold_label, pgold_label, gold_label, 1, sublabel_order, model_order);
      neg_params.update_all_struct_fw(ppgold_label, pgold_label, gold_label, -iter, sublabel_order, model_order);

      //pos_params.update_all_struct_fw(ppsys_label, psys_label, sys_label, -1, use_struct_sub_labels);
      //neg_params.update_all_struct_fw(ppsys_label, psys_label, sys_label, iter, use_struct_sub_labels);
      pos_params.update_all_struct_fw(ppsys_label, psys_label, sys_label, -1, sublabel_order, model_order);
      neg_params.update_all_struct_fw(ppsys_label, psys_label, sys_label, iter, sublabel_order, model_order);
    }
}

void PerceptronTrainer::lemmatizer_update(const Word &w,
					  unsigned int sys_class,
					  unsigned int gold_class,
					  LemmaExtractor &lemma_e,
					  const LabelExtractor &label_e)
{
  ++iter;

  static_cast<void>(lemma_e);
  static_cast<void>(label_e);

  pos_params.update_all_unstruct(w, gold_class, 1, NODEG);
  neg_params.update_all_unstruct(w, gold_class, -iter, NODEG);

  pos_params.update_all_unstruct(w, sys_class, -1, NODEG);
  neg_params.update_all_unstruct(w, sys_class, iter, NODEG);

  //delete lemma_feature_word;
}

void PerceptronTrainer::set_avg_params(void)
{
  pt = pos_params;

  ParamMap::iterator pt_it = pt.get_unstruct_begin();
  ParamMap::iterator pos_it = pos_params.get_unstruct_begin();
  ParamMap::iterator neg_it = neg_params.get_unstruct_begin();

  ParamMap::iterator pt_end = pt.get_unstruct_end();
  ParamMap::iterator pos_end = pos_params.get_unstruct_end();
  ParamMap::iterator neg_end = neg_params.get_unstruct_end();

  while (pt_it != pt_end)
    {
      assert(pos_it != pos_end);
      assert(neg_it != neg_end);
      pt_it->second = (iter + 1) * pos_it->second + neg_it->second;
      ++pt_it;
      ++pos_it;
      ++neg_it;
    }

  pt_it = pt.get_struct_begin();
  pos_it = pos_params.get_struct_begin();
  neg_it = neg_params.get_struct_begin();

  pt_end = pt.get_struct_end();
  pos_end = pos_params.get_struct_end();
  neg_end = neg_params.get_struct_end();

  while (pt_it != pt_end)
    {
      pt_it->second = (iter + 1) * pos_it->second + neg_it->second;
      ++pt_it;
      ++pos_it;
      ++neg_it;
    }

  pt.set_label_extractor(label_extractor);

  if (options.filter_type == UPDATE_COUNT)
    { pt.set_update_counts(pos_params); }
}

#else // TEST_PerceptronTrainer_cc

#include "Data.hh"

class SillyLabelExtractor : public LabelExtractor
{
public:
  SillyLabelExtractor(void):
    LabelExtractor(1)
  {}

  void set_label_candidates(const std::string &word_form,
			    bool use_label_dict,
			    float mass,
			    LabelVector &target,
			    int candidate_count) const
  {
    static_cast<void>(use_label_dict);
    static_cast<void>(mass);

    if (word_form == BOUNDARY_WF)
      {
	target.push_back(get_boundary_label());
      }
    else
      {
	target.clear();

	for (unsigned int i = 0; i < static_cast<unsigned int>(candidate_count); ++i)
	  {
	    target.push_back(i);
	  }
      }
  }
};

class SillyLemmaExtractor : public LemmaExtractor
{
public:
  std::string get_lemma_candidate(const std::string &word_form,
				  const std::string &label)
  {
    static_cast<void>(word_form);
    static_cast<void>(label);

    return "FOO";
  }

  bool is_known_wf(const std::string &word_form) const
  {
    static_cast<void>(word_form);

    return 1;
  }
};

#include <sstream>
#include <cassert>

#include "Trellis.hh"

int main(void)
{
  TaggerOptions options;

  std::string contents("\n"
		       "The\tWORD=The\tthe\tDT\t_\n"
		       "dog\tWORD=dog\tdog\tNN\t_\n"
		       ".\tWORD=.\t.\t.\t_\n"
		       "\n"
		       "\n"
		       "The\tWORD=The\tthe\tDT\t_\n"
		       "dog\tWORD=dog\tdog\tNN\t_\n"
		       ".\tWORD=.\t.\t.\t_\n");

  std::istringstream in(contents);

  SillyLabelExtractor label_extractor;

  ParamTable pt;

  Data train_data(in, 1, label_extractor, pt, 2);
  train_data.set_label_guesses(label_extractor,
			       0,
			       0,
			       label_extractor.label_count());

  Data dev_data(train_data);
  Data dev_data_copy(dev_data);

  dev_data.set_label_guesses(label_extractor,
			     0,
			     0,
			     label_extractor.label_count());

  dev_data_copy.unset_label();

  dev_data_copy.set_label_guesses(label_extractor,
				  0,
				  0,
				  label_extractor.label_count());

  std::ostringstream null_out;
  PerceptronTrainer trainer(5,3,pt, label_extractor, SillyLemmaExtractor(), null_out, options);
  trainer.train(train_data, dev_data);

  for (unsigned int i = 0; i < dev_data_copy.size(); ++i)
    {
      Trellis trellis(dev_data_copy.at(i), label_extractor.get_boundary_label(), NODEG, SECOND);
      trellis.set_maximum_a_posteriori_assignment(pt);
    }

  assert(dev_data.get_acc(dev_data_copy, SillyLemmaExtractor()).label_acc == 1);
}

#endif // TEST_PerceptronTrainer_cc


text:
package intuitio.kickstart.jersey.config;

import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;

@Order(Ordered.HIGHEST_PRECEDENCE)
public class SpringContextInitializer implements WebApplicationInitializer {

    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        servletContext.setInitParameter("contextConfigLocation", "intuitio.kickstart.jersey.config");
        servletContext.setInitParameter("welcomeFileList", "index.html");
        WebApplicationContext rootAppContext = new AnnotationConfigWebApplicationContext();
        servletContext.addListener(new ContextLoaderListener(rootAppContext));
    }
}


text:
/* Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package flowable;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 *
 */
@SpringBootApplication
public class AppSampleApplication {

   public static void main(String args[]) {
        SpringApplication.run(AppSampleApplication.class, args);
    }

}


text:
"""Provides a factory class for generating dynamic messages.

The easiest way to use this class is if you have access to the FileDescriptor
protos containing the messages you want to create you can just do the following:

message_classes = message_factory.GetMessages(iterable_of_file_descriptors)
my_proto_instance = message_classes['some.proto.package.MessageName']()
"""

from google.net.proto2.python.public import descriptor_pool
from google.net.proto2.python.public import message
from google.net.proto2.python.public import reflection

class MessageFactory(object):
  """Factory for creating Proto2 messages from descriptors in a pool."""

  def __init__(self, pool=None):
    """Initializes a new factory."""
    self.pool = pool or descriptor_pool.DescriptorPool()

    self._classes = {}

  def GetPrototype(self, descriptor):
    """Builds a proto2 message class based on the passed in descriptor.

    Passing a descriptor with a fully qualified name matching a previous
    invocation will cause the same class to be returned.

    Args:
      descriptor: The descriptor to build from.

    Returns:
      A class describing the passed in descriptor.
    """
    if descriptor.full_name not in self._classes:
      descriptor_name = descriptor.name
      if str is bytes:
        descriptor_name = descriptor.name.encode('ascii', 'ignore')
      result_class = reflection.GeneratedProtocolMessageType(
          descriptor_name,
          (message.Message,),
          {'DESCRIPTOR': descriptor, '__module__': None})

      self._classes[descriptor.full_name] = result_class
      for field in descriptor.fields:
        if field.message_type:
          self.GetPrototype(field.message_type)
      for extension in result_class.DESCRIPTOR.extensions:
        if extension.containing_type.full_name not in self._classes:
          self.GetPrototype(extension.containing_type)
        extended_class = self._classes[extension.containing_type.full_name]
        extended_class.RegisterExtension(extension)
    return self._classes[descriptor.full_name]

  def GetMessages(self, files):
    """Gets all the messages from a specified file.

    This will find and resolve dependencies, failing if the descriptor
    pool cannot satisfy them.

    Args:
      files: The file names to extract messages from.

    Returns:
      A dictionary mapping proto names to the message classes. This will include
      any dependent messages as well as any messages defined in the same file as
      a specified message.
    """
    result = {}
    for file_name in files:
      file_desc = self.pool.FindFileByName(file_name)
      for desc in file_desc.message_types_by_name.values():
        result[desc.full_name] = self.GetPrototype(desc)

      for extension in file_desc.extensions_by_name.values():
        if extension.containing_type.full_name not in self._classes:
          self.GetPrototype(extension.containing_type)
        extended_class = self._classes[extension.containing_type.full_name]
        extended_class.RegisterExtension(extension)
    return result

_FACTORY = MessageFactory()

def GetMessages(file_protos):
  """Builds a dictionary of all the messages available in a set of files.

  Args:
    file_protos: A sequence of file protos to build messages out of.

  Returns:
    A dictionary mapping proto names to the message classes. This will include
    any dependent messages as well as any messages defined in the same file as
    a specified message.
  """
  for file_proto in file_protos:
    _FACTORY.pool.Add(file_proto)
  return _FACTORY.GetMessages([file_proto.name for file_proto in file_protos])


text:
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;
using System.Management.Automation.Language;
using System.Management.Automation.Runspaces;
using System.Xml;
using System.Text;
using System.Text.RegularExpressions;
using System.Management.Automation.Help;
using System.Reflection;

namespace System.Management.Automation
{
    /// <summary>
    /// Parses help comments and turns them into HelpInfo objects
    /// </summary>
    internal class HelpCommentsParser
    {
        private HelpCommentsParser()
        {
        }

        private HelpCommentsParser(List<string> parameterDescriptions)
        {
            _parameterDescriptions = parameterDescriptions;
        }

        private HelpCommentsParser(CommandInfo commandInfo, List<string> parameterDescriptions)
        {
            FunctionInfo fi = commandInfo as FunctionInfo;
            if (fi != null)
            {
                _scriptBlock = fi.ScriptBlock;
                _commandName = fi.Name;
            }
            else
            {
                ExternalScriptInfo si = commandInfo as ExternalScriptInfo;
                if (si != null)
                {
                    _scriptBlock = si.ScriptBlock;
                    _commandName = si.Path;
                }
            }
            _commandMetadata = commandInfo.CommandMetadata;
            _parameterDescriptions = parameterDescriptions;
        }

        private readonly Language.CommentHelpInfo _sections = new Language.CommentHelpInfo();
        private readonly Dictionary<string, string> _parameters = new Dictionary<string, string>();
        private readonly List<string> _examples = new List<string>();
        private readonly List<string> _inputs = new List<string>();
        private readonly List<string> _outputs = new List<string>();
        private readonly List<string> _links = new List<string>();
        internal bool isExternalHelpSet = false;

        private ScriptBlock _scriptBlock;
        private CommandMetadata _commandMetadata;
        private string _commandName;
        private List<string> _parameterDescriptions;
        private XmlDocument _doc;
        internal static readonly string mshURI = "http://msh";
        internal static readonly string mamlURI = "http://schemas.microsoft.com/maml/2004/10";
        internal static readonly string commandURI = "http://schemas.microsoft.com/maml/dev/command/2004/10";
        internal static readonly string devURI = "http://schemas.microsoft.com/maml/dev/2004/10";
        private const string directive = @"^\s*\.(\w+)(\s+(\S.*))?\s*$";
        private const string blankline = @"^\s*$";
        // Although "http://msh" is the default namespace, it still must be explicitly qualified with non-empty prefix,
        // because XPath 1.0 will associate empty prefix with "null" namespace (not with "default") and query will fail.
        // See: http://www.w3.org/TR/1999/REC-xpath-19991116/#node-tests
        internal static readonly string ProviderHelpCommandXPath =
            "/msh:helpItems/msh:providerHelp/msh:CmdletHelpPaths/msh:CmdletHelpPath{0}/command:command[command:details/command:verb='{1}' and command:details/command:noun='{2}']";

        private void DetermineParameterDescriptions()
        {
            int i = 0;
            foreach (string parameterName in _commandMetadata.StaticCommandParameterMetadata.BindableParameters.Keys)
            {
                string description;
                if (!_parameters.TryGetValue(parameterName.ToUpperInvariant(), out description))
                {
                    if (i < _parameterDescriptions.Count)
                    {
                        _parameters.Add(parameterName.ToUpperInvariant(), _parameterDescriptions[i]);
                    }
                }
                ++i;
            }
        }

        private string GetParameterDescription(string parameterName)
        {
            Diagnostics.Assert(!string.IsNullOrEmpty(parameterName), "Parameter name must not be empty");

            string description;
            _parameters.TryGetValue(parameterName.ToUpperInvariant(), out description);
            return description;
        }

        private XmlElement BuildXmlForParameter(
            string parameterName,
            bool isMandatory,
            bool valueFromPipeline,
            bool valueFromPipelineByPropertyName,
            string position,
            Type type,
            string description,
            bool supportsWildcards,
            string defaultValue,
            bool forSyntax)
        {
            XmlElement command_parameter = _doc.CreateElement("command:parameter", commandURI);
            command_parameter.SetAttribute("required", isMandatory ? "true" : "false");
            //command_parameter.SetAttribute("variableLength", "unknown");
            command_parameter.SetAttribute("globbing", supportsWildcards ? "true" : "false");
            string fromPipeline;
            if (valueFromPipeline && valueFromPipelineByPropertyName)
            {
                fromPipeline = "true (ByValue, ByPropertyName)";
            }
            else if (valueFromPipeline)
            {
                fromPipeline = "true (ByValue)";
            }
            else if (valueFromPipelineByPropertyName)
            {
                fromPipeline = "true (ByPropertyName)";
            }
            else
            {
                fromPipeline = "false";
            }
            command_parameter.SetAttribute("pipelineInput", fromPipeline);
            command_parameter.SetAttribute("position", position);

            XmlElement name = _doc.CreateElement("maml:name", mamlURI);
            XmlText name_text = _doc.CreateTextNode(parameterName);
            command_parameter.AppendChild(name).AppendChild(name_text);
            if (!string.IsNullOrEmpty(description))
            {
                XmlElement maml_description = _doc.CreateElement("maml:description", mamlURI);
                XmlElement maml_para = _doc.CreateElement("maml:para", mamlURI);
                XmlText maml_para_text = _doc.CreateTextNode(description);
                command_parameter.AppendChild(maml_description).AppendChild(maml_para).AppendChild(maml_para_text);
            }

            if (type == null)
                type = typeof(object);

            var typeInfo = type.GetTypeInfo();
            var elementType = typeInfo.IsArray ? typeInfo.GetElementType() : type;

            if (elementType.GetTypeInfo().IsEnum)
            {
                XmlElement parameterValueGroup = _doc.CreateElement("command:parameterValueGroup", commandURI);
                foreach (string valueName in Enum.GetNames(elementType))
                {
                    XmlElement parameterValue = _doc.CreateElement("command:parameterValue", commandURI);
                    parameterValue.SetAttribute("required", "false");
                    XmlText parameterValue_text = _doc.CreateTextNode(valueName);
                    parameterValueGroup.AppendChild(parameterValue).AppendChild(parameterValue_text);
                }
                command_parameter.AppendChild(parameterValueGroup);
            }
            else
            {
                bool isSwitchParameter = elementType == typeof(SwitchParameter);
                if (!forSyntax || !isSwitchParameter)
                {
                    XmlElement parameterValue = _doc.CreateElement("command:parameterValue", commandURI);
                    parameterValue.SetAttribute("required", isSwitchParameter ? "false" : "true");
                    //parameterValue.SetAttribute("variableLength", "unknown");
                    XmlText parameterValue_text = _doc.CreateTextNode(type.Name);
                    command_parameter.AppendChild(parameterValue).AppendChild(parameterValue_text);
                }
            }

            if (!forSyntax)
            {
                XmlElement devType = _doc.CreateElement("dev:type", devURI);
                XmlElement typeName = _doc.CreateElement("maml:name", mamlURI);
                XmlText typeName_text = _doc.CreateTextNode(type.Name);
                command_parameter.AppendChild(devType).AppendChild(typeName).AppendChild(typeName_text);

                XmlElement defaultValueElement = _doc.CreateElement("dev:defaultValue", devURI);
                XmlText defaultValue_text = _doc.CreateTextNode(defaultValue);
                command_parameter.AppendChild(defaultValueElement).AppendChild(defaultValue_text);
            }

            return command_parameter;
        }

        /// <summary>
        /// Create the maml xml after a successful analysis of the comments.
        /// </summary>
        /// <returns>The xml node for the command constructed</returns>
        internal XmlDocument BuildXmlFromComments()
        {
            Diagnostics.Assert(!string.IsNullOrEmpty(_commandName), "Name can never be null");

            _doc = new XmlDocument();
            XmlElement command = _doc.CreateElement("command:command", commandURI);
            command.SetAttribute("xmlns:maml", mamlURI);
            command.SetAttribute("xmlns:command", commandURI);
            command.SetAttribute("xmlns:dev", devURI);
            _doc.AppendChild(command);

            XmlElement details = _doc.CreateElement("command:details", commandURI);
            command.AppendChild(details);

            XmlElement name = _doc.CreateElement("command:name", commandURI);
            XmlText name_text = _doc.CreateTextNode(_commandName);
            details.AppendChild(name).AppendChild(name_text);

            if (!string.IsNullOrEmpty(_sections.Synopsis))
            {
                XmlElement synopsis = _doc.CreateElement("maml:description", mamlURI);
                XmlElement synopsis_para = _doc.CreateElement("maml:para", mamlURI);
                XmlText synopsis_text = _doc.CreateTextNode(_sections.Synopsis);
                details.AppendChild(synopsis).AppendChild(synopsis_para).AppendChild(synopsis_text);
            }

            #region Syntax

            // The syntax is automatically generated from parameter metadata
            DetermineParameterDescriptions();

            XmlElement syntax = _doc.CreateElement("command:syntax", commandURI);
            MergedCommandParameterMetadata parameterMetadata = _commandMetadata.StaticCommandParameterMetadata;
            if (parameterMetadata.ParameterSetCount > 0)
            {
                for (int i = 0; i < parameterMetadata.ParameterSetCount; ++i)
                {
                    BuildSyntaxForParameterSet(command, syntax, parameterMetadata, i);
                }
            }
            else
            {
                BuildSyntaxForParameterSet(command, syntax, parameterMetadata, int.MaxValue);
            }

            #endregion Syntax

            #region Parameters

            XmlElement commandParameters = _doc.CreateElement("command:parameters", commandURI);
            foreach (KeyValuePair<string, MergedCompiledCommandParameter> pair in parameterMetadata.BindableParameters)
            {
                MergedCompiledCommandParameter mergedParameter = pair.Value;
                if (mergedParameter.BinderAssociation == ParameterBinderAssociation.CommonParameters)
                {
                    continue;
                }
                string parameterName = pair.Key;
                string description = GetParameterDescription(parameterName);

                ParameterSetSpecificMetadata parameterSetData;
                bool isMandatory = false;
                bool valueFromPipeline = false;
                bool valueFromPipelineByPropertyName = false;
                string position = "named";
                int i = 0;

                CompiledCommandParameter parameter = mergedParameter.Parameter;
                parameter.ParameterSetData.TryGetValue(ParameterAttribute.AllParameterSets, out parameterSetData);
                while (parameterSetData == null && i < 32)
                {
                    parameterSetData = parameter.GetParameterSetData(1u << i++);
                }
                if (parameterSetData != null)
                {
                    isMandatory = parameterSetData.IsMandatory;
                    valueFromPipeline = parameterSetData.ValueFromPipeline;
                    valueFromPipelineByPropertyName = parameterSetData.ValueFromPipelineByPropertyName;
                    position = parameterSetData.IsPositional ? (1 + parameterSetData.Position).ToString(CultureInfo.InvariantCulture) : "named";
                }

                var compiledAttributes = parameter.CompiledAttributes;
                bool supportsWildcards = compiledAttributes.OfType<SupportsWildcardsAttribute>().Any();

                string defaultValueStr = "";
                object defaultValue = null;
                var defaultValueAttribute = compiledAttributes.OfType<PSDefaultValueAttribute>().FirstOrDefault();
                if (defaultValueAttribute != null)
                {
                    defaultValueStr = defaultValueAttribute.Help;
                    if (string.IsNullOrEmpty(defaultValueStr))
                    {
                        defaultValue = defaultValueAttribute.Value;
                    }
                }

                if (string.IsNullOrEmpty(defaultValueStr))
                {
                    if (defaultValue == null)
                    {
                        RuntimeDefinedParameter rdp;
                        if (_scriptBlock.RuntimeDefinedParameters.TryGetValue(parameterName, out rdp))
                        {
                            defaultValue = rdp.Value;
                        }
                    }

                    var wrapper = defaultValue as Compiler.DefaultValueExpressionWrapper;
                    if (wrapper != null)
                    {
                        defaultValueStr = wrapper.Expression.Extent.Text;
                    }
                    else if (defaultValue != null)
                    {
                        defaultValueStr = PSObject.ToStringParser(null, defaultValue);
                    }
                }

                XmlElement parameterElement = BuildXmlForParameter(parameterName, isMandatory,
                    valueFromPipeline, valueFromPipelineByPropertyName, position,
                    parameter.Type, description, supportsWildcards, defaultValueStr, forSyntax: false);
                commandParameters.AppendChild(parameterElement);
            }
            command.AppendChild(commandParameters);

            #endregion Parameters

            if (!string.IsNullOrEmpty(_sections.Description))
            {
                XmlElement description = _doc.CreateElement("maml:description", mamlURI);
                XmlElement description_para = _doc.CreateElement("maml:para", mamlURI);
                XmlText description_text = _doc.CreateTextNode(_sections.Description);
                command.AppendChild(description).AppendChild(description_para).AppendChild(description_text);
            }
            if (!string.IsNullOrEmpty(_sections.Notes))
            {
                XmlElement alertSet = _doc.CreateElement("maml:alertSet", mamlURI);
                XmlElement alert = _doc.CreateElement("maml:alert", mamlURI);
                XmlElement alert_para = _doc.CreateElement("maml:para", mamlURI);
                XmlText alert_para_text = _doc.CreateTextNode(_sections.Notes);
                command.AppendChild(alertSet).AppendChild(alert).AppendChild(alert_para).AppendChild(alert_para_text);
            }
            if (_examples.Count > 0)
            {
                XmlElement examples = _doc.CreateElement("command:examples", commandURI);
                int count = 1;
                foreach (string example in _examples)
                {
                    XmlElement example_node = _doc.CreateElement("command:example", commandURI);

                    // The title is automatically generated
                    XmlElement title = _doc.CreateElement("maml:title", mamlURI);
                    string titleStr = string.Format(CultureInfo.InvariantCulture,
                        "				-------------------------- {0} {1} --------------------------",
                        HelpDisplayStrings.ExampleUpperCase, count++);
                    XmlText title_text = _doc.CreateTextNode(titleStr);
                    example_node.AppendChild(title).AppendChild(title_text);

                    string prompt_str;
                    string code_str;
                    string remarks_str;
                    GetExampleSections(example, out prompt_str, out code_str, out remarks_str);

                    // Introduction (usually the prompt)
                    XmlElement introduction = _doc.CreateElement("maml:introduction", mamlURI);
                    XmlElement introduction_para = _doc.CreateElement("maml:para", mamlURI);
                    XmlText introduction_para_text = _doc.CreateTextNode(prompt_str);
                    example_node.AppendChild(introduction).AppendChild(introduction_para).AppendChild(introduction_para_text);

                    // Example code
                    XmlElement code = _doc.CreateElement("dev:code", devURI);
                    XmlText code_text = _doc.CreateTextNode(code_str);
                    example_node.AppendChild(code).AppendChild(code_text);

                    // Remarks are comments on the example
                    XmlElement remarks = _doc.CreateElement("dev:remarks", devURI);
                    XmlElement remarks_para = _doc.CreateElement("maml:para", mamlURI);
                    XmlText remarks_para_text = _doc.CreateTextNode(remarks_str);
                    example_node.AppendChild(remarks).AppendChild(remarks_para).AppendChild(remarks_para_text);
                    // The convention is to have 4 blank paras after the example for spacing
                    for (int i = 0; i < 4; i++)
                    {
                        remarks.AppendChild(_doc.CreateElement("maml:para", mamlURI));
                    }
                    examples.AppendChild(example_node);
                }
                command.AppendChild(examples);
            }
            if (_inputs.Count > 0)
            {
                XmlElement inputTypes = _doc.CreateElement("command:inputTypes", commandURI);
                foreach (string inputStr in _inputs)
                {
                    XmlElement inputType = _doc.CreateElement("command:inputType", commandURI);
                    XmlElement type = _doc.CreateElement("dev:type", devURI);
                    XmlElement maml_name = _doc.CreateElement("maml:name", mamlURI);
                    XmlText maml_name_text = _doc.CreateTextNode(inputStr);
                    inputTypes.AppendChild(inputType).AppendChild(type).AppendChild(maml_name).AppendChild(maml_name_text);
                }
                command.AppendChild(inputTypes);
            }
            // For outputs, we prefer what was specified in the comments, but if there are no comments
            // and the OutputType attribute was specified, we'll use those instead.
            IEnumerable outputs = null;
            if (_outputs.Count > 0)
            {
                outputs = _outputs;
            }
            else if (_scriptBlock.OutputType.Count > 0)
            {
                outputs = _scriptBlock.OutputType;
            }
            if (outputs != null)
            {
                XmlElement returnValues = _doc.CreateElement("command:returnValues", commandURI);
                foreach (object output in outputs)
                {
                    XmlElement returnValue = _doc.CreateElement("command:returnValue", commandURI);
                    XmlElement type = _doc.CreateElement("dev:type", devURI);
                    XmlElement maml_name = _doc.CreateElement("maml:name", mamlURI);
                    string returnValueStr = output as string ?? ((PSTypeName)output).Name;
                    XmlText maml_name_text = _doc.CreateTextNode(returnValueStr);
                    returnValues.AppendChild(returnValue).AppendChild(type).AppendChild(maml_name).AppendChild(maml_name_text);
                }
                command.AppendChild(returnValues);
            }
            if (_links.Count > 0)
            {
                XmlElement links = _doc.CreateElement("maml:relatedLinks", mamlURI);
                foreach (string link in _links)
                {
                    XmlElement navigationLink = _doc.CreateElement("maml:navigationLink", mamlURI);
                    bool isOnlineHelp = Uri.IsWellFormedUriString(Uri.EscapeUriString(link), UriKind.Absolute);
                    string nodeName = isOnlineHelp ? "maml:uri" : "maml:linkText";
                    XmlElement linkText = _doc.CreateElement(nodeName, mamlURI);
                    XmlText linkText_text = _doc.CreateTextNode(link);
                    links.AppendChild(navigationLink).AppendChild(linkText).AppendChild(linkText_text);
                }
                command.AppendChild(links);
            }

            return _doc;
        }

        private void BuildSyntaxForParameterSet(XmlElement command, XmlElement syntax, MergedCommandParameterMetadata parameterMetadata, int i)
        {
            XmlElement syntaxItem = _doc.CreateElement("command:syntaxItem", commandURI);
            XmlElement syntaxItemName = _doc.CreateElement("maml:name", mamlURI);
            XmlText syntaxItemName_text = _doc.CreateTextNode(_commandName);

            syntaxItem.AppendChild(syntaxItemName).AppendChild(syntaxItemName_text);

            Collection<MergedCompiledCommandParameter> compiledParameters =
                parameterMetadata.GetParametersInParameterSet(1u << i);

            foreach (MergedCompiledCommandParameter mergedParameter in compiledParameters)
            {
                if (mergedParameter.BinderAssociation == ParameterBinderAssociation.CommonParameters)
                {
                    continue;
                }

                CompiledCommandParameter parameter = mergedParameter.Parameter;
                ParameterSetSpecificMetadata parameterSetData = parameter.GetParameterSetData(1u << i);
                string description = GetParameterDescription(parameter.Name);
                bool supportsWildcards = parameter.CompiledAttributes.Any(attribute => attribute is SupportsWildcardsAttribute);
                XmlElement parameterElement = BuildXmlForParameter(parameter.Name,
                    parameterSetData.IsMandatory, parameterSetData.ValueFromPipeline,
                    parameterSetData.ValueFromPipelineByPropertyName,
                    parameterSetData.IsPositional ? (1 + parameterSetData.Position).ToString(CultureInfo.InvariantCulture) : "named",
                    parameter.Type, description, supportsWildcards, defaultValue: "", forSyntax: true);
                syntaxItem.AppendChild(parameterElement);
            }
            command.AppendChild(syntax).AppendChild(syntaxItem);
        }

        private static void GetExampleSections(string content, out string prompt_str, out string code_str, out string remarks_str)
        {
            prompt_str = code_str = "";
            StringBuilder builder = new StringBuilder();

            int collectingPart = 1;
            foreach (char c in content)
            {
                if (c == '>' && collectingPart == 1)
                {
                    builder.Append(c);
                    prompt_str = builder.ToString().Trim();
                    builder = new StringBuilder();
                    ++collectingPart;
                    continue;
                }
                if (c == '\n' && collectingPart < 3)
                {
                    if (collectingPart == 1)
                    {
                        prompt_str = "PS C:\\>";
                    }
                    code_str = builder.ToString().Trim();
                    builder = new StringBuilder();
                    collectingPart = 3;
                    continue;
                }
                builder.Append(c);
            }

            if (collectingPart == 1)
            {
                prompt_str = "PS C:\\>";
                code_str = builder.ToString().Trim();
                remarks_str = "";
            }
            else
            {
                remarks_str = builder.ToString();
            }
        }

        /// <summary>
        /// Split the text in the comment token into multiple lines, appending commentLines.
        /// </summary>
        /// <param name="comment">A single line or multiline comment token</param>
        /// <param name="commentLines"></param>
        private static void CollectCommentText(Token comment, List<string> commentLines)
        {
            string text = comment.Text;
            CollectCommentText(text, commentLines);
        }

        private static void CollectCommentText(string text, List<string> commentLines)
        {
            int i = 0;
            if (text[0] == '<')
            {
                int start = 2;
                // The full text includes '<#', so start at index 2 to skip those characters,
                // and the full text also includes '#>' at the end, so skip those as well.
                for (i = 2; i < text.Length - 2; i++)
                {
                    if (text[i] == '\n')
                    {
                        commentLines.Add(text.Substring(start, i - start));
                        start = i + 1;
                    }
                    else if (text[i] == '\r')
                    {
                        commentLines.Add(text.Substring(start, i - start));

                        // No need to check length here, comment text has at least '#>' at the end.
                        if (text[i + 1] == '\n')
                        {
                            i++;
                        }
                        start = i + 1;
                    }
                }
                commentLines.Add(text.Substring(start, i - start));
            }
            else
            {
                for (; i < text.Length; i++)
                {
                    // Skip all leading '#' characters as it is a common convention
                    // to use more than one '#' character.
                    if (text[i] != '#')
                    {
                        break;
                    }
                }
                commentLines.Add(text.Substring(i));
            }
        }

        /// <summary>
        /// Collect the text of a section.  Stop collecting the section
        /// when a new directive is found (even if it is an unknown directive).
        /// </summary>
        /// <param name="commentLines">The comment block, as a list of lines.</param>
        /// <param name="i"></param>
        /// <returns>The text of the help section, with 'i' left on the last line collected.</returns>
        private static string GetSection(List<string> commentLines, ref int i)
        {
            bool capturing = false;
            int countLeadingWS = 0;
            StringBuilder sb = new StringBuilder();
            const char nbsp = (char)0xA0;

            for (i++; i < commentLines.Count; i++)
            {
                string line = commentLines[i];
                if (!capturing && Regex.IsMatch(line, blankline))
                {
                    // Skip blank lines before capturing anything in the section.
                    continue;
                }
                if (Regex.IsMatch(line, directive))
                {
                    // Break on any directive even if we haven't started capturing.
                    i--;
                    break;
                }

                // The first line of a section sets how much whitespace we'll ignore (and hence strip).
                if (!capturing)
                {
                    int j = 0;
                    while (j < line.Length && (line[j] == ' ' || line[j] == '\t' || line[j] == nbsp))
                    {
                        countLeadingWS++;
                        j++;
                    }
                }
                capturing = true;

                // Skip leading whitespace based on the first line in the section, skipping
                // only as much whitespace as the first line had, no more (and possibly less.)
                int start = 0;
                while (start < line.Length && start < countLeadingWS &&
                       (line[start] == ' ' || line[start] == '\t' || line[start] == nbsp))
                {
                    start++;
                }
                sb.Append(line.Substring(start));
                sb.Append('\n');
            }
            return sb.ToString();
        }

        internal string GetHelpFile(CommandInfo commandInfo)
        {
            if (_sections.MamlHelpFile == null)
            {
                return null;
            }

            string helpFileToLoad = _sections.MamlHelpFile;
            Collection<String> searchPaths = new Collection<String>();
            string scriptFile = ((IScriptCommandInfo)commandInfo).ScriptBlock.File;
            if (!string.IsNullOrEmpty(scriptFile))
            {
                helpFileToLoad = Path.Combine(Path.GetDirectoryName(scriptFile), _sections.MamlHelpFile);
            }
            else if (commandInfo.Module != null)
            {
                helpFileToLoad = Path.Combine(Path.GetDirectoryName(commandInfo.Module.Path), _sections.MamlHelpFile);
            }
            string location = MUIFileSearcher.LocateFile(helpFileToLoad, searchPaths);

            return location;
        }

        internal RemoteHelpInfo GetRemoteHelpInfo(ExecutionContext context, CommandInfo commandInfo)
        {
            if (string.IsNullOrEmpty(_sections.ForwardHelpTargetName) || string.IsNullOrEmpty(_sections.RemoteHelpRunspace))
            {
                return null;
            }

            // get the PSSession object from the variable specified in the comments
            IScriptCommandInfo scriptCommandInfo = (IScriptCommandInfo)commandInfo;
            SessionState sessionState = scriptCommandInfo.ScriptBlock.SessionState;
            object runspaceInfoAsObject = sessionState.PSVariable.GetValue(_sections.RemoteHelpRunspace);
            PSSession runspaceInfo;
            if (runspaceInfoAsObject == null ||
                !LanguagePrimitives.TryConvertTo(runspaceInfoAsObject, out runspaceInfo))
            {
                string errorMessage = HelpErrors.RemoteRunspaceNotAvailable;
                throw new InvalidOperationException(errorMessage);
            }

            return new RemoteHelpInfo(
                context,
                (RemoteRunspace)runspaceInfo.Runspace,
                commandInfo.Name,
                _sections.ForwardHelpTargetName,
                _sections.ForwardHelpCategory,
                commandInfo.HelpCategory);
        }

        /// <summary>
        /// Look for special comments indicating the comment block is meant
        /// to be used for help.
        /// </summary>
        /// <param name="comments">The list of comments to process</param>
        /// <returns>True if any special comments are found, false otherwise.</returns>
        internal bool AnalyzeCommentBlock(List<Token> comments)
        {
            if (comments == null || comments.Count == 0)
            {
                return false;
            }

            List<string> commentLines = new List<string>();
            foreach (Token comment in comments)
            {
                CollectCommentText(comment, commentLines);
            }

            return AnalyzeCommentBlock(commentLines);
        }

        private bool AnalyzeCommentBlock(List<string> commentLines)
        {
            bool directiveFound = false;
            for (int i = 0; i < commentLines.Count; i++)
            {
                Match match = Regex.Match(commentLines[i], directive);
                if (match.Success)
                {
                    directiveFound = true;

                    if (match.Groups[3].Success)
                    {
                        switch (match.Groups[1].Value.ToUpperInvariant())
                        {
                            case "PARAMETER":
                                {
                                    string param = match.Groups[3].Value.ToUpperInvariant().Trim();
                                    string section = GetSection(commentLines, ref i);
                                    if (!_parameters.ContainsKey(param))
                                    {
                                        _parameters.Add(param, section);
                                    }
                                    break;
                                }
                            case "FORWARDHELPTARGETNAME":
                                _sections.ForwardHelpTargetName = match.Groups[3].Value.Trim();
                                break;
                            case "FORWARDHELPCATEGORY":
                                _sections.ForwardHelpCategory = match.Groups[3].Value.Trim();
                                break;
                            case "REMOTEHELPRUNSPACE":
                                _sections.RemoteHelpRunspace = match.Groups[3].Value.Trim();
                                break;
                            case "EXTERNALHELP":
                                _sections.MamlHelpFile = match.Groups[3].Value.Trim();
                                isExternalHelpSet = true;
                                break;
                            default:
                                return false;
                        }
                    }
                    else
                    {
                        switch (match.Groups[1].Value.ToUpperInvariant())
                        {
                            case "SYNOPSIS":
                                _sections.Synopsis = GetSection(commentLines, ref i);
                                break;
                            case "DESCRIPTION":
                                _sections.Description = GetSection(commentLines, ref i);
                                break;
                            case "NOTES":
                                _sections.Notes = GetSection(commentLines, ref i);
                                break;
                            case "LINK":
                                _links.Add(GetSection(commentLines, ref i).Trim());
                                break;
                            case "EXAMPLE":
                                _examples.Add(GetSection(commentLines, ref i));
                                break;
                            case "INPUTS":
                                _inputs.Add(GetSection(commentLines, ref i));
                                break;
                            case "OUTPUTS":
                                _outputs.Add(GetSection(commentLines, ref i));
                                break;
                            case "COMPONENT":
                                _sections.Component = GetSection(commentLines, ref i).Trim();
                                break;
                            case "ROLE":
                                _sections.Role = GetSection(commentLines, ref i).Trim();
                                break;
                            case "FUNCTIONALITY":
                                _sections.Functionality = GetSection(commentLines, ref i).Trim();
                                break;
                            default:
                                return false;
                        }
                    }
                }
                else if (!Regex.IsMatch(commentLines[i], blankline))
                {
                    return false;
                }
            }

            _sections.Examples = new ReadOnlyCollection<string>(_examples);
            _sections.Inputs = new ReadOnlyCollection<string>(_inputs);
            _sections.Outputs = new ReadOnlyCollection<string>(_outputs);
            _sections.Links = new ReadOnlyCollection<string>(_links);
            // TODO, Changing this to an IDictionary because ReadOnlyDictionary is available only in .NET 4.5
            // This is a temporary workaround and will be fixed later. Tracked by Win8: 354135
            _sections.Parameters = new Dictionary<string, string>(_parameters);

            return directiveFound;
        }

        /// <summary>
        /// The analysis of the comments finds the component, functionality, and role fields, but
        /// those fields aren't added to the xml because they aren't children of the command xml
        /// node, they are under a sibling of the command xml node and apply to all command nodes
        /// in a maml file.
        /// </summary>
        /// <param name="helpInfo">The helpInfo object to set the fields on.</param>
        internal void SetAdditionalData(MamlCommandHelpInfo helpInfo)
        {
            helpInfo.SetAdditionalDataFromHelpComment(
                _sections.Component,
                _sections.Functionality,
                _sections.Role);
        }

        internal static CommentHelpInfo GetHelpContents(List<Language.Token> comments, List<string> parameterDescriptions)
        {
            HelpCommentsParser helpCommentsParser = new HelpCommentsParser(parameterDescriptions);
            helpCommentsParser.AnalyzeCommentBlock(comments);
            return helpCommentsParser._sections;
        }

        internal static HelpInfo CreateFromComments(ExecutionContext context,
                                                    CommandInfo commandInfo,
                                                    List<Language.Token> comments,
                                                    List<string> parameterDescriptions,
                                                    bool dontSearchOnRemoteComputer,
                                                    out string helpFile, out string helpUriFromDotLink)
        {
            HelpCommentsParser helpCommentsParser = new HelpCommentsParser(commandInfo, parameterDescriptions);
            helpCommentsParser.AnalyzeCommentBlock(comments);

            if (helpCommentsParser._sections.Links != null && helpCommentsParser._sections.Links.Count != 0)
            {
                helpUriFromDotLink = helpCommentsParser._sections.Links[0];
            }
            else
            {
                helpUriFromDotLink = null;
            }

            helpFile = helpCommentsParser.GetHelpFile(commandInfo);

            // If only .ExternalHelp is defined and the help file is not found, then we
            // use the metadata driven help
            if (comments.Count == 1 && helpCommentsParser.isExternalHelpSet && helpFile == null)
            {
                return null;
            }

            return CreateFromComments(context, commandInfo, helpCommentsParser, dontSearchOnRemoteComputer);
        }

        internal static HelpInfo CreateFromComments(ExecutionContext context, CommandInfo commandInfo, HelpCommentsParser helpCommentsParser,
            bool dontSearchOnRemoteComputer)
        {
            if (!dontSearchOnRemoteComputer)
            {
                RemoteHelpInfo remoteHelpInfo = helpCommentsParser.GetRemoteHelpInfo(context, commandInfo);
                if (remoteHelpInfo != null)
                {
                    // Add HelpUri if necessary
                    if (remoteHelpInfo.GetUriForOnlineHelp() == null)
                    {
                        DefaultCommandHelpObjectBuilder.AddRelatedLinksProperties(remoteHelpInfo.FullHelp,
                                                                                commandInfo.CommandMetadata.HelpUri);
                    }

                    return remoteHelpInfo;
                }
            }

            XmlDocument doc = helpCommentsParser.BuildXmlFromComments();
            HelpCategory helpCategory = commandInfo.HelpCategory;
            MamlCommandHelpInfo localHelpInfo = MamlCommandHelpInfo.Load(doc.DocumentElement, helpCategory);
            if (localHelpInfo != null)
            {
                helpCommentsParser.SetAdditionalData(localHelpInfo);

                if (!string.IsNullOrEmpty(helpCommentsParser._sections.ForwardHelpTargetName)
                    || !string.IsNullOrEmpty(helpCommentsParser._sections.ForwardHelpCategory))
                {
                    if (string.IsNullOrEmpty(helpCommentsParser._sections.ForwardHelpTargetName))
                    {
                        localHelpInfo.ForwardTarget = localHelpInfo.Name;
                    }
                    else
                    {
                        localHelpInfo.ForwardTarget = helpCommentsParser._sections.ForwardHelpTargetName;
                    }
                    if (!string.IsNullOrEmpty(helpCommentsParser._sections.ForwardHelpCategory))
                    {
                        try
                        {
                            localHelpInfo.ForwardHelpCategory = (HelpCategory)Enum.Parse(typeof(HelpCategory), helpCommentsParser._sections.ForwardHelpCategory, true);
                        }
                        catch (System.ArgumentException)
                        {
                            // Ignore conversion errors.
                        }
                    }
                    else
                    {
                        localHelpInfo.ForwardHelpCategory = (HelpCategory.Alias |
                                                             HelpCategory.Cmdlet |
                                                             HelpCategory.ExternalScript |
                                                             HelpCategory.Filter |
                                                             HelpCategory.Function |
                                                             HelpCategory.ScriptCommand |
                                                             HelpCategory.Workflow);
                    }
                }

                WorkflowInfo workflowInfo = commandInfo as WorkflowInfo;
                if (workflowInfo != null)
                {
                    bool common = DefaultCommandHelpObjectBuilder.HasCommonParameters(commandInfo.Parameters);
                    bool commonWorkflow = ((commandInfo.CommandType & CommandTypes.Workflow) ==
                                           CommandTypes.Workflow);

                    localHelpInfo.FullHelp.Properties.Add(new PSNoteProperty("CommonParameters", common));
                    localHelpInfo.FullHelp.Properties.Add(new PSNoteProperty("WorkflowCommonParameters", commonWorkflow));
                    DefaultCommandHelpObjectBuilder.AddDetailsProperties(obj: localHelpInfo.FullHelp, name: workflowInfo.Name,
                                                                        noun: workflowInfo.Noun, verb: workflowInfo.Verb,
                                                                        typeNameForHelp: "MamlCommandHelpInfo", synopsis: localHelpInfo.Synopsis);
                    DefaultCommandHelpObjectBuilder.AddSyntaxProperties(localHelpInfo.FullHelp, workflowInfo.Name,
                                                                        workflowInfo.ParameterSets, common, commonWorkflow, "MamlCommandHelpInfo");
                }

                // Add HelpUri if necessary
                if (localHelpInfo.GetUriForOnlineHelp() == null)
                {
                    DefaultCommandHelpObjectBuilder.AddRelatedLinksProperties(localHelpInfo.FullHelp, commandInfo.CommandMetadata.HelpUri);
                }
            }

            return localHelpInfo;
        }

        /// <summary>
        /// Analyze a block of comments to determine if it is a special help block.
        /// </summary>
        /// <param name="commentBlock">The block of comments to analyze.</param>
        /// <returns>true if the block is our special comment block for help, false otherwise.</returns>
        internal static bool IsCommentHelpText(List<Token> commentBlock)
        {
            if ((commentBlock == null) || (commentBlock.Count == 0))
                return false;

            HelpCommentsParser generator = new HelpCommentsParser();
            return generator.AnalyzeCommentBlock(commentBlock);
        }

        #region Collect comments from AST

        private static List<Language.Token> GetCommentBlock(Language.Token[] tokens, ref int startIndex)
        {
            var result = new List<Language.Token>();

            // Any whitespace between the token and the first comment is allowed.
            int nextMaxStartLine = Int32.MaxValue;

            for (int i = startIndex; i < tokens.Length; i++)
            {
                Language.Token current = tokens[i];

                // If the current token starts on a line beyond the current "chunk",
                // then we're done scanning.
                if (current.Extent.StartLineNumber > nextMaxStartLine)
                {
                    startIndex = i;
                    break;
                }

                if (current.Kind == TokenKind.Comment)
                {
                    result.Add(current);

                    // The next comment must be on either the same line as this comment ends, or
                    // the next line, but nowhere else, otherwise it's not in the same "chunk".
                    nextMaxStartLine = current.Extent.EndLineNumber + 1;
                }
                else if (current.Kind != TokenKind.NewLine)
                {
                    // A non-comment, non-position token means we are no longer collecting comments
                    startIndex = i;
                    break;
                }
            }

            return result;
        }

        private static List<Language.Token> GetPrecedingCommentBlock(Language.Token[] tokens, int tokenIndex, int proximity)
        {
            var result = new List<Language.Token>();
            int minEndLine = tokens[tokenIndex].Extent.StartLineNumber - proximity;

            for (int i = tokenIndex - 1; i >= 0; i--)
            {
                Language.Token current = tokens[i];

                if (current.Extent.EndLineNumber < minEndLine)
                    break;

                if (current.Kind == TokenKind.Comment)
                {
                    result.Add(current);
                    minEndLine = current.Extent.StartLineNumber - 1;
                }
                else if (current.Kind != TokenKind.NewLine)
                {
                    break;
                }
            }
            result.Reverse();
            return result;
        }

        private static int FirstTokenInExtent(Language.Token[] tokens, IScriptExtent extent, int startIndex = 0)
        {
            int index;
            for (index = startIndex; index < tokens.Length; ++index)
            {
                if (!tokens[index].Extent.IsBefore(extent))
                {
                    break;
                }
            }
            return index;
        }

        private static int LastTokenInExtent(Language.Token[] tokens, IScriptExtent extent, int startIndex)
        {
            int index;
            for (index = startIndex; index < tokens.Length; ++index)
            {
                if (tokens[index].Extent.IsAfter(extent))
                {
                    break;
                }
            }
            return index - 1;
        }

        internal const int CommentBlockProximity = 2;

        private static List<string> GetParameterComments(Language.Token[] tokens, IParameterMetadataProvider ipmp, int startIndex)
        {
            var result = new List<string>();
            var parameters = ipmp.Parameters;
            if (parameters == null || parameters.Count == 0)
            {
                return result;
            }

            foreach (var parameter in parameters)
            {
                var commentLines = new List<string>();

                var firstToken = FirstTokenInExtent(tokens, parameter.Extent, startIndex);
                var comments = GetPrecedingCommentBlock(tokens, firstToken, CommentBlockProximity);
                if (comments != null)
                {
                    foreach (var comment in comments)
                    {
                        CollectCommentText(comment, commentLines);
                    }
                }

                var lastToken = LastTokenInExtent(tokens, parameter.Extent, firstToken);
                for (int i = firstToken; i < lastToken; ++i)
                {
                    if (tokens[i].Kind == TokenKind.Comment)
                    {
                        CollectCommentText(tokens[i], commentLines);
                    }
                }

                lastToken += 1;
                comments = GetCommentBlock(tokens, ref lastToken);
                if (comments != null)
                {
                    foreach (var comment in comments)
                    {
                        CollectCommentText(comment, commentLines);
                    }
                }

                int n = -1;
                result.Add(GetSection(commentLines, ref n));
            }
            return result;
        }

        internal static Tuple<List<Language.Token>, List<string>> GetHelpCommentTokens(IParameterMetadataProvider ipmp,
            Dictionary<Ast, Token[]> scriptBlockTokenCache)
        {
            Diagnostics.Assert(scriptBlockTokenCache != null, "scriptBlockTokenCache cannot be null");
            var ast = (Ast)ipmp;

            var rootAst = ast;
            Ast configAst = null;
            while (rootAst.Parent != null)
            {
                rootAst = rootAst.Parent;
                if (rootAst is ConfigurationDefinitionAst)
                {
                    configAst = rootAst;
                }
            }

            //  tokens saved from reparsing the script.
            Language.Token[] tokens = null;
            scriptBlockTokenCache.TryGetValue(rootAst, out tokens);

            if (tokens == null)
            {
                ParseError[] errors;
                // storing all comment tokens
                Language.Parser.ParseInput(rootAst.Extent.Text, out tokens, out errors);
                scriptBlockTokenCache[rootAst] = tokens;
            }

            int savedStartIndex;
            int startTokenIndex;
            int lastTokenIndex;

            var funcDefnAst = ast as FunctionDefinitionAst;
            List<Language.Token> commentBlock;
            if (funcDefnAst != null || configAst != null)
            {
                // The first comment block preceding the function or configuration keyword is a candidate help comment block.
                var funcOrConfigTokenIndex =
                    savedStartIndex = FirstTokenInExtent(tokens, configAst == null ? ast.Extent : configAst.Extent);

                commentBlock = GetPrecedingCommentBlock(tokens, funcOrConfigTokenIndex, CommentBlockProximity);

                if (HelpCommentsParser.IsCommentHelpText(commentBlock))
                {
                    return Tuple.Create(commentBlock, GetParameterComments(tokens, ipmp, savedStartIndex));
                }

                // comment block is behind function definition
                // we don't support it for configuration declaration as this style is rarely used
                if (funcDefnAst != null)
                {
                    startTokenIndex =
                        FirstTokenInExtent(tokens, funcDefnAst.Body.Extent) + 1;
                    lastTokenIndex = LastTokenInExtent(tokens, ast.Extent, funcOrConfigTokenIndex);

                    Diagnostics.Assert(tokens[startTokenIndex - 1].Kind == TokenKind.LCurly,
                        "Unexpected first token in function");
                    Diagnostics.Assert(tokens[lastTokenIndex].Kind == TokenKind.RCurly,
                        "Unexpected last token in function");
                }
                else
                {
                    return null;
                }
            }
            else if (ast == rootAst)
            {
                startTokenIndex = savedStartIndex = 0;
                lastTokenIndex = tokens.Length - 1;
            }
            else
            {
                // This case should be rare (but common with implicit remoting).
                // We have a script block that was used to generate a function like:
                //     $sb = { }
                //     set-item function:foo $sb
                //     help foo
                startTokenIndex = savedStartIndex = FirstTokenInExtent(tokens, ast.Extent) - 1;
                lastTokenIndex = LastTokenInExtent(tokens, ast.Extent, startTokenIndex);

                Diagnostics.Assert(tokens[startTokenIndex + 1].Kind == TokenKind.LCurly,
                    "Unexpected first token in script block");
                Diagnostics.Assert(tokens[lastTokenIndex].Kind == TokenKind.RCurly,
                    "Unexpected last token in script block");
            }

            while (true)
            {
                commentBlock = GetCommentBlock(tokens, ref startTokenIndex);
                if (commentBlock.Count == 0)
                    break;

                if (!HelpCommentsParser.IsCommentHelpText(commentBlock))
                    continue;

                if (ast == rootAst)
                {
                    // One more check - make sure the comment doesn't belong to the first function in the script.
                    var endBlock = ((ScriptBlockAst)ast).EndBlock;
                    if (endBlock == null || !endBlock.Unnamed)
                    {
                        return Tuple.Create(commentBlock, GetParameterComments(tokens, ipmp, savedStartIndex));
                    }

                    var firstStatement = endBlock.Statements.FirstOrDefault();
                    if (firstStatement is FunctionDefinitionAst)
                    {
                        int linesBetween = firstStatement.Extent.StartLineNumber -
                                            commentBlock.Last().Extent.EndLineNumber;
                        if (linesBetween > CommentBlockProximity)
                        {
                            return Tuple.Create(commentBlock, GetParameterComments(tokens, ipmp, savedStartIndex));
                        }
                        break;
                    }
                }

                return Tuple.Create(commentBlock, GetParameterComments(tokens, ipmp, savedStartIndex));
            }

            commentBlock = GetPrecedingCommentBlock(tokens, lastTokenIndex, tokens[lastTokenIndex].Extent.StartLineNumber);
            if (HelpCommentsParser.IsCommentHelpText(commentBlock))
            {
                return Tuple.Create(commentBlock, GetParameterComments(tokens, ipmp, savedStartIndex));
            }

            return null;
        }

        #endregion Collect comments from AST
    }
}


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

<title>Uses of Class brown.tracingplane.baggageprotocol.BaggageLayerException</title>
<meta name="date" content="2017-05-31">
<link rel="stylesheet" type="text/css" href="../../../../javadoc-stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Skip navigation links

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev

Next

Frames

No Frames

All Classes

Uses of Class
brown.tracingplane.baggageprotocol.BaggageLayerException

Packages that use BaggageLayerException

Package
Description

brown.tracingplane.baggageprotocol

 Defines an encoding scheme for nested data structures using atoms.

Uses of BaggageLayerException in brown.tracingplane.baggageprotocol

Methods in brown.tracingplane.baggageprotocol that throw BaggageLayerException

Modifier and Type
Method and Description

static BagKey
HeaderSerialization.parse(AtomPrefixes.HeaderPrefix prefix,
     java.nio.ByteBuffer buf)

Parses a bag key

static BagKey
HeaderSerialization.parse(java.nio.ByteBuffer atom)

Parses a bag key from the provided atom

static BagKey
HeaderSerialization.parseIndexedHeaderPayload(AtomPrefixes.HeaderPrefix prefix,
                         java.nio.ByteBuffer buf)

Parse the payload of an indexed header

static BagKey
HeaderSerialization.parseKeyedHeaderPayload(AtomPrefixes.HeaderPrefix prefix,
                       java.nio.ByteBuffer buf)

Parse the payload of a keyed header

Skip navigation links

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev

Next

Frames

No Frames

All Classes


text:
{% extends "aldryn_faq/base.html" %}
{% load i18n cms_tags %}

{% block main-column-class %}aldryn aldryn-faq{% endblock main-column-class %}
{% block secondary-column-class %}aldryn aldryn-faq aldryn-faq-sidebar{% endblock secondary-column-class %}

{% block content %}
    {% block faq_title %}{% endblock %}
    {% block faq_content %}
        {% render_placeholder view.config.placeholder_faq_content %}
    {% endblock %}
    {% block faq_footer %}{% endblock %}
{% endblock content %}

{% block sidebar-content %}
    {% block faq_sidebar %}
        {% render_placeholder view.config.placeholder_faq_sidebar_top %}
        {% include "aldryn_faq/plugins/category_list.html" with categories=category_list %}
        {% render_placeholder view.config.placeholder_faq_sidebar_bottom %}
    {% endblock %}
{% endblock sidebar-content %}


text:
import inspect
class mycallable:
    def __init__(self, fun, nargs=None):
        '''make a callable out of fun, record number of args'''
        if nargs == None:
            if isinstance(fun, mycallable): self.nargs = fun.nargs
            else: self.nargs = len(inspect.getargspec(fun).args)
        else: self.nargs = nargs
        self.fun = fun
    def __add__(self, fun):
        '''compose self and fun'''
        f = (mycallable(fun) if not isinstance(fun, mycallable) else fun)
        return mycallable(lambda *args: self(f(*args)), f.nargs)
    def __call__(self, *args):
        '''do the currying'''
        if len(args) == self.nargs: # straight call
            return self.fun(*args)
        if len(args) == 0: # f() == f when arity of f is not 0
            return self
        if len(args) < self.nargs: # too few args
            return mycallable(lambda *ars: self.fun(*(args + ars)),
                              self.nargs-len(args))
        if len(args) > self.nargs: # if l x,y:x+y defined as l x:(l y:x+y)
            rargs = args[self.nargs:]
            res = self.fun(*(args[:self.nargs]))
            return (res(*rargs) if isinstance(res, mycallable) else res)

f = mycallable(lambda x,y : x + y)
h = mycallable(lambda x: x**2)
print (h + f)(1)(2)

f = lambda x : (x + 2, 'f added 2 to %d' % x)
g = lambda x : (x**2,  'g raised %d to the power of 2' % x)
print f(2)


text:
package com.rhomobile.rhodes.osfunctionality;

import android.content.Context;
import android.webkit.WebView;

public interface AndroidFunctionality {
    final String TAG = AndroidFunctionality.class.getSimpleName();
    String AccessOwnerInfo_getEmail(Context context);
    String AccessOwnerInfo_getUsername(Context context);

    /**
     * Returns current screen rotation against default device rotation
     * @return screen rotation in degrees
     */
    int getDeviceRotation(Context context);

    /**
     * Returns current screen orientation
     * @return value in terms of ActivityInfo.screenOrientation
     */
    int getScreenOrientation(Context context);

    void pauseWebView( WebView view, boolean doPause );
}


text:
<configuration scan="true">

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{25} - %msg%n</pattern>
        </encoder>
    </appender>

    <!--<appender name="FILE" class="ch.qos.logback.core.FileAppender">
        <file>gpwquoter.log</file>
        <append>false</append>
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{25} - %msg%n</pattern>
        </encoder>
    </appender>-->

    <logger name="it.milczarek.gpwquoter.handler.QuotesLoggingHandler" level="info"/>
    <logger name="it.milczarek.gpwquoter.handler.QuotesJdbcHandler" level="debug"/>
    <logger name="slick.compiler.QueryCompiler" level="info"/>

    <root level="info">
        <!--<appender-ref ref="FILE"/>-->
        <appender-ref ref="STDOUT"/>
    </root>
</configuration>


text:
import os
from distutils.dir_util import copy_tree

IPYTHON_PATH = os.path.join("..", "ipython")

def update():
    """Pull the latest documentation from the neighboring /ipython directory.

    This will update the tutorial/example notebooks inside this directory with
    the notebooks in the local IPython repository.  Any changes pulled from
    the ipython directory will overwrite the old contents in this directory.
    This script does not run `git remote update` or `git checkout master` in the
    ipython repository, instead you are responsible for that."""
    destination = os.path.join('examples')
    source = os.path.join(IPYTHON_PATH, 'examples')
    copy_tree(source, destination)