package com.tzld.piaoquan.ad.engine.commons.util;


import com.tzld.piaoquan.recommend.feature.model.sample.BaseFeature;
import com.tzld.piaoquan.recommend.feature.model.sample.GroupedFeature;
import com.tzld.piaoquan.recommend.feature.model.sample.LRSamples;

import java.util.ArrayList;

public class FeatureUtils {


    public static String parseSamplesToString2(LRSamples lrSamples) {
        ArrayList<String> featureList = new ArrayList<String>();
        for (int i = 0; i < lrSamples.getFeaturesCount(); i++) {
            GroupedFeature groupedFeature = lrSamples.getFeatures(i);
            if (groupedFeature != null && groupedFeature.getFeaturesCount() != 0) {
                for (int j = 0; j < groupedFeature.getFeaturesCount(); j++) {
                    BaseFeature baseFeature = groupedFeature.getFeatures(j);
                    if (baseFeature != null) {
                        featureList.add(baseFeature.getIdentifier() + ":1");
                    }
                }
            }
        }
        return String.join("\t", featureList);
    }

}
