Johann Petrak
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Design questions for gatenlp (and gateplugin Python) === ### !!NOTE: the most important questions are marked with "**!?!**" below!! ## API In general: * what should be an attribute/propery what should be an accessor method/function? * `obj.something` vs. `obj.something(..)` * should we call accessor methods `get_xxx()` or just `xxx()`? * JP: `xxx()`, CHANGED * should we call methods that return a flag `is_xxx()` or just `xxx()`? * JP: in most cases isxxx() (not underscore needed) * CHANGED ### API for Document * CHANGED: `get_annotation_set_names()` to `annset_names()` * CHANGED: `get_annotations(..)` to `annset(..)` * CHANGED: `remove_annotation_set(name)` to `remove_annset(..)` * CHANGED `set_changelog` to `doc.changelog=cl` * REMOVED `size()` as we have `len(doc)` * `to_offset_type`: change offset type in place * but we should add a method to get a different document with the same content and a different offset type! * `copy`: so far just shallow copy but add options to create a tailor-made copy: * `include_annsets`, `exclude_annsets`, `include_docfeatures`, `exclude_docfeatures`, `offset_type`, `deep=False` ### API for AnnotationSet * `add(start,end,anntype,features=None,annid=None)`: ok * IMPORTANT: `add(..)` returns the annotation, not the ID! * `add_ann(ann, annid=None)`: OK * `by_offset`: ordered list of lists, for each offset where an annotation starts one list * should be `by_offsets` * `by_span`: ordered list of lists, each list contains unique spans * should be `by_spans` * `type_names()`: list of all types in the set * maybe should be `types()` or `types` * JP: `type_names()` is consistent with `annset_names()`, keep * `start_eq(start, ..)`: annotations starting at start, ok * `start_min_ge(pffset, ...)`: all annotations which start at the first offset after the given offset where some annotation starts. ok * `start_ge(offset, ...)`: all annotations which start at or after the given offset. ok * `start_lt(offset, ...)`: all annotations which start before the given offset. ok * `overlapping(span)`: ok * `covering(span)`: ?? * could also be: `containing(span)` * JP: prefer `covering` as contained/containing is sometimes hard to remember what contains what, bad for dyslexic like me * `within(span)`: ?? * could also be: `contained(span)` * JP: prefer `within` (see above) * `coextensive(span)`: OK * `clear()`: remove all anns * `clone_anns()`: make all anns in the set a deep copy of themselves * `document`: (no parentheses) * `get(annid)`: return the annotation with the given annotation id, same as `annset[annid]` * BUT: since we have `annset[annid]` could just as well remove * CHANGED: `detached()` to `detach()` * CHANGED: `detached_from(..)` to `detach_from(..)` * CHANGED: `is_detached()` to `detached` * CHANGED `is_immutable()` to `immutable` and setter `immutable=False` * `name`: (no parens) get the name of an annotation set (cannot be changed!) * `remove(annorid)`: OK * remove(el) is used for lists so this is kind of OK, the API for dicts is weird: del statement and pop. * `x in annset`: if there is an annotation in the set which eq-compares to x: OK * `iter(...)`: configurable iterater in offset order, needs index (but see below) * `fast_iter(...)`: iterator, unpredictable order, no index needed * **?!?** `start()`, `end()`: (parentheses): start, end of the set as a whole * this should have parentheses as it can change over the lifetime of the set * but it is equivalent to Annotation.start/end where we do not have parentheses because there the values cannot change * which to choose: parentheses or no parentheses???? * `first()`: first annotation in offset order (random one if several at same offset) * CHANGED `with_type(typenames...)` to `type(..)` * CHANGED BACK TO "with_type" since it sounds too much like we want to know the type of the annset otherwise. * **?!?** `size()` vs `len()`: number of anns in the set * we could drop `size()` * changed to `size` property * ADDED `length()`: length of the annotation set span * changed to length property ### API for Annotation Main Q here is if some of the fields should look like attributes or like functions, `ann.start` or `ann.start()`. What annoys me here (also in other packages) is that it is often not easy to remember what is a function and what is an attribute. Would be good to have a simple rule for all cases. * REMOVED: `contains_offset(off)`: NOW: `covering(off)` * `end`: no parentheses * `start`: no parentheses * `type`: no parentheses * `features`: get the Features * `gap(other)`: gap between the two annotations * `id`: no parentheses * CHANGED `is_after(other)` to `after(other)` * CHANGED `is_before(other)` to `before(other)` * CHANGED `is_coextensive(other)` to `coextensive(other)` * CHANGED `is_overlapping(other)` to `overlapping(other)` * CHANGED`is_within(other)` to `within(other)` * ADDED `covering(other)` : does it cover the span * ADDED `length()`: length of the annotation span ### API for objects that can have features ALREADY CHANGED: * previously there were methods on the bearing object to set/get features and do other stuff: * `obj.get_feature("xx")` * `obj.set_feature("name", "value")` * also `clear_features`, `del_feature`, `feature_names`, `feature_values`, `has_feature`, `num_features`, `update_features(other)`: this is awful * `features_copy`: this should be `to_dict(deep=False)` * the original idea was: we do not want to return a dict which can then be passed around and modified without us noticing, so hide the dict and make each FeatureBearer inherit the methods to modify it * This was not very pythonic though and maybe hard to remember Now implemented a different solution: * `obj.features`: returns a Features object * That object has methods that make it almost identical to a dict * `obj.features["x"] = "y"` * `obj.feature["value]"` * `obj.features` - returns the Features instance that can be passed around * selected other methods of `dict` provided they work with feature change logging * An object that has features always has an initialized Features instance. The feature instance gets the logger method from its owner. * if the owner gets its changelog removed the logger will automatically not make an attempt to log any more. * a copy of a Features object (no matter if deep or shallow) does not copy the feature logger! * Methods to convert to a dict that is a shallow/deep copy * e.g. `obj.to_dict(deep=False)` ## Print Representation * How to print/pprint the various objects: lots of detail but huge, tiny detail ... ? Especially with `Document` and `AnnotationSet` Document: which information to include, how: * full text? Mid-truncated text? * name? * all document features? truncated document features? number of document features? * annotations: all, number of annotations per type, only total numner? AnnotationSet: * Will get massive for annotated documents if we show details Annotation: * I guess showing everything is fine * But with massive annotations this could get big too For some or all of the objects it would be cool that have support for pprint, so e.g. each annotation is in a separate line, maybe even each feature per annotation is in a separate line ... ## Annotation Set Representation This is not trivial: * the result of `doc.get_anns(name)` is an instance of AnnotationSet which knows the document it belongs to. If changes are made through the API of that instance, they affect the set stored with the document AND get logged in the changelog if there is one. * but what about the sets returned from methods like `within`? * I *think* the best approach is: * return a "detached" annotation set * that set does NOT belong to the document * by default the set is immutable (cannot add or remove annotations) * the annotations in the set are shallow copies of the originals * but it can be made mutable. Since it does not "belong" to the document, any removals or additions to the annotations are not visible in the document or logged in the changelog * If annotations are removed or added in the original set in the document, they do not affect the detached set * however, since we have shallow copies, changes to a mutable feature value will affect the document * to avoid that too, there is a method on the annotation set to replace all annotations with a deep copy (should rarely be necessary) Iterating over annotations: * any annotation set can be itereated over * with `fast_iter` we get annotations in arbitrary order * with `iter` and `for ann in annset` we iterate in offset order * HOWEVER: offset order is not a strict order since we can have several annotations on the same offset * How should we provide a stable strict order of annotations? This could be based on the `<` comparison definition on annotations * BUT what is the correct `<` and `==` definition for annotations Maybe: * annotations are only equal if * start, end, type are equal * annotation id is equal * all features are equal * for annotations from the same set, no two annotations can have the same id, so the id being unequal is already enough to be sure the annotations are not equal So when iterating over annotations from a single set (and I think we always do this), a stable strict order could be based on * start * end * annid Maybe: add a method `strict_iter` to `iter` and `fast_iter` for this? ## GATE Slave interface TBD!

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully