step 1a as defined for the porter stemmer algorithm.
161391
function step1a$1(token) {
                var r1 = getR1(token);

                if (!r1) {
                    return token;
                }

                var r1Match = r1.match(/(a|e|ede|ande|ende|ane|ene|hetene|en|heten|ar|er|heter|as|es|edes|endes|enes|hetenes|ens|hetens|ers|ets|et|het|ast)$/);

                if (r1Match) {
                    return token.replace(new RegExp(r1Match[1] + '$'), '');
                }

                return token;
            }
572163
def do_step(self, values, xy_values,coeff, width):
        """"""
        forces = {k:[] for k,i in enumerate(xy_values)}
        for (index1, value1), (index2,value2) in combinations(enumerate(xy_values),2):
            f = self.calc_2d_forces(value1[0],value1[1],value2[0],value2[1],width)
            if coeff[index1] < coeff[index2]:
                if self.b_lenght-coeff[index2]<self.b_lenght/10: #a quick and dirty solution, but works
                    forces[index1].append(f[1]) # push to left (smaller projection value)
                    forces[index2].append(f[0])
                else:
                    #all is normal
                    forces[index1].append(f[0]) # push to left (smaller projection value)
                    forces[index2].append(f[1])
            else:
                if self.b_lenght-coeff[index1]<self.b_lenght/10: #a quick and dirty solution, but works
                    forces[index1].append(f[0]) # push to left (smaller projection value)
                    forces[index2].append(f[1])
                else:
                #if all is normal
                    forces[index1].append(f[1]) # push to left (smaller projection value)
                    forces[index2].append(f[0])
        forces = {k:sum(v) for k,v in forces.items()}

        energy = sum([abs(x) for x in forces.values()])

        return [(forces[k]/10+v) for k, v in enumerate(values)], energy
1056008
private final void step3() {
        if (k == 0) {
            return;
        }

        switch (b[k - 1]) {
            case 'a':
                if (endWith("ational")) {
                    r("ate");
                    break;
                }
                if (endWith("tional")) {
                    r("tion");
                    break;
                }
                break;
            case 'c':
                if (endWith("enci")) {
                    r("ence");
                    break;
                }
                if (endWith("anci")) {
                    r("ance");
                    break;
                }
                break;
            case 'e':
                if (endWith("izer")) {
                    r("ize");
                    break;
                }
                break;
            case 'l':
                if (endWith("bli")) {
                    r("ble");
                    break;
                }
                if (endWith("alli")) {
                    r("al");
                    break;
                }
                if (endWith("entli")) {
                    r("ent");
                    break;
                }
                if (endWith("eli")) {
                    r("e");
                    break;
                }
                if (endWith("ousli")) {
                    r("ous");
                    break;
                }
                break;
            case 'o':
                if (endWith("ization")) {
                    r("ize");
                    break;
                }
                if (endWith("ation")) {
                    r("ate");
                    break;
                }
                if (endWith("ator")) {
                    r("ate");
                    break;
                }
                break;
            case 's':
                if (endWith("alism")) {
                    r("al");
                    break;
                }
                if (endWith("iveness")) {
                    r("ive");
                    break;
                }
                if (endWith("fulness")) {
                    r("ful");
                    break;
                }
                if (endWith("ousness")) {
                    r("ous");
                    break;
                }
                break;
            case 't':
                if (endWith("aliti")) {
                    r("al");
                    break;
                }
                if (endWith("iviti")) {
                    r("ive");
                    break;
                }
                if (endWith("biliti")) {
                    r("ble");
                    break;
                }
                break;
            case 'g':
                if (endWith("logi")) {
                    r("log");
                    break;
                }
        }
    }
