labeling observation sequences.

@param data list of sequences with specified format which can be read by DataReader
@return a list of sentences with tags annotated
193411
@SuppressWarnings("unchecked")
	public List seqLabeling(String data){
		List<Sentence> obsvSeqs = dataReader.readString(data);
		return labeling(obsvSeqs);
	}
388836
public static String toLog(XmlChannel data) {
        return data.getName() + "(" + data.getOwner() + "):["
                + (data.properties)
                + (data.tags)
                + "]";
    }
928641
public <T> JSONAPIDocument<List<T>> readDocumentCollection(byte[] data, Class<T> clazz) {
		return readDocumentCollection(new ByteArrayInputStream(data), clazz);
	}
1039780
def parse(data):
		
		reader = io.BytesIO(data)
		headers = []
		while reader.tell() < len(data):
			h = Header()
			h.tag = int.from_bytes(reader.read(2), byteorder='big', signed=False)
			h.taglen = int.from_bytes(reader.read(2), byteorder='big', signed=False)
			h.tagdata = reader.read(h.taglen)
			headers.append(h)
		return headers
1326263
@Override
    public MultiDataSet next() {
        counter.incrementAndGet();

        INDArray[] features = new INDArray[baseFeatures.length];
        System.arraycopy(baseFeatures, 0, features, 0, baseFeatures.length);
        INDArray[] labels = new INDArray[baseLabels.length];
        System.arraycopy(baseLabels, 0, labels, 0, baseLabels.length);

        MultiDataSet ds = new MultiDataSet(features, labels);

        return ds;
    }
84904
@Override
   public void tag(Annotation sentence) {
      SequenceInput<Annotation> sequenceInput = new SequenceInput<>(sentence.tokens());
      Labeling result = labeler.label(featurizer.extractSequence(sequenceInput.iterator()));
      for (int i = 0; i < sentence.tokenLength(); ) {
         if (result.getLabel(i).equals("O")) {
            i++;
         } else {
            Annotation start = sentence.tokenAt(i);
            String type = result.getLabel(i).substring(2);
            i++;
            while (i < sentence.tokenLength() && result.getLabel(i).startsWith("I-")) {
               i++;
            }
            Annotation end = sentence.tokenAt(i - 1);
            HString span = start.union(end);
            Annotation entity = sentence.document()
                                        .annotationBuilder()
                                        .type(annotationType)
                                        .bounds(span)
                                        .createAttached();
            entity.put(annotationType.getTagAttribute(),
                       annotationType.getTagAttribute().getValueType().decode(type));
         }
      }
   }
3451
protected List<CRFDatum> extractDatumSequence(int[][][] allData, int beginPosition, int endPosition,
      List<IN> labeledWordInfos) {
    List<CRFDatum> result = new ArrayList<CRFDatum>();
    int beginContext = beginPosition - windowSize + 1;
    if (beginContext < 0) {
      beginContext = 0;
    }
    // for the beginning context, add some dummy datums with no features!
    // TODO: is there any better way to do this?
    for (int position = beginContext; position < beginPosition; position++) {
      List<Collection<String>> cliqueFeatures = new ArrayList<Collection<String>>();
      for (int i = 0; i < windowSize; i++) {
        // create a feature list
        cliqueFeatures.add(Collections.<String>emptyList());
      }
      CRFDatum<Collection<String>, String> datum = new CRFDatum<Collection<String>, String>(cliqueFeatures,
              labeledWordInfos.get(position).get(AnswerAnnotation.class));
      result.add(datum);
    }
    // now add the real datums
    for (int position = beginPosition; position <= endPosition; position++) {
      List<Collection<String>> cliqueFeatures = new ArrayList<Collection<String>>();
      for (int i = 0; i < windowSize; i++) {
        // create a feature list
        Collection<String> features = new ArrayList<String>();
        for (int j = 0; j < allData[position][i].length; j++) {
          features.add(featureIndex.get(allData[position][i][j]));
        }
        cliqueFeatures.add(features);
      }
      CRFDatum<Collection<String>,String> datum = new CRFDatum<Collection<String>,String>(cliqueFeatures,
              labeledWordInfos.get(position).get(AnswerAnnotation.class));
      result.add(datum);
    }
    return result;
  }
