Beispiel #1
0
# -*- coding: utf-8 -*-
from natural.constant import NATO_ALPHABET, NATO_ALPHABET_PHONETIC
from natural.constant import SPELL_ALPHABET, CODE_PRONOUNCIATION
from natural.constant import CODE_ALPHABET_ARMY, CODE_ALPHABET_FAA
from natural.constant import CODE_ALPHABET_ICAO, CODE_ALPHABET_MORSE
from natural.constant import CODE_ALPHABET_WORD


NATO_ALPHABET_KEYS = sorted(NATO_ALPHABET.keys())


class Spelling(object):
    def __call__(self, sentence, pad=u' '):
        parts = []
        for letter in sentence.lower():
            letter = self.transform(letter)
            if letter is not None:
                parts.append(letter)
        return pad.join(parts)

    def transform(self, letter):
        return None


class Alphabet(Spelling):
    '''
    Helper class for (spelling) alphabets.
    '''

    def __init__(self, mapping):
        self.mapping = mapping
Beispiel #2
0
# -*- coding: utf-8 -*-
from natural.constant import NATO_ALPHABET, NATO_ALPHABET_PHONETIC
from natural.constant import SPELL_ALPHABET, CODE_PRONOUNCIATION
from natural.constant import CODE_ALPHABET_ARMY, CODE_ALPHABET_FAA
from natural.constant import CODE_ALPHABET_ICAO, CODE_ALPHABET_MORSE
from natural.constant import CODE_ALPHABET_WORD

NATO_ALPHABET_KEYS = NATO_ALPHABET.keys()
NATO_ALPHABET_KEYS.sort()


class Spelling(object):
    def __call__(self, sentence, pad=u' '):
        parts = []
        for letter in sentence.lower():
            letter = self.transform(letter)
            if letter is not None:
                parts.append(letter)
        return pad.join(parts)

    def transform(self, letter):
        return None


class Alphabet(Spelling):
    def __init__(self, mapping):
        self.mapping = mapping

    @staticmethod
    def from_pair(self, keys, values):
        return Alphabet(dict(zip(keys, values)))
Beispiel #3
0
# -*- coding: utf-8 -*-
from natural.constant import NATO_ALPHABET, NATO_ALPHABET_PHONETIC
from natural.constant import SPELL_ALPHABET, CODE_PRONOUNCIATION
from natural.constant import CODE_ALPHABET_ARMY, CODE_ALPHABET_FAA
from natural.constant import CODE_ALPHABET_ICAO, CODE_ALPHABET_MORSE
from natural.constant import CODE_ALPHABET_WORD


NATO_ALPHABET_KEYS = list(NATO_ALPHABET.keys())
NATO_ALPHABET_KEYS.sort()


class Spelling(object):
    def __call__(self, sentence, pad=' '):
        parts = []
        for letter in sentence.lower():
            letter = self.transform(letter)
            if letter is not None:
                parts.append(letter)
        return pad.join(parts)

    def transform(self, letter):
        return None


class Alphabet(Spelling):
    def __init__(self, mapping):
        self.mapping = mapping

    @staticmethod
    def from_pair(self, keys, values):
Beispiel #4
0
# -*- coding: utf-8 -*-
from natural.constant import NATO_ALPHABET, NATO_ALPHABET_PHONETIC
from natural.constant import SPELL_ALPHABET, CODE_PRONOUNCIATION
from natural.constant import CODE_ALPHABET_ARMY, CODE_ALPHABET_FAA
from natural.constant import CODE_ALPHABET_ICAO, CODE_ALPHABET_MORSE
from natural.constant import CODE_ALPHABET_WORD


NATO_ALPHABET_KEYS = NATO_ALPHABET.keys()
NATO_ALPHABET_KEYS.sort()


class Spelling(object):
    def __call__(self, sentence, pad=u' '):
        parts = []
        for letter in sentence.lower():
            letter = self.transform(letter)
            if letter is not None:
                parts.append(letter)
        return pad.join(parts)

    def transform(self, letter):
        return None


class Alphabet(Spelling):
    def __init__(self, mapping):
        self.mapping = mapping

    @staticmethod
    def from_pair(self, keys, values):
Beispiel #5
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, print_function

from natural.constant import NATO_ALPHABET, NATO_ALPHABET_PHONETIC
from natural.constant import SPELL_ALPHABET, CODE_PRONOUNCIATION
from natural.constant import CODE_ALPHABET_ARMY, CODE_ALPHABET_FAA
from natural.constant import CODE_ALPHABET_ICAO, CODE_ALPHABET_MORSE
from natural.constant import CODE_ALPHABET_WORD

NATO_ALPHABET_KEYS = sorted(NATO_ALPHABET.keys())


class Spelling(object):
    def __call__(self, sentence, pad=' '):
        parts = []
        for letter in sentence.lower():
            letter = self.transform(letter)
            if letter is not None:
                parts.append(letter)
        return pad.join(parts)

    def transform(self, letter):
        return None


class Alphabet(Spelling):
    '''
    Helper class for (spelling) alphabets.
    '''
    def __init__(self, mapping):
        self.mapping = mapping