1002643
def tsp(edges, constraint_generation=False):
    
    edges = populate_edge_weights(edges)
    incoming, outgoing, nodes = node_to_edge(edges)

    nedges, nnodes = len(edges), len(nodes)
    L = LPInstance()

    L.add_objective(edges, objective=MINIMIZE)
    balance = []
    # For each node, select exactly 1 incoming and 1 outgoing edge
    for v in nodes:
        incoming_edges = incoming[v]
        outgoing_edges = outgoing[v]
        icc = summation(incoming_edges)
        occ = summation(outgoing_edges)
        balance.append("{0} = 1".format(icc))
        balance.append("{0} = 1".format(occ))

    # Subtour elimination - Miller-Tucker-Zemlin (MTZ) formulation
    # <http://en.wikipedia.org/wiki/Travelling_salesman_problem>
    # Desrochers and laporte, 1991 (DFJ) has a stronger constraint
    # See also:
    # G. Laporte / The traveling salesman problem: Overview of algorithms
    start_step = nedges + 1
    u0 = nodes[0]
    nodes_to_steps = dict((n, start_step + i) for i, n in enumerate(nodes[1:]))
    edge_store = dict((e[:2], i) for i, e in enumerate(edges))
    mtz = []
    for i, e in enumerate(edges):
        a, b = e[:2]
        if u0 in (a, b):
            continue
        na, nb = nodes_to_steps[a], nodes_to_steps[b]
        con_ab = " x{0} - x{1} + {2}x{3}".format(na, nb, nnodes - 1, i + 1)
        if (b, a) in edge_store:  # This extra term is the stronger DFJ formulation
            j = edge_store[(b, a)]
            con_ab += " + {0}x{1}".format(nnodes - 3, j + 1)
        con_ab += " <= {0}".format(nnodes - 2)
        mtz.append(con_ab)

    # Step variables u_i bound between 1 and n, as additional variables
    bounds = []
    for i in xrange(start_step, nedges + nnodes):
        bounds.append(" 1 <= x{0} <= {1}".format(i, nnodes - 1))

    L.add_vars(nedges)

    """
    Constraint generation seek to find 'cuts' in the LP problem, by solving the
    relaxed form. The subtours were then incrementally added to the constraints.
    """
    if constraint_generation:
        L.constraints = balance
        subtours = []
        while True:
            selected, obj_val = L.lpsolve()
            results = sorted(x for i, x in enumerate(edges) if i in selected) \
                if selected else None
            if not results:
                break
            G = edges_to_graph(results)
            cycles = list(nx.simple_cycles(G))
            if len(cycles) == 1:
                break
            for c in cycles:
                incident = [edge_store[a, b] for a, b in pairwise(c + [c[0]])]
                icc = summation(incident)
                subtours.append("{0} <= {1}".format(icc, len(incident) - 1))
            L.constraints = balance + subtours
    else:
        L.constraints = balance + mtz
        L.add_vars(nnodes - 1, offset=start_step, binary=False)
        L.bounds = bounds
        selected, obj_val = L.lpsolve()
        results = sorted(x for i, x in enumerate(edges) if i in selected) \
            if selected else None

    return results
417303
def step(self, tau=1.0, state_fb=None):
        

        # run canonical system
        cs_args = {'tau':tau,
                   'error_coupling':1.0}
        if state_fb is not None: 
            # take the 2 norm of the overall error
            state_fb = state_fb.reshape(1,self.dmps)
            dist = np.sqrt(np.sum((state_fb - self.y)**2))
            cs_args['error_coupling'] = 1.0 / (1.0 + 10*dist)
        x = self.cs.step(**cs_args)

        # generate basis function activation
        psi = self.gen_psi(x)

        for d in range(self.dmps):

            # generate the forcing term
            f = self.gen_front_term(x, d) * \
                (np.dot(psi, self.w[d])) / np.sum(psi) if self.bfs > 0. else 0.

            # DMP acceleration
            self.ddy[d] = (self.ay[d] * 
                     (self.by[d] * (self.goal[d] - self.y[d]) - \
                     self.dy[d]/tau) + f) * tau
            self.dy[d] += self.ddy[d] * tau * self.dt * cs_args['error_coupling']
            self.y[d] += self.dy[d] * self.dt * cs_args['error_coupling']

        return self.y, self.dy, self.ddy
678871
def step(self, t, x_im1, v_im1_2, dt):
        

        x_i = x_im1 + v_im1_2 * dt
        F_i = self.F(t, np.vstack((x_i, v_im1_2)), *self._func_args)
        a_i = F_i[self.ndim:]

        v_i = v_im1_2 + a_i * dt / 2
        v_ip1_2 = v_i + a_i * dt / 2

        return x_i, v_i, v_ip1_2
1226632
private final void step4() {
		switch (b[k]) {
		case 'e':
			if (ends("icate")) {
				r("ic");
				break;
			}
			if (ends("ative")) {
				r("");
				break;
			}
			if (ends("alize")) {
				r("al");
				break;
			}
			break;
		case 'i':
			if (ends("iciti")) {
				r("ic");
				break;
			}
			break;
		case 'l':
			if (ends("ical")) {
				r("ic");
				break;
			}
			if (ends("ful")) {
				r("");
				break;
			}
			break;
		case 's':
			if (ends("ness")) {
				r("");
				break;
			}
			break;
		}
	}
181780
private DoubleMatrix1D calculateNewtonStep(DoubleMatrix2D hessX, DoubleMatrix1D gradX) throws Exception {
		final KKTSolver kktSolver = new BasicKKTSolver();
		if(isCheckKKTSolutionAccuracy()){
			kktSolver.setCheckKKTSolutionAccuracy(isCheckKKTSolutionAccuracy());
			kktSolver.setToleranceKKT(getToleranceKKT());
		}
		kktSolver.setHMatrix(hessX);
		kktSolver.setGVector(gradX);
		DoubleMatrix1D[] sol = kktSolver.solve();
		DoubleMatrix1D step = sol[0];
		return step;
	}
994784
function step(x, a, p, q) {
      var temp, w;

      temp = p <= 0.5 ? gratio(a)(x) - p : q - gratioc(a)(x);
      temp /= r(a, x);
      w = (a - 1 - x) / 2;
      if (Math.max(Math.abs(temp), Math.abs(w * temp)) <= 0.1) {
         return x * (1 - (temp + w * temp * temp));
      }
      return x * (1 - temp);
   }