1214862
public static BasicTagList of(String... tags) {
    Preconditions.checkArgument(tags.length % 2 == 0,
        "tags must be a sequence of key,value pairs");

    final SmallTagMap.Builder builder = SmallTagMap.builder();
    for (int i = 0; i < tags.length; i += 2) {
      Tag t = Tags.newTag(tags[i], tags[i + 1]);
      builder.add(t);
    }
    return new BasicTagList(builder.result());
  }
450376
public void doInference(List data) {
	if (lambda == null) {
	    lambda = new double[feaGen.numFeatures()];
	    
	    // reading feature weights from the feature list
	    for (int i = 0; i < feaGen.features.size(); i++) {
		Feature f = (Feature)feaGen.features.get(i);
		lambda[f.idx] = f.wgt;    
	    }	    
	}
	
	inference.doInference(data);	
    }
106338
private Map<String, String> readAsMap(String data) {
        Map<String, String> params = new HashMap<>();

        Arrays.stream(data.split("&")).forEach(arg -> {
            if (StringUtils.isEmpty(arg)) {
                return;
            }
            String[] args = arg.split("=");
            if (args.length == 1) {
                params.put(args[0], null);
            } else {
                params.put(args[0], args[1]);
            }
        });
        return params;
    }
414754
public List<Card> parseData(@Nullable T data) {
        List<Card> cardList = mDataParser.parseGroup(data, this);
        MVHelper mvHelper = (MVHelper) mServices.get(MVHelper.class);
        if (mvHelper != null) {
            mvHelper.renderManager().onDownloadTemplate();
        }
        return cardList;
    }
842784
def _handle_tag_data(self, data, text):
        """"""
        for chunk in self.tag_splitter.split(text):
            if not chunk:
                continue
            if data.context & data.CX_NAME:
                if chunk in self.MARKERS or chunk.isspace():
                    self._fail_route()  # Tags must start with text, not spaces
                data.context = data.CX_NOTE_SPACE
            elif chunk.isspace():
                self._handle_tag_space(data, chunk)
                continue
            elif data.context & data.CX_NOTE_SPACE:
                if data.context & data.CX_QUOTED:
                    data.context = data.CX_ATTR_VALUE
                    self._memoize_bad_route()
                    self._pop()
                    self._head = data.reset - 1  # Will be auto-incremented
                    return  # Break early
                self._fail_route()
            elif data.context & data.CX_ATTR_READY:
                data.context = data.CX_ATTR_NAME
                self._push(contexts.TAG_ATTR)
            elif data.context & data.CX_ATTR_NAME:
                if chunk == "=":
                    data.context = data.CX_ATTR_VALUE | data.CX_NOTE_QUOTE
                    self._emit(tokens.TagAttrEquals())
                    continue
                if data.context & data.CX_NOTE_EQUALS:
                    self._push_tag_buffer(data)
                    data.context = data.CX_ATTR_NAME
                    self._push(contexts.TAG_ATTR)
            else:  # data.context & data.CX_ATTR_VALUE assured
                escaped = self._read(-1) == "\\" and self._read(-2) != "\\"
                if data.context & data.CX_NOTE_QUOTE:
                    data.context ^= data.CX_NOTE_QUOTE
                    if chunk in "'\"" and not escaped:
                        data.context |= data.CX_QUOTED
                        data.quoter = chunk
                        data.reset = self._head
                        try:
                            self._push(self._context)
                        except BadRoute:
                            # Already failed to parse this as a quoted string
                            data.context = data.CX_ATTR_VALUE
                            self._head -= 1
                            return
                        continue
                elif data.context & data.CX_QUOTED:
                    if chunk == data.quoter and not escaped:
                        data.context |= data.CX_NOTE_SPACE
                        continue
            self._handle_tag_text(chunk)
