Example #1
0
 /// <summary>
 /// Returns a string representation of this instance.
 /// </summary>
 /// <returns>The string representation of the current object.</returns>
 public override string ToString()
 {
     if (DateFormat == DefaultDateFormat)
     {
         return("date");
     }
     else
     {
         return("date " + ArffWriter.QuoteAndEscape(DateFormat));
     }
 }
Example #2
0
        /// <summary>
        /// Writes an ARFF file with the specified path, relation name, attributes and instances.
        /// </summary>
        /// <param name="path">The path of the file that should be written.</param>
        /// <param name="relationName">The name of the relation that is to be written.</param>
        /// <param name="attributes">The attributes of the data to be written.</param>
        /// <param name="instances">The instance data to write. Length and element types must conform to the attributes.
        /// <para>
        /// The expected element types depend on the type of their corresponding attribute:
        /// <see cref="double"/> (numeric attribute),
        /// <see cref="string"/> (string attribute),
        /// <see cref="int"/> (nominal attribute, index into nominal values array),
        /// <see cref="DateTime"/> (date attribute),
        /// <see cref="object"/>[][] (relational attribute).
        /// Missing values should be represented as <c>null</c>.</para>
        /// </param>
        /// <param name="sparse">True, if the instances should be written in sparse format.</param>
        /// <exception cref="UnauthorizedAccessException"/>
        /// <exception cref="ArgumentNullException"/>
        /// <exception cref="ArgumentException"/>
        /// <exception cref="DirectoryNotFoundException"/>
        /// <exception cref="IOException"/>
        /// <exception cref="PathTooLongException"/>
        /// <exception cref="System.Security.SecurityException"/>
        public static void Write(string path, string relationName, IEnumerable <ArffAttribute> attributes, IEnumerable <object[]> instances, bool sparse)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException(nameof(attributes));
            }

            using (ArffWriter arffWriter = new ArffWriter(path))
            {
                arffWriter.WriteRelationName(relationName);

                foreach (ArffAttribute attribute in attributes)
                {
                    arffWriter.WriteAttribute(attribute);
                }

                arffWriter.WriteAllInstances(instances, sparse);
            }
        }
Example #3
0
 /// <summary>
 /// Returns a string representation of this instance.
 /// </summary>
 /// <returns>The string representation of the current object.</returns>
 public override string ToString()
 {
     return($"@attribute {ArffWriter.QuoteAndEscape(Name)} {Type}");
 }
Example #4
0
 /// <summary>
 /// Returns a string representation of this instance.
 /// </summary>
 /// <returns>The string representation of the current object.</returns>
 public override string ToString()
 {
     return($"@relation {ArffWriter.QuoteAndEscape(RelationName)} ({Attributes.Count} attribute{(Attributes.Count == 1 ? "" : "s")})");
 }