Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added back massTagger feature and changed stats to now also includes …
…percentage of known morphemes weighted by frequency (field level)
- Loading branch information
Showing
5 changed files
with
28 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,29 @@ | ||
#-*- coding: utf-8 -*- | ||
from morphemes import getMorphemes, ms2str, MorphDb | ||
from morphemes import getMorphemes, MorphDb | ||
from util import addBrowserSelectionCmd, cfg, cfg1, infoMsg, QInputDialog, QFileDialog, QLineEdit | ||
import util | ||
|
||
def pre( b ): | ||
def pre( b ): # :: Browser -> State | ||
tags, ok = QInputDialog.getText( b, 'Enter tags', 'Tags', QLineEdit.Normal, 'hasMorph' ) | ||
if not ok or not tags: return | ||
path = QFileDialog.getOpenFileName( caption='Open db', directory=util.dbsPath ) | ||
if not path: return | ||
db = MorphDb( path ) | ||
return { 'b':b, 'db':db, 'tags':unicode(tags) } | ||
|
||
def per( st, n ): | ||
n.delTag( st['tags'] ) | ||
|
||
if n['k+N'] == '1': # FIXME this special but commonly wanted logic must be a cfg option | ||
ms = getMorphemes( n['focusMorph'], None, cfg1('morph_blacklist') ) | ||
for m in ms: | ||
def per( st, n ): # :: State -> Note -> State | ||
#n.delTag( st['tags'] ) # clear tags if they already exist? | ||
|
||
for field in cfg( n.mid, None, 'morph_fields' ): | ||
for m in getMorphemes( n[ field ], None, cfg1('morph_blacklist') ): | ||
if m in st['db'].db: | ||
n.addTag( st['tags'] ) | ||
break | ||
|
||
n.flush() | ||
return st | ||
|
||
def post( st ): | ||
def post( st ): # :: State -> State | ||
infoMsg( 'Tagged all notes containing morphemes in that db' ) | ||
return st | ||
|
||
addBrowserSelectionCmd( 'Mass Tagger', pre, per, post, tooltip='Tag all cards that contain morphemes from db', shortcut=None ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.