/[ambar]/ambar/conversacion.py
ViewVC logotype

Diff of /ambar/conversacion.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2.0 by pabloruiz, Sat Aug 17 21:11:09 2002 UTC revision 2.1 by amoyav, Fri Aug 23 12:51:18 2002 UTC
# Line 1  Line 1 
1  #!/usr/bin/env python  #!/usr/bin/env python
2  #  #
3  #Minë. Mundo Interactivo-Narrativo en Español [Tierra-Media]  #Minë. Mundo Interactivo-Narrativo en Español [Tierra-Media]
4  #Copyright (C) 2002  Pablo Ruiz Múzquiz  #Copyright (C) 2002  Pablo Ruiz Múzquiz
5  #  #
6  #  #
7  #This program is free software; you can redistribute it and/or modify  #This program is free software; you can redistribute it and/or modify
8  #it under the terms of the GNU General Public License as published by  #it under the terms of the GNU General Public License as published by
9  #the Free Software Foundation; either version 2 of the License, or  #the Free Software Foundation; either version 2 of the License, or
10  #(at your option) any later version.  #(at your option) any later version.
11  #  #
12  #This program is distributed in the hope that it will be useful,  #This program is distributed in the hope that it will be useful,
13  #but WITHOUT ANY WARRANTY; without even the implied warranty of  #but WITHOUT ANY WARRANTY; without even the implied warranty of
14  #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  #GNU General Public License for more details.  #GNU General Public License for more details.
16  #  #
17  #You should have received a copy of the GNU General Public License  #You should have received a copy of the GNU General Public License
18  #along with this program; if not, write to the Free Software  #along with this program; if not, write to the Free Software
19  #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  #  #
21    
22  #Fichero: conversacion.py  #Fichero: conversacion.py
23    
24  """Clase Conversacion."""  """Clase Conversacion."""
# Line 45  class Conversacion(BloqueDialogo): Line 45  class Conversacion(BloqueDialogo):
45       - comentario (string): comentario explicativo del fichero de conversacion.       - comentario (string): comentario explicativo del fichero de conversacion.
46    
47       - _tolerancia_offtopic(int): porcentaje de rechazo de temas fuera de contexto       - _tolerancia_offtopic(int): porcentaje de rechazo de temas fuera de contexto
48       - _probabilidad_offtopic_continuar(float): probabilidad de que un offtopic permita o impida cambiar de tema       - _probabilidad_offtopic_continuar(float): probabilidad de que un offtopic permita o impida cambiar de tema
49    
50       - _sinonimos({string: string}): diccionario de conversión de sinonimos a los nombres de tema equivalentes       - _sinonimos({string: string}): diccionario de conversión de sinonimos a los nombres de tema equivalentes
51       - _contextos_iniciales([contexto]): contextos definidos con el atributo inicial='si'       - _contextos_iniciales([contexto]): contextos definidos con el atributo inicial='si'
# Line 102  class Conversacion(BloqueDialogo): Line 102  class Conversacion(BloqueDialogo):
102          self._limpiar_comentarios(doc_xml)          self._limpiar_comentarios(doc_xml)
103          self.__parsear_conversacion(doc_xml)          self.__parsear_conversacion(doc_xml)
104          self.__parsear_id(doc_xml)                self.__parsear_id(doc_xml)      
105          self._tolerancia_offtopic = 1          self._tolerancia_offtopic = 1
106          self._probabilidad_offtopic_continuar = 100          self._probabilidad_offtopic_continuar = 100
107                    
108          especiales_xml = doc_xml.getElementsByTagName("temasEspeciales")          especiales_xml = doc_xml.getElementsByTagName("temasEspeciales")
109          if especiales_xml:          if especiales_xml:
110              self._temas_especiales = self._parsear_temas_especiales(especiales_xml[0])              self._temas_especiales = self._parsear_temas_especiales(especiales_xml[0])
111              offtopic = especiales_xml[0].getElementsByTagName("temaOfftopic")              offtopic = especiales_xml[0].getElementsByTagName("temaOfftopic")
112              if offtopic and offtopic[0].getAttribute("probabilidad"):              if offtopic and offtopic[0].getAttribute("probabilidad"):
113                  self._probabilidad_offtopic_continuar = string.atoi(offtopic[0].getAttribute("probabilidad_continuar"))                  self._probabilidad_offtopic_continuar = string.atoi(offtopic[0].getAttribute("probabilidad_continuar"))
114              if offtopic and offtopic[0].getAttribute("tolerancia"):              if offtopic and offtopic[0].getAttribute("tolerancia"):
115                  self._tolerancia_offtopic = string.atoi(offtopic[0].getAttribute("tolerancia"))                  self._tolerancia_offtopic = string.atoi(offtopic[0].getAttribute("tolerancia"))
116          else:          else:
117              self._temas_especiales = {"temaAgotado": [], "temaNoEncontrado": [], "temaOfftopic" : []}              self._temas_especiales = {"temaAgotado": [], "temaNoEncontrado": [], "temaOfftopic" : []}
118                    
# Line 127  class Conversacion(BloqueDialogo): Line 127  class Conversacion(BloqueDialogo):
127              if nodo_contexto.getAttribute("inicial") == "si":              if nodo_contexto.getAttribute("inicial") == "si":
128                  self._contextos_iniciales.append(self.contexto(nodo_contexto.getAttribute("id")))                  self._contextos_iniciales.append(self.contexto(nodo_contexto.getAttribute("id")))
129                  filter(None, self._contextos_iniciales)                  filter(None, self._contextos_iniciales)
130          escribir("Cargada con éxito la conversación " + archivo)          escribir("Cargada con éxito la conversación " + archivo)
131    
132                    
133      def __parsear_conversacion(self, doc_xml):      def __parsear_conversacion(self, doc_xml):
# Line 222  class Conversacion(BloqueDialogo): Line 222  class Conversacion(BloqueDialogo):
222    
223      def tolerancia(self):      def tolerancia(self):
224          return self._tolerancia_offtopic          return self._tolerancia_offtopic
225    
226      def probabilidad_cancelacion(self):      def probabilidad_cancelacion(self):
227          return 100 - self._probabilidad_offtopic_continuar          return 100 - self._probabilidad_offtopic_continuar
228                    
229      def __str__(self):      def __str__(self):
230          texto = '<Conversacion - "' + self.id          texto = '<Conversacion - "' + self.id

Legend:
Removed from v.2.0  
changed lines
  Added in v.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26