emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Matt Price <moptop99@gmail.com>
To: Org Mode <emacs-orgmode@gnu.org>
Subject: fuzzy matching of parameters
Date: Thu, 1 Dec 2016 21:11:19 -0500	[thread overview]
Message-ID: <CAN_Dec8js7xhAbbb6qFPX92EieikkjaZuOS5TOK3M2ia5O50TA@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2242 bytes --]

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)

[-- Attachment #2: Type: text/html, Size: 3246 bytes --]

             reply	other threads:[~2016-12-02  2:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-02  2:11 Matt Price [this message]
2016-12-02  3:01 ` fuzzy matching of parameters Charles C. Berry
2016-12-02 13:55 ` John Kitchin
2016-12-03 17:06   ` Matt Price

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAN_Dec8js7xhAbbb6qFPX92EieikkjaZuOS5TOK3M2ia5O50TA@mail.gmail.com \
    --to=moptop99@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).