892684
@Override
	public void parse(final byte[] pData, final Collection<TagAndLength> pTags) {
		Collection<AnnotationData> set = getAnnotationSet(pTags);
		BitUtils bit = new BitUtils(pData);
		Iterator<AnnotationData> it = set.iterator();
		while (it.hasNext()) {
			AnnotationData data = it.next();
			if (data.isSkip()) {
				bit.addCurrentBitIndex(data.getSize());
			} else {
				Object obj = DataFactory.getObject(data, bit);
				setField(data.getField(), this, obj);
			}
		}
	}
87955
public List<Sentence> readString(String dataStr){
		String [] lines = dataStr.split("\n");
		List<Sentence> data = new ArrayList<Sentence>();
		for (String line : lines){
			Sentence sentence = new Sentence();
			
			if (line.startsWith("#"))
				continue;
			
			StringTokenizer tk = new StringTokenizer(line, " ");	
			while (tk.hasMoreTokens()){
				String word = "", tag = null;
				if (!isTrainReading){
					String token = tk.nextToken();
					word = token;
					sentence.addTWord(word, tag);
				}
				else {
					String token = tk.nextToken();
					StringTokenizer sltk = new StringTokenizer(token, "/");
					word = sltk.nextToken();
					tag = sltk.nextToken();
					sentence.addTWord(word, tag);
				}
			}	
			data.add(sentence);
		}
		
		return data;
	}
1343947
public static String getFormattedTagAndLength(final byte[] data, final int indentLength) {
		StringBuilder buf = new StringBuilder();
		String indent = getSpaces(indentLength);
		TLVInputStream stream = new TLVInputStream(new ByteArrayInputStream(data));

		boolean firstLine = true;
		try {
			while (stream.available() > 0) {
				if (firstLine) {
					firstLine = false;
				} else {
					buf.append("\n");
				}
				buf.append(indent);

				ITag tag = searchTagById(stream.readTag());
				int length = stream.readLength();

				buf.append(prettyPrintHex(tag.getTagBytes()));
				buf.append(" ");
				buf.append(String.format("%02x", length));
				buf.append(" -- ");
				buf.append(tag.getName());
			}
		} catch (IOException e) {
			LOGGER.error(e.getMessage(), e);
		} finally {
			IOUtils.closeQuietly(stream);
		}
		return buf.toString();
	}
964375
@Benchmark
  @BenchmarkMode(Mode.AverageTime)
  @OutputTimeUnit(TimeUnit.NANOSECONDS)
  public Span addAnnotationWithAnnotation(Data data) {
    Span span = data.annotationSpanAnnotation;
    Annotation annotation =
        Annotation.fromDescriptionAndAttributes(ANNOTATION_DESCRIPTION, data.attributeMap);
    span.addAnnotation(annotation);
    return span;
  }
875583
def parse(self, data):
        

        categories = data.split("\n\n")
        reference = {}
        reference_points = {}
        genre_index = []
        tag_index = []

        for category in categories:
            entries = category.strip().split("\n")
            entry_category, entry_points = self._parse_entry(entries[0].lower())

            if entry_category.startswith("#"):
                continue

            for entry in entries:
                entry = entry.lower()
                if not entry:
                    continue

                # Comment, ignore
                if entry.startswith("#"):
                    continue

                # Handle genre
                if not entry.startswith("-"):
                    genre, points = self._parse_entry(entry)

                    reference[genre] = entry_category
                    reference_points[genre] = points
                    genre_index.append(genre)

                # Handle tag
                else:
                    tag = entry[1:]
                    tag, points = self._parse_entry(tag, limit=9.5)

                    reference[tag] = entry_category
                    reference_points[tag] = points
                    tag_index.append(tag)

        self.reference = reference
        self.genres = genre_index
        self.tags = tag_index
        self.points = reference_points