From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: fuzzy matching of parameters Date: Fri, 02 Dec 2016 08:55:22 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46717) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCoJF-0005i8-LB for emacs-orgmode@gnu.org; Fri, 02 Dec 2016 08:55:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cCoJA-0005n6-MX for emacs-orgmode@gnu.org; Fri, 02 Dec 2016 08:55:29 -0500 Received: from mail-qt0-x232.google.com ([2607:f8b0:400d:c0d::232]:36633) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cCoJA-0005mr-IK for emacs-orgmode@gnu.org; Fri, 02 Dec 2016 08:55:24 -0500 Received: by mail-qt0-x232.google.com with SMTP id w33so251778873qtc.3 for ; Fri, 02 Dec 2016 05:55:24 -0800 (PST) In-reply-to: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Matt Price Cc: Org Mode I would not do that if I were you. The fuzzy match might inadvertently send feed back to the wrong student. I would fall back to some manual attachment if you do not find an exact match, e.g. using helm or ivy to select the files for attachment, perhaps sorted and matched using their fuzzy algorithms. Matt Price writes: > I have just done something I'm very excited about. Given a directory name > (the variable ~assignment~ in this case) and a list of student info, search > through the directory for files whose names contain the student names, and > attach those to newly created subtrees. > > Before now, manually attaching those files has been a real pain, so it's > great to have this automated! However, sometimes the name I have on file > doesn't quite match the submitted name. In particular, my Chinese students > usually have an English first name that we use in class, and a > transliterated Chinese personal name that is used in official documents > (like my class list). I would like to first try to match the whole name, > and if that fails, attempt some kind of "fuzzy" match of the name. I'm not > sure the best way to go about it. > > Any suggestions? Here is, I think, the relevant section of code (I can post > the wider context if that would be helpful). Thanks! > > Matt > > (mapcar (lambda (stu) > (let ((name (car stu)) > (email (cdr stu)) > ) > (insert (format "\n** %s" name)) > (org-todo 'todo) > (org-set-property "MAIL_TO" email) > (org-set-property "MAIL_SUBJECT" > (format "Comments on %s > Assignment (%s)" > > (mwp-org-get-parent-headline) name )) > ;; try to attach files, if possible > (condition-case nil > (let* (( afiles (directory-files > assignment nil name))) > (if afiles > (dolist (f afiles) > (org-attach-attach (concat > (file-name-directory (buffer-file-name)) assignment "/" f) )) > (message "No files match name of %s" > name))) > (error (message "Unable to attach file > belonging to student"))) > (save-excursion > (org-mark-subtree) > (org-cycle nil)) > )) students) -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu