Returns this word in context, {size} words to the left, the current word, and {size} words to the right
175249
def context(self, size, placeholder=None, scope=None):
        """"""
        return self.leftcontext(size, placeholder,scope) + [self] + self.rightcontext(size, placeholder,scope)
116432
private IContext findMultiwordsInContextStructure(IContext context) throws ContextPreprocessorException {
        for (Iterator<INode> i = context.getNodes(); i.hasNext(); ) {
            INode sourceNode = i.next();
            // sense disambiguation within the context structure
            // for all ACoLs in the source node
            for (Iterator<IAtomicConceptOfLabel> j = sourceNode.getNodeData().getACoLs(); j.hasNext(); ) {
                IAtomicConceptOfLabel synSource = j.next();
                // in all descendants and ancestors
                findMultiwordsAmong(sourceNode.getDescendants(), synSource);
                findMultiwordsAmong(sourceNode.getAncestors(), synSource);
            }
        }
        return context;
    }
100053
def _get_context(center_idx, sentence_boundaries, window_size,
                 random_window_size, seed):
    
    random.seed(seed + center_idx)

    sentence_index = np.searchsorted(sentence_boundaries, center_idx)
    sentence_start, sentence_end = _get_sentence_start_end(
        sentence_boundaries, sentence_index)

    if random_window_size:
        window_size = random.randint(1, window_size)
    start_idx = max(sentence_start, center_idx - window_size)
    end_idx = min(sentence_end, center_idx + window_size + 1)

    if start_idx != center_idx and center_idx + 1 != end_idx:
        context = np.concatenate((np.arange(start_idx, center_idx),
                                  np.arange(center_idx + 1, end_idx)))
    elif start_idx != center_idx:
        context = np.arange(start_idx, center_idx)
    elif center_idx + 1 != end_idx:
        context = np.arange(center_idx + 1, end_idx)
    else:
        context = None

    return context
336439
function getLeft(node) {
    let left = node.left;

    while (isConcatenation(left)) {
        left = left.right;
    }
    return left;
}
6140
def wrap(self, word, width, hyphen='-'):
        
        width -= len(hyphen)
        for w1, w2 in self.iterate(word):
            if len(w1) <= width:
                return w1 + hyphen, w2
1117941
def adjustTextMargins( self ):
        
        left_buttons = self._buttons.get(Qt.AlignLeft, [])
        
        if left_buttons:
            bwidth = left_buttons[-1].pos().x() + left_buttons[-1].width() - 4
        else:
            bwidth = 0 + (max(8, self.cornerRadius()) - 8)
        
        ico = self.icon()
        if ico and not ico.isNull():
            bwidth += self.iconSize().width()
        
        self.setTextMargins(bwidth, 0, 0, 0)
1049651
function getPaddings(styles) {
    const positions = ['top', 'right', 'bottom', 'left'];
    const paddings = {};

    for (const position of positions) {
        const value = styles['padding-' + position];

        paddings[position] = toFloat(value);
    }

    return paddings;
}
175069
function( element ) {
		element = element || this.element;

		var offset = element.offset(),
			width = element.width(),
			height = element.height();

		return {
			x1: offset.left,
			y1: offset.top,
			x2: offset.left + width,
			y2: offset.top + height,
			surface: width * height,
			contentItem: this
		};
	}
228992
def _item_in_context(lines, item, context):
    
    start_offset = _line_and_col_to_offset(lines, item.start_pos[0],
                                           item.start_pos[1])
    stop_offset = _line_and_col_to_offset(lines, item.end_pos[0],
                                          item.end_pos[1])
    width = stop_offset - start_offset

    return start_offset >= context.offset and width <= len(context.topic)
