CharTypes -> Features ->
 -> [Word]
182764
def possible_words str,i,found_in_normal_dic
      ret=[]
      first_char_type=@char_types.type_for str[i].ord
      return [] if found_in_normal_dic && !first_char_type.invoke?

      collect_result ret,first_char_type,str[i..i] if first_char_type.length > 0

      l=1
      str[(i+1)..-1].each_codepoint{|cp|
        break unless first_char_type.accept? cp
        l+=1
        collect_result ret,first_char_type,str[i...(i+l)] if first_char_type.length >= l
      }
      collect_result ret,first_char_type,str[i...(i+l)] if first_char_type.group? && first_char_type.length < l

      ret
    end
1027475
private static int getFeatureTypeIndex(String feature) {
    if (feature.endsWith("|C")) {
      return 0;
    } else if (feature.endsWith("|CpC")) {
      return 1;
    } else if (feature.endsWith("|Cp2C")) {
      return 2;
    } else if (feature.endsWith("|Cp3C")) {
      return 3;
    } else if (feature.endsWith("|Cp4C")) {
      return 4;
    } else if (feature.endsWith("|Cp5C")) {
      return 5;
    } else {
      throw new RuntimeException("Unknown feature type " + feature);
    }
  }
378760
def feature(self,feat=None,searchforit=False,init=None):
		
		if feat==None:
			return self.feats

		if not init:
			init=self
			init.tick=0
			init._matches=[]
			feat=feat.strip()
			if feat.startswith("+"):
				init._eval=True
				feat=feat[1:]
			elif feat.startswith("-"):
				init._eval=False
				feat=feat[1:]
			else:
				init._eval=None

		if (hasattr(self,'feats')) and (feat in self.feats):
			if type(self.feats[feat]) == type([]):
				if len(self.feats[feat]) > 1:
					return self.feats[feat]
				else:
					return self.feats[feat][0]
			else:
				return self.feats[feat]
		else:
			if searchforit:

				for child in self.descendants():
					init.tick+=1
					x=child.feature(feat,searchforit,init)
					#print init.tick, self.classname(), child.classname(), x
					if x==None: continue
					init._matches.append ( (child,x) )


				#return [child.feature(feat,searchforit) for child in self.descendants()]
			else:
				return None
			#if searchforit:
			#	return self.search(SearchTerm(feat))
			#else:
			#	None

		if self==init:

			if init._eval==None:
				return init._matches
			else:
				return [ x for (x,y) in init._matches if bool(y)==init._eval ]
802646
def _maybe_dt_data(data, feature_names, feature_types):
    
    if not isinstance(data, DataTable):
        return data, feature_names, feature_types

    data_types_names = tuple(lt.name for lt in data.ltypes)
    bad_fields = [data.names[i]
                  for i, type_name in enumerate(data_types_names)
                  if type_name not in DT_TYPE_MAPPER]
    if bad_fields:
        msg = """DataFrame.types for data must be int, float or bool.
                Did not expect the data types in fields """
        raise ValueError(msg + ', '.join(bad_fields))

    if feature_names is None:
        feature_names = data.names

        # always return stypes for dt ingestion
        if feature_types is not None:
            raise ValueError('DataTable has own feature types, cannot pass them in')
        feature_types = np.vectorize(DT_TYPE_MAPPER2.get)(data_types_names)

    return data, feature_names, feature_types
704280
def feature_analysis(fname="feature_analysis.png"):
    

    # Create side-by-side axes grid
    _, axes = plt.subplots(ncols=2, figsize=(18,6))

    # Draw RadViz on the left
    data = load_occupancy(split=False)
    oz = RadViz(ax=axes[0], classes=["unoccupied", "occupied"])
    oz.fit(data.X, data.y)
    oz.finalize()

    # Draw Rank2D on the right
    data = load_concrete(split=False)
    oz = Rank2D(ax=axes[1])
    oz.fit_transform(data.X, data.y)
    oz.finalize()

    # Save figure
    path = os.path.join(FIGURES, fname)
    plt.tight_layout()
    plt.savefig(path)
29371
def _get_features(self, i, word, context, prev, prev2):
        '''
        '''
        def add(name, *args):
            features[' '.join((name,) + tuple(args))] += 1

        i += len(self.START)
        features = defaultdict(int)
        # It's useful to have a constant feature, which acts sort of like a prior
        add('bias')
        add('i suffix', word[-3:])
        add('i pref1', word[0])
        add('i-1 tag', prev)
        add('i-2 tag', prev2)
        add('i tag+i-2 tag', prev, prev2)
        add('i word', context[i])
        add('i-1 tag+i word', prev, context[i])
        add('i-1 word', context[i-1])
        add('i-1 suffix', context[i-1][-3:])
        add('i-2 word', context[i-2])
        add('i+1 word', context[i+1])
        add('i+1 suffix', context[i+1][-3:])
        add('i+2 word', context[i+2])
        return features
