Skip to content

Commit

Permalink
add option to ignore content in brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
InfiniteRain committed May 17, 2019
1 parent 4cf041f commit c0776b5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion morph/morphemes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import codecs, pickle as pickle, gzip, os, subprocess, re
import re

# need some fallbacks if not running from anki and thus morph.util isn't available
try:
Expand Down Expand Up @@ -55,8 +56,12 @@ def show( self ): # str
def ms2str( ms ): # [Morpheme] -> Str
return '\n'.join( m.show() for m in ms )


def getMorphemes(morphemizer, expression, note_tags=None):
if jcfg('Option_IgnoreBracketContents'):
regex = r'\[[^\]]*\]'
if re.search(regex, expression):
expression = re.sub(regex, '', expression)

# go through all replacement rules and search if a rule (which dictates a string to morpheme conversion) can be applied
replace_rules = jcfg('ReplaceRules')
if not note_tags is None and not replace_rules is None:
Expand Down
1 change: 1 addition & 0 deletions morph/preferencesDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def createGeneralTab(self):
("Skip comprehension cards", 'Option_SkipComprehensionCards', 'Note that only has mature words (optimal for sentence learning but not for acquiring new vocabulary).'),
("Skip cards with fresh vocabulary", 'Option_SkipFreshVocabCards', 'Note that does not contain unknown words, but one or\nmore unmature (card with recently learned morphmes). Enable to\nskip to first card that has unknown vocabulary.'),
("Skip card if focus morph was already seen today", 'Option_SkipFocusMorphSeenToday', 'This improves the \'new cards\'-queue without having to recalculate the databases.'),
("Ignore everything in brackets (for MIA Japanese Support plugin)", 'Option_IgnoreBracketContents', 'Use this option to ignore content generated by the MIA Japanese Support plugin.')
]
self.boolOptionList = []
for i, (name, key, tooltipInfo) in enumerate(optionList):
Expand Down
1 change: 1 addition & 0 deletions morph/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def jcfg_default():
'Option_SkipComprehensionCards': True, # bury/skip all new cards that have 'Tag_Comprehension'
'Option_SkipFreshVocabCards': True, # bury/skip all new cards that have 'Tag_Fresh'
'Option_SkipFocusMorphSeenToday': True, # bury/skip all new cards that have a focus morph that was reviewed today/marked as `already known`
'Option_IgnoreBracketContents': False,
}

def jcfg2():
Expand Down

0 comments on commit c0776b5

Please sign in to comment.