Phone word to number one


This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters

Show hidden characters

<?php
/**
* Convert a phone number containing words, to a plain number. e.g. ‘1800 CALLME’ == ‘1800225563’
*/
function ephemeris_phone_word_to_number( $phone_number ) {
$phone_word_pattern = array(
‘a’ => ‘2’,
‘b’ => ‘2’,
‘c’ => ‘2’,
‘d’ => ‘3’,
‘e’ => ‘3’,
‘f’ => ‘3’,
‘g’ => ‘4’,
‘h’ => ‘4’,
‘i’ => ‘4’,
‘j’ => ‘5’,
‘k’ => ‘5’,
‘l’ => ‘5’,
‘m’ => ‘6’,
‘n’ => ‘6’,
‘o’ => ‘6’,
‘p’ => ‘7’,
‘q’ => ‘7’,
‘r’ => ‘7’,
‘s’ => ‘7’,
‘t’ => ‘8’,
‘u’ => ‘8’,
‘v’ => ‘8’,
‘w’ => ‘9’,
‘x’ => ‘9’,
‘y’ => ‘9’,
‘z’ => ‘9’,
‘ ‘ => »,
‘-‘ => »,
‘(‘ => »,
‘)’ => »,
‘[‘ => »,
‘]’ => »,
);
if( !empty( $phone_number ) ) {
return str_ireplace( array_keys( $phone_word_pattern ), array_values( $phone_word_pattern ), $phone_number );
}
return false;
}

код 2 и 3:

ones = {
    0: '', 1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six',
    7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve',
    13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen',
    17: 'seventeen', 18: 'eighteen', 19: 'nineteen'}
tens = {
    2: 'twenty', 3: 'thirty', 4: 'forty', 5: 'fifty', 6: 'sixty',
    7: 'seventy', 8: 'eighty', 9: 'ninety'}
illions = {
    1: 'thousand', 2: 'million', 3: 'billion', 4: 'trillion', 5: 'quadrillion',
    6: 'quintillion', 7: 'sextillion', 8: 'septillion', 9: 'octillion',
    10: 'nonillion', 11: 'decillion'}



def say_number(i):
    """
    Convert an integer in to it word representation.

    say_number(i: integer) -> string
    """
    if i < 0:
        return _join('negative', _say_number_pos(-i))
    if i == 0:
        return 'zero'
    return _say_number_pos(i)