380110
public boolean isIndexed(FeatureIndexType type) {
		boolean indexed = false;
		if (type == null) {
			indexed = isIndexed();
		} else {
			switch (type) {
			case GEOPACKAGE:
				indexed = featureTableIndex.isIndexed();
				break;
			case RTREE:
				indexed = rTreeIndexTableDao.has();
				break;
			default:
				throw new GeoPackageException("Unsupported FeatureIndexType: "
						+ type);
			}
		}
		return indexed;
	}
109625
def feature_names(self, feature_names):
        
        if not feature_names is None:
            # validate feature name
            if not isinstance(feature_names, list):
                feature_names = list(feature_names)
            if len(feature_names) != len(set(feature_names)):
                raise ValueError('feature_names must be unique')
            if len(feature_names) != self.num_col():
                msg = 'feature_names must have the same length as data'
                raise ValueError(msg)
            # prohibit to use symbols may affect to parse. e.g. ``[]=.``
            if not all(isinstance(f, STRING_TYPES) and f.isalnum()
                       for f in feature_names):
                raise ValueError('all feature_names must be alphanumerics')
        else:
            # reset feature_types also
            self.feature_types = None
        self._feature_names = feature_names
566390
function(features) {
            if (!(features instanceof Array)) {
                features = [features];
            }
            var result = this.toTriangles().map(function(triPoly) {
                    return triPoly.getTetraFeatures(features);
                })
                .reduce(function(pv, v) {
                    return v.map(function(feat, i) {
                        return feat + (pv === 0 ? 0 : pv[i]);
                    });
                }, 0);
            return (result.length == 1) ? result[0] : result;
        }
1354706
protected void printFeatures(IN wi, Collection<String> features) {
    if (flags.printFeatures == null || writtenNum > flags.printFeaturesUpto) {
      return;
    }
    try {
      if (cliqueWriter == null) {
        cliqueWriter = new PrintWriter(new FileOutputStream("feats" + flags.printFeatures + ".txt"), true);
        writtenNum = 0;
      }
    } catch (Exception ioe) {
      throw new RuntimeException(ioe);
    }
    if (writtenNum >= flags.printFeaturesUpto) {
      return;
    }
    if (wi instanceof CoreLabel) {
      cliqueWriter.print(wi.get(TextAnnotation.class) + ' ' + wi.get(PartOfSpeechAnnotation.class) + ' '
          + wi.get(CoreAnnotations.GoldAnswerAnnotation.class) + '\t');
    } else {
      cliqueWriter.print(wi.get(CoreAnnotations.TextAnnotation.class)
          + wi.get(CoreAnnotations.GoldAnswerAnnotation.class) + '\t');
    }
    boolean first = true;
    for (Object feat : features) {
      if (first) {
        first = false;
      } else {
        cliqueWriter.print(" ");
      }
      cliqueWriter.print(feat);
    }
    cliqueWriter.println();
    writtenNum++;
  }
967257
def feature_detector(self, tokens, index, history):
        

        word = tokens[index]
        if index == 0: # At the beginning of the sentence
            prevword = prevprevword = None
            prevtag = prevprevtag = None
            #word = word.lower() # Lowercase at the beginning of sentence
        elif index == 1:
            prevword = tokens[index-1] # Note: no lowercase
            prevprevword = None
            prevtag = history[index-1]
            prevprevtag = None
        else:
            prevword = tokens[index-1]
            prevprevword = tokens[index-2]
            prevtag = history[index-1]
            prevprevtag = history[index-2]

        if re.match('[0-9]+([\.,][0-9]*)?|[0-9]*[\.,][0-9]+$', word):
            # Included "," as decimal point
            shape = 'number'
        elif re.compile('\W+$', re.UNICODE).match(word):
            # Included unicode flag
            shape = 'punct'
        elif re.match('([A-ZÄÖÜ]+[a-zäöüß]*-?)+$', word):
            # Included dash for dashed words and umlauts
            shape = 'upcase'
        elif re.match('[a-zäöüß]+', word):
            # Included umlauts
            shape = 'downcase'
        elif re.compile("\w+", re.UNICODE).match(word):
            # Included unicode flag
            shape = 'mixedcase'
        else:
            shape = 'other'

        features = {
            'prevtag': prevtag,
            'prevprevtag': prevprevtag,
            'word': word,
            'word.lower': word.lower(),
            'suffix3': word.lower()[-3:],
            #'suffix2': word.lower()[-2:],
            #'suffix1': word.lower()[-1:],
            'preffix1': word[:1], # included
            'prevprevword': prevprevword,
            'prevword': prevword,
            'prevtag+word': '%s+%s' % (prevtag, word),
            'prevprevtag+word': '%s+%s' % (prevprevtag, word),
            'prevword+word': '%s+%s' % (prevword, word),
            'shape': shape
            }
        return features
