Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

¡¾×ª¡¿PythonʵÏÖµÄHMMÀà

#!/usr/bin/env python """
HMM module This module implements simple Hidden Markov Model class. It follows the description in
Chapter 6 of Jurafsky and Martin (2008) fairly closely, with one exception: in this
implementation, we assume that all states are initial states. @author: Rob Malouf
@organization: Dept. of Linguistics, San Diego State University
@contact: rmalouf@mail.sdsu.edu
@version: 2
@since: 24-March-2008
""" from copy import copy class HMM(object):     """
    Class for Hidden Markov Models
    An HMM is a weighted FSA which consists of:         - a set of states (0...C{self.states})
        - an output alphabet (C{self.alphabet})
        - a table of state transition probabilities (C{self.A})
        - a table of symbol emission probabilities (C{self.B})          
        - a list of initial probabilies (C{self.initial})         We assume that the HMM is complete, and that all states are both initial and final
        states. 
    """
    def __init__(self,states,alphabet,A,B,initial):
        """
        Create a new FSA object
        @param states: states
        @type states: C{list}
        @param alphabet: output alphabet
        @type finals: C{list}
        @param A: transition probabilities
   


Ïà¹ØÎĵµ£º

Python±Ê¼Ç£¨5£©

Ä£¿é
 
Ò».¼ò½é
Ä£¿é»ù±¾ÉϾÍÊÇÒ»¸ö°üº¬ÁËËùÓÐÄ㶨ÒåµÄº¯ÊýºÍ±äÁ¿µÄÎļþ¡£ÎªÁËÔÚÆäËû³ÌÐòÖÐÖØÓÃÄ£¿é£¬Ä£¿éµÄÎļþÃû±ØÐëÒÔ.pyΪÀ©Õ¹Ãû¡£
 
ÀýÈ磺
 
#!/usr/bin/python
# Filename: using_sys.py
import sys
print 'The command line arguments are:'
for i in sys.argv:
print i
print '\n ......

pythonµÄwiki ÁÐ×Ó.

#coding=utf-8
from newtest.wiki.models import WiKi
from django.template import loader, Context
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response

def index(request, pagename=""):
"""ÏÔʾÕý³£Ò³Ã棬¶ÔÒ³ÃæµÄÎÄ×Ö×öÌØÊâµÄÁ´½Ó´¦Àí"""
......

Python±Ê¼Ç£¨9£©

PythonÖеÄÎļþ²Ù×÷ÒÔ¼°ÊäÈëÊä³ö
ÎÒÃÇ¿ÉÒÔ·Ö±ðʹÓÃraw_inputºÍprintÓï¾äÀ´Íê³ÉÕâЩ¹¦ÄÜ¡£¶ÔÓÚÊä³ö£¬ÄãÒ²¿ÉÒÔʹÓöàÖÖ¶àÑùµÄstr£¨×Ö·û´®£©Àà¡£ÀýÈ磬ÄãÄܹ»Ê¹ÓÃrjust·½·¨À´µÃµ½Ò»¸ö°´Ò»¶¨¿í¶ÈÓÒ¶ÔÆëµÄ×Ö·û´®¡£ÀûÓÃhelp(str)»ñµÃ¸ü¶àÏêÇé¡£
 
 
ÁíÒ»¸ö³£ÓõÄÊäÈë/Êä³öÀàÐÍÊÇ´¦ÀíÎļþ¡£´´½¨¡¢¶ÁºÍдÎļþµÄÄÜÁ¦ÊÇ ......

python »ù±¾ÀàÐÍlist¡¢tuple¡¢dictѧϰ


1.list£¨Êý×飩
x´ú±íÊý×éÖеÄÔªËØ£¬i´ú±íλÖÃ
a) append(x) °ÑÔªËØxÌí¼Óµ½Êý×éµÄβ²¿
b) insert(i,x) °ÑÔªËØx ²åÈ뵽λÖÃi
c) remove(x) ɾ³ýµÚÒ»¸öÔªËØx
d) pop(i) ɾ³ýµÚi¸öÔªËØ£¬²¢·µ»ØÕâ¸öÔªËØ¡£Èôµ÷ÓÃpop()Ôòɾ³ý×îºóÒ»¸öÔªËØ
e) index(x) ·µ»ØÊý×éÖеÚÒ»¸öֵΪxµÄλÖá£Èç¹ûûÓÐÆ¥ÅäµÄÔªËØ»áÅ׳öÒ»¸ö´íÎó
f ......

Python ǶÌ׺¯Êý Óë ±äÁ¿×÷ÓÃÓò

a=1
print id(a)
a=2
print id(a)
a=a+1
print id(a) 
-------------------------------------------------------------------------------------------------------------------------
t=6
def tt():
    global t
    t=t+1
    print t
print t
tt()
½ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