Source/NFX/Parsing/NaturalTextGenerator.cs
/// <summary>
/// Generates a string that resembles a human last name
/// </summary>
Generates a string that resembles a human last name
Generates a string that resembles a human last name
public static string GenerateLastName()
    {
      var rnd = ExternalRandomGenerator.Instance.NextRandomInteger;
      if (rnd>0 && rnd <123000000)
        return POPULAR_LAST_NAMES[(0x7fFFFFFF & rnd) % POPULAR_LAST_NAMES.Length];
      var shrt =  rnd > 1543000000;
      string prefix;
      if (shrt)
        prefix = LAST_NAME_SUFFIXES[(0x7fFFFFFF & ExternalRandomGenerator.Instance.NextRandomInteger) % LAST_NAME_SUFFIXES.Length];
      else
      {
        do
        {
          prefix = GenerateWord(4, 8);
        }
        while(prefix.IndexOf('\'')!=-1);
        prefix = prefix.ToLowerInvariant();
      }
      var suffix = LAST_NAME_SUFFIXES[(0x7fFFFFFF & rnd) % LAST_NAME_SUFFIXES.Length];
      var reverse = !shrt && rnd<-1543000000;
      if (reverse)
      {
        var t = prefix;
        prefix = suffix;
        suffix = t;
      }
      prefix = Char.ToUpperInvariant(prefix[0]) + prefix.Substring(1).ToLowerInvariant();
      return prefix + suffix;
    }
public static string GenerateLastName ( ) { var rnd = ExternalRandomGenerator . Instance . NextRandomInteger ; if ( rnd > 0 && rnd < 123000000 ) return POPULAR_LAST_NAMES [ ( 0x7fFFFFFF & rnd ) % POPULAR_LAST_NAMES . Length ] ; var shrt = rnd > 1543000000 ; string prefix ; if ( shrt ) prefix = LAST_NAME_SUFFIXES [ ( 0x7fFFFFFF & ExternalRandomGenerator . Instance . NextRandomInteger ) % LAST_NAME_SUFFIXES . Length ] ; else { do { prefix = GenerateWord ( 4 , 8 ) ; } while ( prefix . IndexOf ( ' \' ' ) != - 1 ) ; prefix = prefix . ToLowerInvariant ( ) ; } var suffix = LAST_NAME_SUFFIXES [ ( 0x7fFFFFFF & rnd ) % LAST_NAME_SUFFIXES . Length ] ; var reverse = ! shrt && rnd < - 1543000000 ; if ( reverse ) { var t = prefix ; prefix = suffix ; suffix = t ; } prefix = Char . ToUpperInvariant ( prefix [ 0 ] ) + prefix . Substring ( 1 ) . ToLowerInvariant ( ) ; return prefix + suffix ; }
Generates a string that resembles a human last name
Generates a string that resembles a human last name