538832
def _subsequent_step_to_match(match_step):
    """"""
    if not isinstance(match_step.root_block, (Traverse, Recurse)):
        raise AssertionError(u'Expected Traverse root block, received: '
                             u'{} {}'.format(match_step.root_block, match_step))

    is_recursing = isinstance(match_step.root_block, Recurse)

    match_step.root_block.validate()

    traversal_command = u'.%s(\'%s\')' % (match_step.root_block.direction,
                                          match_step.root_block.edge_name)

    parts = []
    if match_step.coerce_type_block:
        coerce_type_set = match_step.coerce_type_block.target_class
        if len(coerce_type_set) != 1:
            raise AssertionError(u'Found MATCH type coercion block with more than one target class:'
                                 u' {} {}'.format(coerce_type_set, match_step))
        coerce_type_target = list(coerce_type_set)[0]
        parts.append(u'class: %s' % (coerce_type_target,))

    if is_recursing:
        # In MATCH, "$depth < 1" means "include the source vertex and its immediate neighbors."
        # Yes, the "<" is intentional -- it's not supposed to be a "<=".
        parts.append(u'while: ($depth < %d)' % (match_step.root_block.depth,))

    if match_step.where_block:
        match_step.where_block.validate()
        parts.append(u'where: (%s)' % (match_step.where_block.predicate.to_match(),))

    if not is_recursing and match_step.root_block.optional:
        parts.append(u'optional: true')

    if match_step.as_block:
        match_step.as_block.validate()
        parts.append(u'as: %s' % (_get_vertex_location_name(match_step.as_block.location),))

    return u'%s {{ %s }}' % (traversal_command, u', '.join(parts))
332987
function step1b(token) {
    var r1 = getR1(token);

    if (!r1) {
        return token;
    }

    if (token.match(/(b|c|d|f|g|h|j|l|m|n|o|p|r|t|v|y|z)s$/)) {
        return token.slice(0, -1);
    }

    if (token.match(/([^aeiouyæåø]k)s$/)) {
        return token.slice(0, -1);
    }

    return token;
}
629142
private double algorithm1(String[] tTokens, String[] uTokens,
                            double[] tIdfArray, double[] uIdfArray) {
    ArrayList candidateList = obtainCandidateList(tTokens, uTokens, tIdfArray,
                                                  uIdfArray);
    sortCandidateList(candidateList);
    double scoreValue = 0.0;
    HashMap tMap = new HashMap(),
        uMap = new HashMap();
    Iterator it = candidateList.iterator();
    while (it.hasNext()) {
      Candidates actualCandidates = (Candidates) it.next();
      Integer tPos = new Integer(actualCandidates.getTPos());
      Integer uPos = new Integer(actualCandidates.getUPos());
      if ( (!tMap.containsKey(tPos)) &&
          (!uMap.containsKey(uPos))) {
        double actualScore = actualCandidates.getScore();
        scoreValue += actualScore;
        tMap.put(tPos, null);
        uMap.put(uPos, null);
      }
    }
    return scoreValue;
  }
700309
protected function firstStep()
    {
        $this->logger->info('Beginning the first step');

        // Allocate all the ballots
        foreach ($this->ballots as $i => $ballot) {
            $this->allocateVotes($ballot);
        }

        $this->logger->notice('Step 1 complete',
            ['candidatesStatus' => $this->election->getCandidatesStatus()]
        );

        $this->steps[1] = $this->election->getCandidatesStatus();

        return;
    }
83327
private void step1(DBIDRef id, WritableDBIDDataStore pi, WritableDoubleDataStore lambda) {
    // P(n+1) = n+1:
    pi.put(id, id);
    // L(n+1) = infinity
    // Initialized already.
    // lambda.putDouble(id, Double.POSITIVE_INFINITY);
  }
526089
function step1 ( srcs ) {
				var map = Object.create ( null );
				function next ( source, parts, map ) {
					var part = parts.shift ();
					if ( !parts.length ) {
						map [ part ] = source;
					} else {
						map [ part ] = map [ part ] || Object.create ( null );
						next ( source, parts, map [ part ]);
					}
				}
				srcs.forEach ( function ( source ) {
					next ( source, source.split ( "/" ), map );
				});
				return map;
			}
944122
def step(self, loss, optimizer, scheduler, update=True):
        
        loss.backward()
        if update:
            if self.grad_clip != float('inf'):
                clip_grad_norm_(self.model.parameters(), self.grad_clip)
            scheduler.step()
            optimizer.step()
            self.model.zero_grad()
523696
def ystep(self):
        
        """

        AXU = self.AX + self.U
        Y0 = (self.rho*(self.block_sep0(AXU) - self.S)) / (self.W**2 +
                                                           self.rho)
        Y1 = self.Pcn(self.block_sep1(AXU))
        self.Y = self.block_cat(Y0, Y1)