コード例 #1
0
        private NameAnalysisResult AnalyseCompoundFamilyName(String nameStr)
        {
            String[] parts = nameStr.Split('-');

            if (parts.Length == 1)
            {
                return(this.AnalyseFamilyName(parts[0]));
            }

            CompoundNameResult result = new CompoundNameResult(nameStr);

            foreach (String part in parts)
            {
                result.Parts.Add(this.AnalyseFamilyName(part));
            }

            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Analyses a name.
        /// </summary>
        /// <param name="data">The name to analyse.</param>
        /// <returns></returns>
        public List <NameAnalysisResult> Analyse(String data)
        {
            // trim whitespaces from both ends
            data = data.Trim();

            List <NameAnalysisResult> results = new List <NameAnalysisResult>();
            CompoundNameResult        result  = new CompoundNameResult(data);

            // bit simplistic -- will improve later
            String[] parts = data.Split(' ');

            // for now, we will assume that the first name always comes first
            String firstName = parts[0];

            result.Parts.Add(this.AnalyseGivenName(firstName));

            // if there's another part, we'll assume that it's the surname
            if (parts.Length == 2)
            {
                String surname = parts[1];
                result.Parts.Add(this.AnalyseCompoundFamilyName(surname));
            }
            else if (parts.Length > 2)
            {
                // if there are more than 2 parts, we treat everything in the middle
                // as more given names
                for (Int32 i = 1; i < parts.Length - 1; i++)
                {
                    result.Parts.Add(this.AnalyseGivenName(parts[i]));
                }

                String surname = parts.Last();
                result.Parts.Add(this.AnalyseCompoundFamilyName(surname));
            }

            results.Add(result);
            return(results);
        }
コード例 #3
0
ファイル: NameAnalyser.cs プロジェクト: etilic/Etilic.Name
        private NameAnalysisResult AnalyseCompoundFamilyName(String nameStr)
        {
            String[] parts = nameStr.Split('-');

            if (parts.Length == 1)
                return this.AnalyseFamilyName(parts[0]);

            CompoundNameResult result = new CompoundNameResult(nameStr);

            foreach (String part in parts)
                result.Parts.Add(this.AnalyseFamilyName(part));

            return result;
        }
コード例 #4
0
ファイル: NameAnalyser.cs プロジェクト: etilic/Etilic.Name
        /// <summary>
        /// Analyses a name.
        /// </summary>
        /// <param name="data">The name to analyse.</param>
        /// <returns></returns>
        public List<NameAnalysisResult> Analyse(String data)
        {
            // trim whitespaces from both ends
            data = data.Trim();

            List<NameAnalysisResult> results = new List<NameAnalysisResult>();
            CompoundNameResult result = new CompoundNameResult(data);

            // bit simplistic -- will improve later
            String[] parts = data.Split(' ');

            // for now, we will assume that the first name always comes first
            String firstName = parts[0];
            result.Parts.Add(this.AnalyseGivenName(firstName));

            // if there's another part, we'll assume that it's the surname
            if(parts.Length == 2)
            {
                String surname = parts[1];
                result.Parts.Add(this.AnalyseCompoundFamilyName(surname));
            }
            else if(parts.Length > 2)
            {
                // if there are more than 2 parts, we treat everything in the middle
                // as more given names
                for(Int32 i = 1; i < parts.Length - 1; i++)
                {
                    result.Parts.Add(this.AnalyseGivenName(parts[i]));
                }

                String surname = parts.Last();
                result.Parts.Add(this.AnalyseCompoundFamilyName(surname));
            }

            results.Add(result);
            return results;
        }