All pastes #410895 Raw Edit

Someone

public text v1 · immutable
#410895 ·published 2007-03-26 19:07 UTC
rendered paste body


#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.

#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.

#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#    Autor: Jose Manuel Perez Ramirez (mankod@mankod.net , mankod@gmail.com)

#    Versión: 0.1
#    Fecha Liberación del código: 01/12/06


#!/bin/bash
clear
echo -e "+++++++++++++++++PROBABILIDAD Y ESTADISTICA +2006+++++++++++++"
echo -e "Se considera el formato del siguiente texto para sacar"
echo -e "Ingresando  texto T --> testa.sen, se crean los sig. archivos"
echo -e "     TEXTO_00 --> T1 (entrenamiento) " 
echo -e "     TEXTO_01 --> T2 (   prueba    ) " 
echo -e "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
cantidad=`wc -l testa.sen | awk '{print $1}'`
echo -e "Cantidad de lineas en el texto T: $cantidad"
num=`cat testa.sen| wc -l`;  
num=`echo "($num/5)*4" |bc` ; 
split -d -l $num testa.sen TEXTO_
wc -l TEXTO_*

echo -e "Se divide texto T en 4/5 y 1/5, correctamente !!!"
cat  TEXTO_00 |awk '{ if ($2=="sust") print; }' > SUST
cat  TEXTO_00 |awk '{ if ($2=="verb") print; }' > VERB
cat  TEXTO_00 |awk '{ if ($2=="adj") print; }' > ADJ
cat  TEXTO_00 |awk '{ if ($2=="adv") print; }' > ADV

cat ADJ  | head -n 4 > patrones 
cat SUST | head -n 4 >> patrones
cat VERB | head -n 4 >> patrones
cat ADV  | head -n 4 >> patrones
mostrar=`nl patrones`

echo -e "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo -e " Se propone mediante inspeccion de T1, antecedentes"
echo -e " que contengan una palabra con categoria VERB, SUST, ADJ, ADV 
estas son :
$mostrar"
echo -e "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"

sed -n '1,16p' testa.lst > frecuencias.L
echo -e " Se escogen las palabras de mayor frecuencia en testa.lst estas son :"
cat frecuencias.L
echo -e "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"

paste  frecuencias.L patrones > concatenan
echo -e "La union de antecedente y consecuente es :"
cat concatenan
echo -e "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo -e "La regla  formateada es : "
cat  concatenan  | awk '{print $1, $4, $5 } ' > conca
nl conca > lista_conca
cat lista_conca
echo -e "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo -e "Favor de Seleccionar una regla ... " 
read numero  
grep  $numero lista_conca | head -n 1  > seleccionada
cat seleccionada
echo -e "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo -e "La regla para validar es :"
cat seleccionada  |awk '{print $2" X/ "$4}' > seleccion_regla
#cat seleccion_regla    
cat seleccion_regla | awk '{print $2 }' 
 

echo -e "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
cat testa.sen  | awk '{print $1}' | tr '\n' ' ' > texto_sin_etiquetas 
regla=`cat seleccionada  |awk '{print $2" "$3}'`
busca_antecedente=`cat seleccion_regla | awk '{print $1 }'`
echo -e "Regla a introducir en el buscador, para validarla : $regla"
echo -e "Antecedente es = $busca_antecedente"
##echo -e "En que texto quieres hacer la validez, TEXTO_00, o TEXTO_01"
##read texto
######################################################################
acum=0
                resultado=`grep -o "\ $regla[ ^$]"  texto_sin_etiquetas|wc -l`
        	resultado1=`grep -o "\ $busca_antecedente[ ^$]"  texto_sin_etiquetas|wc -l`

                let resultado+=`grep -o "^$regla[ ^$]"  texto_sin_etiquetas|wc -l`
		let resultado1+=`grep -o "^$busca_antecedente[ ^$]"  texto_sin_etiquetas|wc -l`

                totalpalabras=`wc -w texto_sin_etiquetas 2>/dev/null | awk '{ print$1 }'`
                echo "No. de veces que se encontro el antecedente :$resultado1"
		echo "No. de veces que se encontro la regla valida :$resultado"			
	
                echo "Total de palabras : $totalpalabras"
                total=$(echo "scale=4; $resultado/$resultado1" | bc)
		echo -e "valor $total"
                acum=$(echo "scale=4; $acum+$total" |bc )
#######################################################################