Source/NFX/Parsing/NaturalTextGenerator.cs
/// <summary>
/// Generates a string that resembles an address line
/// </summary>
Generates a string that resembles an address line
Generates a string that resembles an address line
public static string GenerateAddressLine()
    {
      var streetNumber = ExternalRandomGenerator.Instance.NextScaledRandomInteger(1, 10000);
      var rnd = ExternalRandomGenerator.Instance.NextRandomInteger;
      string street;
      if (rnd % 3==0) street = GenerateFirstName();
      else
      if (rnd % 2==0) street = GenerateLastName();
      else
       street = GenerateCityName();
      if (rnd > 0)
       street +=  STREET_SUFFIXES[(0x7fFFFFFF & ExternalRandomGenerator.Instance.NextRandomInteger) % STREET_SUFFIXES.Length];
      var rnd2 =  ExternalRandomGenerator.Instance.NextRandomInteger;
      if (rnd2 % 7==0) street += " apt #"+Math.Abs(rnd2 % 18).ToString()+(char)('A'+(rnd2 & 0x8));
      else
      if (rnd2 % 5==0) street += " apt. "+Math.Abs(rnd2 % 18).ToString()+(char)('a'+(rnd2 & 0x8));
      else
      if (rnd2 % 4==0) street += " suite "+Math.Abs(rnd2 % 180).ToString();
      else
      if (rnd2 % 3==0) street += " room "+Math.Abs(rnd2 % 180).ToString();
      return "{0} {1}".Args(streetNumber, street);
    }
public static string GenerateAddressLine ( ) { var streetNumber = ExternalRandomGenerator . Instance . NextScaledRandomInteger ( 1 , 10000 ) ; var rnd = ExternalRandomGenerator . Instance . NextRandomInteger ; string street ; if ( rnd % 3 == 0 ) street = GenerateFirstName ( ) ; else if ( rnd % 2 == 0 ) street = GenerateLastName ( ) ; else street = GenerateCityName ( ) ; if ( rnd > 0 ) street += STREET_SUFFIXES [ ( 0x7fFFFFFF & ExternalRandomGenerator . Instance . NextRandomInteger ) % STREET_SUFFIXES . Length ] ; var rnd2 = ExternalRandomGenerator . Instance . NextRandomInteger ; if ( rnd2 % 7 == 0 ) street += " " + Math . Abs ( rnd2 % 18 ) . ToString ( ) + ( char ) ( ' ' + ( rnd2 & 0x8 ) ) ; else if ( rnd2 % 5 == 0 ) street += " " + Math . Abs ( rnd2 % 18 ) . ToString ( ) + ( char ) ( ' ' + ( rnd2 & 0x8 ) ) ; else if ( rnd2 % 4 == 0 ) street += " " + Math . Abs ( rnd2 % 180 ) . ToString ( ) ; else if ( rnd2 % 3 == 0 ) street += " " + Math . Abs ( rnd2 % 180 ) . ToString ( ) ; return " " . Args ( streetNumber , street ) ; }
Generates a string that resembles an address line
Generates a string that resembles an address line