public override string ToString() { var name = Tokenizer?.GetType().Name; name = name?.Substring(0, name.LastIndexOf("Tokenizer", StringComparison.Ordinal)) ?? "ROOT"; return(name); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentCategorizerFactory"/> with the specified tokenizer and the feature generatos. /// </summary> /// <param name="tokenizer">The tokenizer.</param> /// <param name="featureGenerators">The feature generators.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="tokenizer"/> /// or /// <paramref name="featureGenerators"/> /// </exception> /// <exception cref="System.ArgumentException">The specified tokenizer is not registered in the type resolver.</exception> public DocumentCategorizerFactory(ITokenizer tokenizer, IFeatureGenerator[] featureGenerators) { if (tokenizer == null) { throw new ArgumentNullException("tokenizer"); } if (featureGenerators == null) { throw new ArgumentNullException("featureGenerators"); } if (!Library.TypeResolver.IsRegistered(tokenizer.GetType())) { throw new ArgumentException("The specified tokenizer is not registered in the type resolver."); } foreach (var featureGenerator in featureGenerators) { if (featureGenerator == null) { throw new ArgumentException("The feature generators must not have any null objects."); } if (!Library.TypeResolver.IsRegistered(featureGenerator.GetType())) { throw new ArgumentException(string.Format("The feature generator type {0} is not registered in the type resolver.", featureGenerator.GetType().Name)); } } this.featureGenerators = featureGenerators; this.tokenizer = tokenizer; }
public static void MetricRun(IReworder reworder, IReader reader, ITokenizer tok, ISparseDistance dist, int nbNeighbours, bool train, bool proba, string questionFilePath, string encyclopediaFilePath, string outFolder) { string encyclopediaName = Path.GetFileNameWithoutExtension(encyclopediaFilePath); string summary = "Metric_" + reworder.GetType().Name + "_" + reader.GetType().Name + "_" + tok.GetType().Name + "_" + dist.GetType().Name + "_" + nbNeighbours.ToString() + "_" + encyclopediaName; Console.Write("\n" + summary); SparseMatcher robot = new SparseMatcher(dist, reworder, reader, tok, encyclopediaFilePath); string[] answers = robot.Answer(nbNeighbours, questionFilePath, train, proba); if (train) { EvaluateAndPrintScores(questionFilePath, answers); } else { string[] ids = TextToData.ImportColumn(questionFilePath, 0); Submissions.Write(answers, ids, outFolder + summary + ".csv"); } Console.WriteLine(); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentCategorizerFactory"/> with the specified tokenizer and the feature generatos. /// </summary> /// <param name="tokenizer">The tokenizer.</param> /// <param name="featureGenerators">The feature generators.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="tokenizer"/> /// or /// <paramref name="featureGenerators"/> /// </exception> /// <exception cref="System.ArgumentException">The specified tokenizer is not registered in the type resolver.</exception> public DocumentCategorizerFactory(ITokenizer tokenizer, IFeatureGenerator[] featureGenerators) { if (tokenizer == null) throw new ArgumentNullException("tokenizer"); if (featureGenerators == null) throw new ArgumentNullException("featureGenerators"); if (!Library.TypeResolver.IsRegistered(tokenizer.GetType())) throw new ArgumentException("The specified tokenizer is not registered in the type resolver."); foreach (var featureGenerator in featureGenerators) { if (featureGenerator == null) throw new ArgumentException("The feature generators must not have any null objects."); if (!Library.TypeResolver.IsRegistered(featureGenerator.GetType())) throw new ArgumentException(string.Format("The feature generator type {0} is not registered in the type resolver.", featureGenerator.GetType().Name)); } this.featureGenerators = featureGenerators; this.tokenizer = tokenizer; }