#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Location
    Germany
    Posts
    4
    Rep Power
    0

    Phonetic search / Syntax Error


    Hi there,

    I'm trying to build a phonetic search (german) with Python and I'm always getting a Syntax Error. I have no clue though what could be wrong.
    Here is my code:

    Code:
    # -*- coding: iso-8859-1 -*-
    
    import string
    
    suchwort = "test"
    suchwort_liste =[suchwort]
    
    phontab1=['', '','', 'ss','', '', '', 'f', 'ei','ei','ei','ey','ey','ai']
    phontab2=['ss','s','sz','s', 'ae','oe','ue','ph','ey','ai','ay','ai','ay','ay']
    
    for x in range(0,len(phontab1)-1):
      if suchwort.find(phontab1[x])+1:
         suchwort_liste.append(suchwort.replace(phontab1[x],phontab2[x])
    
    for x in range(0,len(phontab2)-1):
      if suchwort.find(phontab2[x])+1:
         suchwort_liste.append(suchwort.replace(phontab2[x],phontab1[x])
    
    return suchwort_liste

    I have to add that I'm fairly new to Python. Maybe it's just a really stupid bug.

    thanks in advance

    Manuela
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    383
    Rep Power
    13
    Please paste the error as well.

    For one I see that you are not matching up parentheses correctly in your .append calls, but you should always paste the error message.
    Debian - because life's too short for worrying.
    Best. (Python.) IRC bot. ever.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Location
    Germany
    Posts
    4
    Rep Power
    0
    Originally Posted by Strike
    Please paste the error as well.

    For one I see that you are not matching up parentheses correctly in your .append calls, but you should always paste the error message.

    oh sorry, the error was:
    Code:
      File "phon_suche.py", line 15
        for x in range(0,len(phontab2)-1):
                                         ^
    SyntaxError: invalid syntax
    But you were right, I forgot the parentheses.
    It's working now.

    Thanks for your help!

    Manuela

IMN logo majestic logo threadwatch logo seochat tools logo