/// <summary> /// Constructs a big string representing the input list of CoreLabel, /// with one line per token using the following format /// word label feat1 feat2 ... /// </summary> /// <remarks> /// Constructs a big string representing the input list of CoreLabel, /// with one line per token using the following format /// word label feat1 feat2 ... /// (where each space is actually a tab). /// Assumes that CoreLabel has both TextAnnotation and AnswerAnnotation. /// </remarks> /// <param name="document"> /// List of CoreLabel /// (does not have to represent a "document", just a sequence of text, /// like a sentence or a paragraph) /// </param> /// <returns>String representation of features</returns> private string GetFeatureString(IList <In> document) { int docSize = document.Count; if (classifier.flags.useReverse) { Java.Util.Collections.Reverse(document); } StringBuilder sb = new StringBuilder(); for (int j = 0; j < docSize; j++) { IN token = document[j]; sb.Append(token.Get(typeof(CoreAnnotations.TextAnnotation))); sb.Append(delimiter); sb.Append(token.Get(typeof(CoreAnnotations.AnswerAnnotation))); CRFDatum <IList <string>, CRFLabel> d = classifier.MakeDatum(document, j, classifier.featureFactories); IList <IList <string> > features = d.AsFeatures(); foreach (ICollection <string> cliqueFeatures in features) { IList <string> sortedFeatures = new List <string>(cliqueFeatures); sortedFeatures.Sort(); foreach (string feat in sortedFeatures) { feat = UbPrefixFeatureString(feat); sb.Append(delimiter); sb.Append(feat); } } sb.Append(eol); } if (classifier.flags.useReverse) { Java.Util.Collections.Reverse(document); } return(sb.ToString()); }