def _say_number_pos(i):
    if i < 20:
        return ones[i]
    if i < 100:
        return _join(tens[i // 10], ones[i % 10])
    if i < 1000:
        return _divide(i, 100, 'hundred')
    for illions_number, illions_name in illions.items():
        if i < 1000**(illions_number + 1):
            break
    return _divide(i, 1000**illions_number, illions_name)


def _divide(dividend, divisor, magnitude):
    return _join(
        _say_number_pos(dividend // divisor),
        magnitude,
        _say_number_pos(dividend % divisor),
    )


def _join(*args):
    return ' '.join(filter(bool, args))

тестовое задание:

def test_say_number(data, expected_output):
    """Test cases for say_number(i)."""
    output = say_number(data)
    assert output == expected_output, 
        "n    for:      {}n    expected: {}n    got:      {}".format(
            data, expected_output, output)


test_say_number(0, 'zero')
test_say_number(1, 'one')
test_say_number(-1, 'negative one')
test_say_number(10, 'ten')
test_say_number(11, 'eleven')
test_say_number(99, 'ninety nine')
test_say_number(100, 'one hundred')
test_say_number(111, 'one hundred eleven')
test_say_number(999, 'nine hundred ninety nine')
test_say_number(1119, 'one thousand one hundred nineteen')
test_say_number(999999,
                'nine hundred ninety nine thousand nine hundred ninety nine')
test_say_number(9876543210,
                'nine billion eight hundred seventy six million '
                'five hundred forty three thousand two hundred ten')
test_say_number(1000**1, 'one thousand')
test_say_number(1000**2, 'one million')
test_say_number(1000**3, 'one billion')
test_say_number(1000**4, 'one trillion')
test_say_number(1000**5, 'one quadrillion')
test_say_number(1000**6, 'one quintillion')
test_say_number(1000**7, 'one sextillion')
test_say_number(1000**8, 'one septillion')
test_say_number(1000**9, 'one octillion')
test_say_number(1000**10, 'one nonillion')
test_say_number(1000**11, 'one decillion')
test_say_number(1000**12, 'one thousand decillion')
test_say_number(
    1-1000**12,
    'negative nine hundred ninety nine decillion nine hundred ninety nine '
    'nonillion nine hundred ninety nine octillion nine hundred ninety nine '
    'septillion nine hundred ninety nine sextillion nine hundred ninety nine '
    'quintillion nine hundred ninety nine quadrillion nine hundred ninety '
    'nine trillion nine hundred ninety nine billion nine hundred ninety nine'
    ' million nine hundred ninety nine thousand nine hundred ninety nine')

Very much a MySQL noob, so please forgive me if I’m asking an obvious question.

My problem is that I have to convert telephone numbers from a text field to an integer. The text field has always been free text, so users have been able to enter what they want. I’ve handled 90% of the rows (spaces, non-alpha etc.) but I’m stuck on translating the 0800 ‘words’ — ie 0800PHONEME needs to be converted to 08007466363. I need to translate up to 10 letters after the 0800 number.

If possible, I’d like to do this at the DB level

Any ideas/suggestions please?

Thanks

asked Feb 19, 2013 at 22:31

LPlates's user avatar

1

I wish i have the chance/time to complete the example, but you should get the idea:

http://sqlfiddle.com/#!2/73482/1

Just keep chaining the replace function for all the numbers.

answered Feb 19, 2013 at 23:00

Ricardo Ortega Magaña's user avatar

1

I think your best bet would be to use a UDF (user defined function) such as REGEXP_REPLACE to find and replace the alphas.

answered Feb 19, 2013 at 23:06

Kermit's user avatar

KermitKermit

33.6k13 gold badges84 silver badges120 bronze badges

number 2:

UPDATE `t_contact` SET `c_phonenumber` = REPLACE(UPPER(`c_phonenumber`),'A','2');
UPDATE `t_contact` SET `c_phonenumber` = REPLACE(UPPER(`c_phonenumber`),'B','2');
UPDATE `t_contact` SET `c_phonenumber` = REPLACE(UPPER(`c_phonenumber`),'C','2');

number 3:

UPDATE `t_contact` SET `c_phonenumber` = REPLACE(UPPER(`c_phonenumber`),'D','3');
UPDATE `t_contact` SET `c_phonenumber` = REPLACE(UPPER(`c_phonenumber`),'E','3');
UPDATE `t_contact` SET `c_phonenumber` = REPLACE(UPPER(`c_phonenumber`),'F','3');

and so on…

answered Feb 19, 2013 at 23:17

samuel's user avatar

samuelsamuel

3262 silver badges9 bronze badges

2

Services section navigation

  • .htpasswd and .htaccess generator
  • 3D product box generator
  • Augmented reality pattern marker generator
  • Audio, video, image or data file ID3 file information
  • Bank identification number checker
  • Base64 encoder and decoder
  • Battery charge time calculator
  • BBAN to IBAN converter
  • BIC / SWIFT code finder for SEPA countries
  • Big number bitwise calculation
  • Big number converter
  • Big number equation calculation
  • Blockchain and cryptocurrency tools
  • Business card maker
  • Calendar
  • Character dataset test
  • Check Dutch bank account number or citizen service number with Eleven test
  • Chinese handwriting recognition
  • Compound interest calculator with graph
  • Convert Dutch bank account numbers to IBAN numbers
  • Convert domain name to IP address, find IP address of a domain name
  • Convert IP adddress to different formats
  • Convert ISO Latin 1, UTF-8, UTF-16, UTF-16LE or Base64 text to hex and vice versa
  • Convert Unicode characters to HTML code numbers and vice versa
  • Convert Unicode characters to Unicode escape sequences and vice versa
  • Coordinate converter and show map
  • Create self-signed SSL certificates online
  • Cryptographic Pseudorandom Number Generator
  • CSV to XML converter
  • CVS pserver password decoder and encoder
  • Decode Certificate Signing Request (CSR)
  • Decode SSL certificate
  • Electronic business card vCard generator
  • European clothing standard EN 13402 pictogram generator
  • Favicon generator
  • File checksum calculator
  • Find the BIC numbers for Dutch IBAN numbers
  • Free game sound effects
  • Free game textures
  • Free online practice exams
  • Free online SEPA XML valdation
  • Generate Dutch bank account numbers and Dutch citizen service numbers
  • Google toolbar custom button code generator
  • Google maps (API v2) code generator
  • Google map distance calculator
  • Hide email address
  • HTML escape and unescape tool
  • Hieroglyphs generator
  • IBAN checker
  • Icon generator
  • International bra size calculator
  • Javascript and HTML
    code executor
  • JSON formatter and validator
  • Javascript formatter
  • Learning Mandarin Chinese
  • Long division generator
  • Lorem ipsum generator
  • MAC address lookup or manufacturer lookup
  • Markdown to HTML converter
  • MD5, SHA1, SHA224, SHA256, SHA384, SHA512 and RIPEMD160 hash generator
  • Mugshot maker
  • Nominal interest rate and effective interest rate converter
  • One-time pad encoder/decoder and key generator
  • Online calculation of the interest payment as banks do.
  • Online credit card number checker
  • Online credit card number generator
  • Online CSV to ClieOp file generator
  • Online cursor maker
  • Online eval gzinflate base64_decode decoder
  • Online GUID generator
  • Online hex editor
  • Online HTML image map creator
  • Online image or photo editor
  • Online image to SVG converter
  • Online Ishihara test for color blindness
  • Online Java class decompiler
  • Online MIDI maker
  • Online morse code generator
  • Online multiple badges maker
  • Online multiple QR codes generator
  • Online ping
  • Online RSA key generation
  • Online SEPA XML message generator for business payments orders and direct debits orders
  • Online signature maker
  • Online steganography service, hide message or file inside an image
  • Online Web FTP
  • Phone number to words
  • Post and search IT jobs for free
  • Pretty print or minify text in XML, JSON, CSS and SQL formats
  • Previous poll results
  • Prime numbers generator and checker
  • Private key match the certificate
  • QR code generator
  • Random IBAN generator
  • Random test data generator
  • Readability tester
  • Record XY mouse coordinates on an uploaded image
  • RF creditor reference generator, validator and reference converter
  • Roman numeral to Arabic numeral converter and vice versa
  • Rot13 (rot-n) encoder decoder
  • Savings annuity calculator with graph
  • Show all the fonts installed on your Windows system
  • Show text in different fonts on HTML canvas
  • Show my IP address
  • Simple interest calculator
  • Simple online PHP obfuscator
  • Submit a website free
  • Take passport photos with your webcam online
  • Take photos with your webcam online
  • Text space manipulator
  • Text to speech
  • Unicode character map
  • Unit converter
  • Unix timestamp converter
  • Upload image and add shooting target
  • Wanted poster generator
  • Web proxy
  • Whois
  • World clock and time zones
  • XML sitemap generator / CSV to XML sitemap converter
  • XML validator against XSD schema
  • Show more ▼
Select language:    English      Dutch
 

This service converts a phone number into easy to remember words.

Many telephone keypads have letters with the numbers, from which words, names, acronyms, abbreviations or alphanumeric combinations can be formed.
These words are known as phonewords. Phonewords are easier to remember than a meaningless sequence of numbers.

For example:
212-272-5263 becomes a-1-barb-lane

Businesses use phonewords in advertisements on television, billboard or radio.

There are different telephone keypads, each with a different number-letters mapping.
But most phones built today place letters on the phone keypad according to the ITU E.161 standard:

ITU E.161 standaard phone keypad

This service does not only convert a phone number to words, but it converts words into a phone number and convert a phone number to all letters combinations.
Due to the large amount of data the letter combinations is limited to maximum 60000.

How this service works:

  1. Select an action to be applied:
    • Convert phone number to words
    • Convert words to phone number
    • Convert phone number to all letter combinations
  2. Enter a phone number.
    The phone number may contain 3 to 10 letters and numbers separated by spaces, dashes «-» or
    round brackets «(  )».
  3. If «Convert phone number to words» is selected choose an English or Dutch word list to verify the phonewords.
    If «Convert phone number to all letter combinations» is selected, you can apply an number of filter options.
  4. Press the Convert button. The action may take a while. Please be patient.

Input generate phone number to words:

Output generate phone number to words:

babyagi

babyagi

The original commit of Baby AGI at 105 lines of code + comments.

See evolved BabyAGI on Github here: https://github.com/yoheinakajima/babyagi

HOW TO USE 👇
Fork this into a private Repl
Add your OpenAI API Key and Pinecone API Key
Go to «Shell» (over to the right ->) and type «pip install pinecone-client» and press enter
Update the OBJECTIVE variable
Press «Run» at the top.
NOTE: the first time you run, it will initiate the table first — which may take a few minutes, you’ll be waiting at the initial OBJECTIVE phase. If it fails, try again.)

WARNING: THIS CODE WILL KEEP RUNNING UNTIL YOU STOP IT. BE MINDFUL OF OPENAI API BILLS. DELETE PINECONE INDEX AFTER USE.

Made with love by @yoheinakajima

AutoGPT: An Autonomous GPT-4 Experiment

AutoGPT: An Autonomous GPT-4 Experiment

An experimental open-source attempt to make GPT-4 fully autonomous. Watch the live demo: https://twitter.com/chillzaza_/status/1645923169654505473?s=20

Fork this Repl to get started! Make sure to set the environment variable OPENAIAPIKEY as a Secret.

GPT-4 is strongly recommended for optimal performance.

A big thank you to Significant Gravitas for their incredible work on AutoGPT!

AI-NFT-Generator-Repl

AI-NFT-Generator-Repl

UI interface to generate NFTs using Dall-E API then mint and deploy to the blockchain built by Ethan Hasbrouk.

Click «Use template» and signup for an Alchemy account here to get your API key: https://dashboard.alchemy.com/signup/?a=ai-nft-generator-replit-template https://dashboard.alchemy.com/signup/?a=ai-nft-generator-replit-template

(You will need to input your own Open AI and Pinata API keys for the replit to run).

Понравилась статья? Поделить с друзьями:
  • Phone number word match
  • Pdf to word online как текст
  • Pdf to word online skachat
  • Pdf to word online api
  • Pdf to word office 2013