根据Example查询总数

@param ms
@return
170103
public String selectAggregationByExample(MappedStatement ms) {
        Class<?> entityClass = getEntityClass(ms);
        StringBuilder sql = new StringBuilder();
        if (isCheckExampleEntityClass()) {
            sql.append(SqlHelper.exampleCheck(entityClass));
        }
        sql.append("SELECT ${@tk.mybatis.mapper.additional.aggregation.AggregationProvider@aggregationSelectClause(");
        sql.append("@").append(entityClass.getCanonicalName()).append("@class");
        sql.append(", '").append(getConfig().getWrapKeyword()).append("'");
        sql.append(", aggregateCondition");
        sql.append(")} ");
        sql.append(SqlHelper.fromTable(entityClass, tableName(entityClass)));
        sql.append(SqlHelper.updateByExampleWhereClause());
        sql.append(" ${@tk.mybatis.mapper.additional.aggregation.AggregationProvider@aggregationGroupBy(");
        sql.append("@").append(entityClass.getCanonicalName()).append("@class");
        sql.append(", '").append(getConfig().getWrapKeyword()).append("'");
        sql.append(", aggregateCondition");
        sql.append(")} ");
        sql.append(SqlHelper.exampleOrderBy("example", entityClass));
        sql.append(SqlHelper.exampleForUpdate());
        return sql.toString();
    }
666945
private Instance[] readInstance(String corpus, FeatureMap featureMap)
    {
        IOUtil.LineIterator lineIterator = new IOUtil.LineIterator(corpus);
        List<Instance> instanceList = new LinkedList<Instance>();
        for (String line : lineIterator)
        {
            String[] cells = line.split(",");
            String text = cells[0], label = cells[1];
            List<Integer> x = extractFeature(text, featureMap);
            int y = featureMap.tagSet.add(label);
            if (y == 0)
                y = -1; // 感知机标签约定为±1
            else if (y > 1)
                throw new IllegalArgumentException("类别数大于2，目前只支持二分类。");
            instanceList.add(new Instance(x, y));
        }
        return instanceList.toArray(new Instance[0]);
    }
910184
public ExampleSet copy()
	{
		ExampleSet copy = new SentenceSetCopy();
		for (int i=0;i<size();i++)
			copy.add(x(i), y(i), id(i));

		return copy;
	}
1079732
public String deleteByIds(MappedStatement ms) {
        final Class<?> entityClass = getEntityClass(ms);
        StringBuilder sql = new StringBuilder();
        sql.append(SqlHelper.deleteFromTable(entityClass, tableName(entityClass)));
        Set<EntityColumn> columnList = EntityHelper.getPKColumns(entityClass);
        if (columnList.size() == 1) {
            EntityColumn column = columnList.iterator().next();
            sql.append(" where ");
            sql.append(column.getColumn());
            sql.append(" in (${_parameter})");
        } else {
            throw new MapperException("继承 deleteByIds 方法的实体类[" + entityClass.getCanonicalName() + "]中必须只有一个带有 @Id 注解的字段");
        }
        return sql.toString();
    }
755168
@Override
    public Object createExample() {
        AnnotationDto result = new AnnotationDto();
        Map<String, String> sampleFields = new HashMap<>();

        fields.put("fieldName", "fieldValue");
        result.setFields(sampleFields);
        result.setId("datasourceSpecificUniqueID");
        result.setMetric("metric");
        result.setScope("scope");
        result.setSource("splunk");

        Map<String, String> sampleTags = new HashMap<>();

        sampleTags.put("tagk", "tagv");
        result.setTags(sampleTags);
        result.setTimestamp(System.currentTimeMillis());
        result.setType("erelease");
        return result;
    }
167562
private static String formatTime(long ms)
    {
        StringTokenizer st = new StringTokenizer(new Date(ms).toString());
        ArrayList<String>	arrayList = new ArrayList<>();
        while (st.hasMoreTokens())
            arrayList.add(st.nextToken());

        String  time  = arrayList.get(3);
        double d = (double)ms/1000;
        long   l = ms/1000;
        d = (d - l) * 1000;
        ms = (long) d;

        return time + "." + ms;
    }
806421
@Override
    public Object createExample() {
        MetricDto result = new MetricDto();
        Map<Long, Double> dps = new TreeMap<>();

        dps.put(System.currentTimeMillis(), 1.2);
        result.setDatapoints(dps);
        result.setDisplayName("A description of the metric");
        result.setMetric("metric");
        result.setScope("scope");

        Map<String, String> sampleTags = new HashMap<>();

        sampleTags.put("tagk", "tagv");
        result.setTags(sampleTags);
        result.setUnits("ms");
        return result;
    }