1238085
function getSideMargins (style) {
  const margins = compact(style.split(';')).map((decl) => {
    const split = decl.split(':')

    return {
      prop: first(split).trim().toLowerCase(),
      value: last(split).trim().toLowerCase()
    }
  }).filter(({ prop, value }) => prop.indexOf('margin') === 0)

  let left = 0
  let right = 0
  margins.forEach(({ prop, value }) => {
    if (prop === 'margin-left') {
      left = value
      return
    }

    if (prop === 'margin-right') {
      right = value
      return
    }

    if (prop === 'margin') {
      const values = value.split(' ').map((i) => i.trim())

      switch (values.length) {
        case 1:
          right = first(values)
          left = first(values)
          break

        case 2:
          right = last(values)
          left = last(values)
          break

        case 3:
          right = nth(values, 1)
          left = nth(values, 1)
          break

        default:
          right = nth(values, 1)
          left = nth(values, 3)
          break
      }
    }
  })

  return { left, right }
}
587395
function _arrayizeContext(context) {
  function checkAndAdd(type) {
    if (context[type]) {
      context[type] = _arrayify(context[type])
    }
  }
  checkAndAdd('all')
  checkAndAdd('any')
  checkAndAdd('none')
  return context
}
765836
def get_current_word(self, completion=False):
        """"""
        ret = self.get_current_word_and_position(completion)
        if ret is not None:
            return ret[0]
1162442
function(word)
		{
			var c = word[0];
			for (var i = 0; i < 3; i++)
				word[i] = word[i+1];
			word[3] = c;
			
			return word;
		}
327442
function path() {
  var p = _.random(1);
  var words = choose(above);

  words += fragment(s[p], (choose(trans)+s[(p+1)%2]));

  words += ['', 'the', choose(below)].join(' ') + choose(s) + ".";
  return words;
}
18791
def text_justification(words, max_width):
    '''
    
    '''
    ret = []  # return value
    row_len = 0  # current length of strs in a row
    row_words = []  # current words in a row
    index = 0  # the index of current word in words
    is_first_word = True  # is current word the first in a row
    while index < len(words):
        while row_len <= max_width and index < len(words):
            if len(words[index]) > max_width:
                raise ValueError("there exists word whose length is larger than max_width")
            tmp = row_len
            row_words.append(words[index])
            tmp += len(words[index])
            if not is_first_word:
                tmp += 1  # except for the first word, each word should have at least a ' ' before it.
            if tmp > max_width:
                row_words.pop()
                break
            row_len = tmp
            index += 1
            is_first_word = False
        # here we have already got a row of str , then we should supplement enough ' ' to make sure the length is max_width.
        row = ""
        # if the row is the last
        if index == len(words):
            for word in row_words:
                row += (word + ' ')
            row = row[:-1]
            row += ' ' * (max_width - len(row))
        # not the last row and more than one word
        elif len(row_words) != 1:
            space_num = max_width - row_len
            space_num_of_each_interval = space_num // (len(row_words) - 1)
            space_num_rest = space_num - space_num_of_each_interval * (len(row_words) - 1)
            for j in range(len(row_words)):
                row += row_words[j]
                if j != len(row_words) - 1:
                    row += ' ' * (1 + space_num_of_each_interval)
                if space_num_rest > 0:
                    row += ' '
                    space_num_rest -= 1
        # row with only one word
        else:
            row += row_words[0]
            row += ' ' * (max_width - len(row))
        ret.append(row)
        # after a row , reset those value
        row_len = 0
        row_words = []
        is_first_word = True
    return ret
861934
public HString leftContext(@NonNull AnnotationType type, int windowSize) {
      windowSize = Math.abs(windowSize);
      Preconditions.checkArgument(windowSize >= 0);
      int sentenceStart = sentence().start();
      if (windowSize == 0 || start() <= sentenceStart) {
         return Fragments.detachedEmptyHString();
      }
      HString context = firstToken().previous(type);
      for (int i = 1; i < windowSize; i++) {
         HString next = context
                           .firstToken()
                           .previous(type);
         if (next.end() <= sentenceStart) {
            break;
         }
         context = context.union(next);
      }
      return context;
   }
1205566
def inside(self, other):
        
        return ( self.left >= other.left and
                 self.right <= other.right and
                 self.top <= other.top and
                 self.bottom >= other.bottom)