Foros del Web » Programando para Internet » PHP »

Aporte: Accesibilidad - Traductor a braille

Estas en el tema de Aporte: Accesibilidad - Traductor a braille en el foro de PHP en Foros del Web. Bueno hace mucho que no aporto en este foro así que dejo este código que realice hace unos días, el cual implementare en un proyecto ...
  #1 (permalink)  
Antiguo 06/01/2012, 09:42
Colaborador
 
Fecha de Ingreso: octubre-2009
Ubicación: Tokyo - Japan !
Mensajes: 3.867
Antigüedad: 14 años, 6 meses
Puntos: 334
De acuerdo Aporte: Accesibilidad - Traductor a braille

Bueno hace mucho que no aporto en este foro así que dejo este código que realice hace unos días, el cual implementare en un proyecto futuro para la plataforma android !... el código originalmente lo tengo en python pero para dejarlo como herramienta en mi framework lo escribí también en PHP

Código PHP:
<?php
/**
 * Khaus Framework
 *
 * LICENSE
 *
 * This source file is subject to the Public license Creative Commons LPCC
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://creativecommons.org/licenses/by-nc/2.0/cl/
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to [email protected] so we can send you a copy immediately.
 *
 * @category    Khaus
 * @package     Khaus_Accessibility
 * @copyright   Copyright (c) 2010 - 2011, Khaus Corp. Chile [[email protected]]
 * @license     Atribucion-Licenciar Igual 2.0 Chile. CC BY-NC 2.0
 * @version     1:20120106
 */
class Khaus_Accessibility_Braille
{
    private 
$_true 1;
    private 
$_false 0;
    private 
$_bin = array(
        
'a' => 1,   'b' => 5,   'c' => 3,   'd' => 11,
        
'e' => 9,   'f' => 7,   'g' => 15,  'h' => 13,
        
'i' => 6,   'j' => 14,  'k' => 17,  'l' => 21,
        
'm' => 19,  'n' => 27,  'o' => 25,  'p' => 23,
        
'q' => 31,  'r' => 29,  's' => 22,  't' => 30,
        
'u' => 49,  'v' => 53,  'w' => 46,  'x' => 51,
        
'y' => 59,  'z' => 57,  ' ' => 0,
    );
    
    
/**
     * Setea los valores de retorno, por defecto en los espacios
     * marcados del braile retorna 1 y en los no marcados un 0
     *
     * @param mixed $true
     * @param mixed $false 
     */
    
public function setReturnValues($true$false)
    {
        
$this->_true $true;
        
$this->_false $false;
    }
    
    
/**
     * Devuelve un array con cada letra en otro array con seis celdas en donde
     * se especifican los puntos prendidos y apagados del alfabeto braille.
     * 
     * @example
     * $access->braille('khaus');
     * 
     * @param string $string
     * @return array
     * @exception Exception si el string es invalido
     */
    
public function braille($string)
    {
        
$string = (string) strtolower($string);
        if (
preg_match('/^[a-z ]+$/'$string)) {
            
$returnBraille = array();
            for (
$i 0$o strlen($string); $i $o$i++) {
                
$key $string{$i};
                
$word = array();
                for (
$x 1$x <= 32$x $x << 1) {
                    
$word[] = $this->_bin[$key] & $x $this->_true $this->_false;
                }
                
$returnBraille[] = $word;
            }
            return 
$returnBraille;
        } else {
            throw new 
Exception('String invalido');
        }
    }
}
luego haré un update a mi framework que mantengo en Github para agregar esta librería,
quizá no sea de mucha utilidad en proyectos comunes... pero sirve para destacar que PHP da para muchas cosas, es solo cuestión de imaginar :)

dejo también un ejemplo de su uso y una foto del resultado

Código PHP:
<form action="" method="post">
    <input type="text" name="palabra" />
</form>
<?php
$access 
= new Khaus_Accessibility_Braille;
$access->setReturnValues('&circledcirc;''&xcirc;');
$palabra = isset($_POST['palabra']) ? $access->braille($_POST['palabra']) : array();
?>
<?php 
foreach ($palabra as $key => $value) : ?>
    <table style="display:inline-block;padding:3px;">
        <tr>
            <td><?php echo $value[0]; ?></td>
            <td><?php echo $value[1]; ?></td>
        </tr>
        <tr>
            <td><?php echo $value[2]; ?></td>
            <td><?php echo $value[3]; ?></td>
        </tr>
        <tr>
            <td><?php echo $value[4]; ?></td>
            <td><?php echo $value[5]; ?></td>
        </tr>
    </table>
<?php endforeach; ?>
---

---

si quieren consultar cualquier cosa no duden en hacerlo

saludos.
__________________
More about me...
~ @rhyudek1
~ Github
  #2 (permalink)  
Antiguo 06/01/2012, 14:52
Avatar de andresdzphp
Colaborador
 
Fecha de Ingreso: julio-2011
Ubicación: $this->Colombia;
Mensajes: 2.749
Antigüedad: 12 años, 9 meses
Puntos: 793
Respuesta: Aporte: Accesibilidad - Traductor a braille

Cita:
Iniciado por Hidek1 Ver Mensaje
quizá no sea de mucha utilidad en proyectos comunes... pero sirve para destacar que PHP da para muchas cosas, es solo cuestión de imaginar :)
+1

Interesante el aporte y el código muy claro. Gracias
__________________
Si sabemos como leer e interpretar el manual será mucho más fácil aprender PHP. En lugar de confiar en ejemplos o copiar y pegar - PHP
  #3 (permalink)  
Antiguo 06/01/2012, 15:58
Colaborador
 
Fecha de Ingreso: octubre-2009
Ubicación: Tokyo - Japan !
Mensajes: 3.867
Antigüedad: 14 años, 6 meses
Puntos: 334
Respuesta: Aporte: Accesibilidad - Traductor a braille

gracias por el comentario @andresdzphp..

luego pondré el proyecto finalizado para Android a ver que tal :)

saludos.
__________________
More about me...
~ @rhyudek1
~ Github
  #4 (permalink)  
Antiguo 09/01/2012, 08:44
 
Fecha de Ingreso: noviembre-2009
Mensajes: 4
Antigüedad: 14 años, 5 meses
Puntos: 0
Respuesta: Aporte: Accesibilidad - Traductor a braille

Se agradece, igual es bueno estar innovando de vez en cuando salen buenas ideas.
  #5 (permalink)  
Antiguo 10/01/2012, 06:27
Colaborador
 
Fecha de Ingreso: octubre-2009
Ubicación: Tokyo - Japan !
Mensajes: 3.867
Antigüedad: 14 años, 6 meses
Puntos: 334
Respuesta: Aporte: Accesibilidad - Traductor a braille

es muy probable que una librería así ya existiera..
pero se me ocurrió que podría ser interesante usar operadores bit a bit para desarrollar el alfabeto..
y pues.. aquí esta el resultado..


saludos.
__________________
More about me...
~ @rhyudek1
~ Github

Etiquetas: braile, khaus, libreria, aportes
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta

SíEste tema le ha gustado a 9 personas




La zona horaria es GMT -6. Ahora son las 13:58.