156328
public static void main(String[] args) throws Exception {
		
		NERTagger tag = new NERTagger("../models/seg.m","../models/pos.m");
		String str = " 新浪体育讯　北京时间4月15日03:00(英国当地时间14日20:00)，2009/10赛季英格兰足球超级联赛第34轮一场焦点战在白鹿巷球场展开角逐，阿森纳客场1比2不敌托特纳姆热刺，丹尼-罗斯和拜尔先入两球，本特纳扳回一城。阿森纳仍落后切尔西6分(净胜球少15个)，夺冠几成泡影。热刺近 7轮联赛取得6胜，继续以1分之差紧逼曼城。";
		HashMap<String, String> map = new HashMap<String, String>();
		tag.tag(str,map);
		System.out.println(map);
		map = tag.tagFile("../example-data/data-tag.txt");
		System.out.println(map);
		System.out.println("Done!");
	}
191704
public String selectOne(MappedStatement ms) {
        Class<?> entityClass = getEntityClass(ms);
        //修改返回值类型为实体类型
        setResultType(ms, entityClass);
        StringBuilder sql = new StringBuilder();
        sql.append(SqlHelper.selectAllColumns(entityClass));
        sql.append(SqlHelper.fromTable(entityClass, tableName(entityClass)));
        sql.append(SqlHelper.whereAllIfColumns(entityClass, isNotEmpty()));
        return sql.toString();
    }
455750
public static String getDesc(final Method m) {
		StringBuilder ret = new StringBuilder(m.getName()).append('(');
		Class<?>[] parameterTypes = m.getParameterTypes();
		for (int i = 0; i < parameterTypes.length; i++)
			ret.append(getDesc(parameterTypes[i]));
		ret.append(')').append(getDesc(m.getReturnType()));
		return ret.toString();
	}
240826
public static <I, O> Example<I, O> create(I input, O output) {
    return new Example<I, O>(input, output);
  }
280305
function msb (x) {
  return (
    x & 0xF0
    ? x & 0xC0 ? x & 0x80 ? 8 : 7 : x & 0x20 ? 6 : 5
    : x & 0x0C ? x & 0x08 ? 4 : 3 : x & 0x02 ? 2 : x
  )
}
1014631
public final void mSOURCE() throws RecognitionException {
        try {
            int _type = SOURCE;
            int _channel = DEFAULT_TOKEN_CHANNEL;
            // C:\\Project\\Obdalib\\obdalib-parent\\obdalib-core\\src\\main\\java\\it\\unibz\\inf\\obda\\gui\\swing\\utils\\MappingFilter.g:120:7: ( ( 'S' | 's' ) ( 'O' | 'o' ) ( 'U' | 'u' ) ( 'R' | 'r' ) ( 'C' | 'c' ) ( 'E' | 'e' ) )
            // C:\\Project\\Obdalib\\obdalib-parent\\obdalib-core\\src\\main\\java\\it\\unibz\\inf\\obda\\gui\\swing\\utils\\MappingFilter.g:120:9: ( 'S' | 's' ) ( 'O' | 'o' ) ( 'U' | 'u' ) ( 'R' | 'r' ) ( 'C' | 'c' ) ( 'E' | 'e' )
            {
            if ( input.LA(1)=='S'||input.LA(1)=='s' ) {
                input.consume();
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                recover(mse);
                throw mse;
            }


            if ( input.LA(1)=='O'||input.LA(1)=='o' ) {
                input.consume();
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                recover(mse);
                throw mse;
            }


            if ( input.LA(1)=='U'||input.LA(1)=='u' ) {
                input.consume();
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                recover(mse);
                throw mse;
            }


            if ( input.LA(1)=='R'||input.LA(1)=='r' ) {
                input.consume();
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                recover(mse);
                throw mse;
            }


            if ( input.LA(1)=='C'||input.LA(1)=='c' ) {
                input.consume();
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                recover(mse);
                throw mse;
            }


            if ( input.LA(1)=='E'||input.LA(1)=='e' ) {
                input.consume();
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                recover(mse);
                throw mse;
            }


            }

            state.type = _type;
            state.channel = _channel;
        }
        finally {
        	// do for sure before leaving
        }
    }
