Пример #1
0
        /// <summary>
        /// Parses <paramref name="address"/> into its component parts and returns <see cref="Address"/>.
        /// </summary>
        /// <param name="address">address <see cref="string"/> to parse</param>
        /// <returns>parsed and formatted <see cref="Address"/></returns>
        public Address Parse(string address)
        {
            string[] words = Preprocessing.GetFormattedWords(
                address?.Trim() ?? "",
                new char[1] {
                '-'
            });
            int[]   tags          = Tagger.TagInput(words);
            int[]   labels        = HMM.Decide(tags);
            Address parsedAddress = AssignToAddressFromLabels(labels, words);

            return(Formatter.Format(parsedAddress));
        }
Пример #2
0
        /// <summary>
        /// Parses <paramref name="name"/> into its component parts and returns <see cref="Name"/>.
        /// </summary>
        /// <param name="name">name <see cref="string"/> to parse</param>
        /// <returns>parsed and formatted <see cref="Name"/></returns>
        public Name Parse(string name)
        {
            string[] words  = Preprocessing.GetFormattedWords(name?.Trim() ?? "");
            int[]    labels = new int[0];
            if (IndividualChecker.IsIndividual(words))
            {
                int[] tags = Tagger.TagInput(words);
                labels = HMM.Decide(tags);
            }
            else
            {
                // if non-individual, just assign everything to LastName
                labels = words.Select(w => (int)NameLabel.LastName).ToArray();
            }
            Name parsedName = AssignToNameFromLabels(labels, words);

            return(Formatter.Format(parsedName));
        }
Пример #3
0
 private int[] TagSample(SampleType sample, char[] splitChars)
 {
     return(Tagger.TagInput(Preprocessing.GetFormattedWords(sample.Input, splitChars)));
 }