Skip to content

Commit

Permalink
Fix create inflexion pron
Browse files Browse the repository at this point in the history
  • Loading branch information
hubertbossot committed Aug 12, 2024
1 parent a0d62e5 commit ccc0293
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/wiktionary/fr_wiktionary_create_inflexions.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ def treat_page(page):
plural = getWordPlural(page_content, page_name, templates[m])
if plural is None:
return

if debug_level > 0:
print(f' Pluriel : {plural}')
print(f' Plural: {plural}')

pronunciation = get_plural_pronunciation(page_content, current_language)
if pronunciation[:1] != '|':
pronunciation = f'|{pronunciation}'
Expand Down Expand Up @@ -179,11 +179,11 @@ def treat_page(page):
plural_page = get_content_from_page(page2, 'All')
if plural_page.find('{{langue|' + language_code + '}}') != -1:
if debug_level > 0:
print(f' Pluriel existant l 216 : {plural}')
print(f' Pluriel existant : {plural}')
break
else:
if debug_level > 0:
print(' Pluriel introuvable l 219')
print(' Pluriel introuvable')
plural_page = ''

# **************** Pluriel 1 ****************
Expand Down
9 changes: 6 additions & 3 deletions src/wiktionary/fr_wiktionary_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@ def get_pronunciation_from_fr(page_content, language_code):


def get_plural_pronunciation(page_content, language_code):
global debug_level
if debug_level > 0:
print('\nget_plural_pronunciation')
if language_code != 'fr':
return None

Expand All @@ -440,21 +443,21 @@ def get_plural_pronunciation(page_content, language_code):
pron = page_content[:page_content.find('}}')]
if debug_level > 1:
print(f' pron before while: {pron}')
if pron.find('|pron=') != -1:
if '|pron=' in pron:
pron = '|' + pron[pron.find('|pron=')+len('|pron='):]

pron_array = pron.split('|')
# Ex: {{fr-rég|a.kʁɔ.sɑ̃.tʁik|mf=oui}}
n = 0
while n < len(pron_array) and (pron_array[n] == '' or pron_array[n].find('=') != -1):
if debug_level > 1:
print(pron_array[n].find('='))
n += 1
pron = '|' if n == len(pron_array) else f'|{pron_array[n]}'
if debug_level > 1:
print(f' pron after while: {pron}')
pron = trim(pron)

if pron[:1] == '|':
pron = pron[1:]
if '|' in pron:
pron = trim(pron[:pron.find('|')])
if '/' in pron:
Expand Down

0 comments on commit ccc0293

Please sign in to comment.