26618
private List<HashMap<String, String>> createSegmentListFromMessage(String msg) {
        List<HashMap<String, String>> segmentList = new ArrayList<HashMap<String, String>>();

        boolean quoteNext = false;
        int startPosi = 0;

        for (int i = 0; i < msg.length(); i++) {
            char ch = msg.charAt(i);

            if (!quoteNext && ch == '@') {
                // skip binary values
                int idx = msg.indexOf("@", i + 1);
                String len_st = msg.substring(i + 1, idx);
                i += Integer.parseInt(len_st) + 1 + len_st.length();
            } else if (!quoteNext && ch == '\'') {
                // segment-ende gefunden
                HashMap<String, String> segmentInfo = new HashMap<>();
                segmentInfo.put("code", msg.substring(startPosi, msg.indexOf(":", startPosi)));
                segmentInfo.put("start", Integer.toString(startPosi));
                segmentInfo.put("length", Integer.toString(i - startPosi + 1));

                segmentList.add(segmentInfo);
                startPosi = i + 1;
            }
            quoteNext = !quoteNext && ch == '?';
        }

        return segmentList;
    }
747057
def get_ms_item(xml, service, parent_id):
    
    cls = MS_TYPE_TO_CLASS.get(xml.findtext(ns_tag('ms', 'itemType')))
    out = cls.from_xml(xml, service, parent_id)
    return out
746962
private AbstractHelperDialect getDialect(MappedStatement ms) {
        //改为对dataSource做缓存
        DataSource dataSource = ms.getConfiguration().getEnvironment().getDataSource();
        String url = getUrl(dataSource);
        if (urlDialectMap.containsKey(url)) {
            return urlDialectMap.get(url);
        }
        try {
            lock.lock();
            if (urlDialectMap.containsKey(url)) {
                return urlDialectMap.get(url);
            }
            if (StringUtil.isEmpty(url)) {
                throw new PageException("无法自动获取jdbcUrl，请在分页插件中配置dialect参数!");
            }
            String dialectStr = fromJdbcUrl(url);
            if (dialectStr == null) {
                throw new PageException("无法自动获取数据库类型，请通过 helperDialect 参数指定!");
            }
            AbstractHelperDialect dialect = initDialect(dialectStr, properties);
            urlDialectMap.put(url, dialect);
            return dialect;
        } finally {
            lock.unlock();
        }
    }
792603
public static void main(String[] args) throws Exception {

		
		String train = "../example-data/sequence/train.txt";
		String testfile = "../example-data/sequence/test.txt";
		String templateFile="../example-data/sequence/template";
		AlphabetFactory factory;
		Pipe featurePipe;
		TempletGroup templets;

		templets = new TempletGroup();
		templets.load(templateFile);
		factory = AlphabetFactory.buildFactory();

		/**
		 * 标签字典。转为0、1、2、...
		 */
		LabelAlphabet labels = factory.DefaultLabelAlphabet();
		/**
		 * 特征字典
		 */
		IFeatureAlphabet features = factory.DefaultFeatureAlphabet();
		// 将样本通过Pipe抽取特征
		
		featurePipe = new Sequence2FeatureSequence(templets, features, labels);

		Pipe pipe = new SeriesPipes(new Pipe[] { new Target2Label(labels), featurePipe });


		System.out.print("读入训练数据 ...");
		InstanceSet trainSet = new InstanceSet(pipe, factory);

		// 训练集
		trainSet.loadThruStagePipes(new SequenceReader(train, true, "utf8"));
		System.out.println("训练样本个数 " + trainSet.size());
		System.out.println("标签个数: " + labels.size()); // 
		System.out.println("特征个数" + features.size()); 

		// 冻结特征集
		features.setStopIncrement(true);
		labels.setStopIncrement(true);


		// viterbi解码
		HammingLoss loss = new HammingLoss();
		Inferencer inference = new LinearViterbi(templets, labels.size());
		Update update = new LinearViterbiPAUpdate((LinearViterbi) inference, loss);


		OnlineTrainer trainer = new OnlineTrainer(inference, update, loss,
				factory, 50,0.1f);

		Linear cl = trainer.train(trainSet);


		// test data没有标注
		Pipe tpipe = featurePipe;
		// 测试集
		InstanceSet testSet = new InstanceSet(tpipe);

		testSet.loadThruPipes(new SequenceReader(testfile, false, "utf8"));
		System.out.println("测试样本个数: " + testSet.size()); // 
		String[][] labelsSet = new String[testSet.size()][];
		for (int i = 0; i < testSet.size(); i++) {
			Instance carrier = testSet.get(i);
			int[] pred = (int[]) cl.classify(carrier).getLabel(0);
			labelsSet[i] = labels.lookupString(pred);
		}
		
		String s = SimpleFormatter.format(testSet, labelsSet);
		System.out.println(s);
		System.out.println("Done");
	}