917143
def as_feature(data):
    
    if not isinstance(data, (Feature, FeatureCollection)):
        if is_featurelike(data):
            data = Feature(**data)
        elif has_features(data):
            data = FeatureCollection(**data)
        elif isinstance(data, collections.Sequence):
            data = FeatureCollection(features=data)
        elif has_layer(data):
            data = LayerCollection(data)
        elif has_coordinates(data):
            data = Feature(geometry=data)
        elif isinstance(data, collections.Mapping) and not data:
            data = Feature()
    return data
676023
private String getFeatureString(Set<String> featureNames) {
        StringBuilder featureBuilder = new StringBuilder();

        if (featureNames != null) {
            Iterator<String> iter = featureNames.iterator();
            while (iter.hasNext()) {
                featureBuilder.append(iter.next());
                if (iter.hasNext())
                    featureBuilder.append(',');
            }
        }
        return featureBuilder.toString();
    }
442289
def _draw_feature(self, feature, extent, colour, bg, xo, yo):
        """"""
        geometry = feature["geometry"]
        if geometry["type"] == "Polygon":
            self._draw_polygons(feature, bg, colour, extent, geometry["coordinates"], xo, yo)
        elif feature["geometry"]["type"] == "MultiPolygon":
            for multi_polygon in geometry["coordinates"]:
                self._draw_polygons(feature, bg, colour, extent, multi_polygon, xo, yo)
        elif feature["geometry"]["type"] == "LineString":
            self._draw_lines(bg, colour, extent, geometry["coordinates"], xo, yo)
        elif feature["geometry"]["type"] == "MultiLineString":
            for line in geometry["coordinates"]:
                self._draw_lines(bg, colour, extent, line, xo, yo)
        elif feature["geometry"]["type"] == "Point":
            x, y = self._scale_coords(
                geometry["coordinates"][0], geometry["coordinates"][1], extent, xo, yo)
            text = u" {} ".format(feature["properties"]["name_en"])
            self._screen.print_at(text, int(x - len(text) / 2), int(y), colour=colour, bg=bg)
1064469
def features(sentence, i):
    

    word = sentence[i]

    yield "word:{}" + word.lower()

    if word[0].isupper():
        yield "CAP"

    if i > 0:
        yield "word-1:{}" + sentence[i - 1].lower()
        if i > 1:
            yield "word-2:{}" + sentence[i - 2].lower()
    if i + 1 < len(sentence):
        yield "word+1:{}" + sentence[i + 1].lower()
        if i + 2 < len(sentence):
            yield "word+2:{}" + sentence[i + 2].lower()
670505
def featureCounts_chart (self):
        

        # Config for the plot
        config = {
            'id': 'featureCounts_assignment_plot',
            'title': 'featureCounts: Assignments',
            'ylab': '# Reads',
            'cpswitch_counts_label': 'Number of Reads'
        }

        return bargraph.plot(self.featurecounts_data, self.featurecounts_keys, config)
1102341
def describe(df, dtype=None):
    
    if dtype is None:
        dtype = {}
    print('Number of datapoints: {datapoints}'.format(datapoints=len(df)))
    column_info, column_info_meta = _get_column_info(df, dtype)

    if len(column_info['int']) > 0:
        _describe_int(df, column_info)

    if len(column_info['float']) > 0:
        _describe_float(df, column_info)

    if len(column_info['category']) > 0:
        _describe_category(df, column_info, column_info_meta)

    if len(column_info['time']) > 0:
        _describe_time(df, column_info, column_info_meta)

    if len(column_info['other']) > 0:
        _describe_other(df, column_info, column_info_meta)

    column_types = {}
    for column_type, columns in column_info.items():
        for column_name in columns:
            if column_type == 'other':
                column_type = 'str'
            column_types[column_name] = column_type
    return column_types