Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamyang-liu committed Jun 26, 2021
1 parent c2f8b2c commit 176e3d4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
6 changes: 4 additions & 2 deletions client/src/annotator_ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -3353,9 +3353,10 @@ var AnnotatorUI = (function ($, window, undefined) {
"ajax.cgi",
{
protocol: 1,
action: "createEntity",
action: "modifyEntity",
entity_name: entity,
collection: collection,
type: "create"
},
function () {
dispatcher.post("ajax", [
Expand Down Expand Up @@ -3390,9 +3391,10 @@ var AnnotatorUI = (function ($, window, undefined) {
"ajax.cgi",
{
protocol: 1,
action: "deleteEntity",
action: "modifyEntity",
entity_name: entity,
collection: collection,
type: "delete"
},
function () {
dispatcher.post("ajax", [
Expand Down
24 changes: 16 additions & 8 deletions server/src/configManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,34 @@ def push(self, config_option, elem):

def remove(self, config_option, elem):
if config_option == AnnotationConfigOption.entities:
self.entities.remove(elem)
if elem in set(self.entities):
self.entities.remove(elem)
elif config_option == AnnotationConfigOption.relations:
self.relations.remove(elem)
if elem in set(self.relations):
self.relations.remove(elem)
elif config_option == AnnotationConfigOption.events:
self.events.remove(elem)
if elem in set(self.events):
self.events.remove(elem)
elif config_option == AnnotationConfigOption.attributes:
self.attributes.remove(elem)
if elem in set(self.attributes):
self.attributes.remove(elem)

def update(self, config_option, old, new):
if config_option == AnnotationConfigOption.entities:
self.entities.remove(old)
if old in set(self.entities):
self.entities.remove(old)
self.entities.append(new)
elif config_option == AnnotationConfigOption.relations:
self.relations.remove(old)
if old in set(self.relations):
self.relations.remove(old)
self.relations.append(new)
elif config_option == AnnotationConfigOption.events:
self.events.remove(old)
if old in set(self.events):
self.events.remove(old)
self.events.append(new)
elif config_option == AnnotationConfigOption.attributes:
self.attributes.remove(old)
if old in set(self.attributes):
self.attributes.remove(old)
self.attributes.append(new)

def archive(self):
Expand Down
7 changes: 3 additions & 4 deletions server/src/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from newDocument import create_new_document, import_new_document, delete_new_document, create_folder
from createSpanAll import create_span_all_text, create_span_all_re
from utils import GLOBAL_LOGGER, fetch_all_annotations, prehandle_data, cache_model_results
from newEntity import create_new_entity, delete_entity
from newEntity import modify_entity
# no-op function that can be invoked by client to log a user action


Expand Down Expand Up @@ -72,8 +72,7 @@ def logging_no_op(collection, document, log):
'deleteSpan': delete_span,
'splitSpan': split_span,

'createEntity': create_new_entity,
'deleteEntity': delete_entity,
'modifyEntity': modify_entity,

'createArc': create_arc,
'reverseArc': reverse_arc,
Expand Down Expand Up @@ -134,7 +133,7 @@ def logging_no_op(collection, document, log):

# Actions that correspond to labeling function functionality
EXPAND_ACTION = {'labelingFunctionProcess', 'instantExecutor', 'addLabelingFunction', 'deleteLabelingFunction', 'getAvailableLabelingFunction', 'createSpanAllText',
'createSpanAllRe', 'fetchAllAnnotations', 'preprocessModelData', 'createNewDocument', 'importNewDocument','deleteNewDocument', 'createNewUser', 'cacheModelResults', 'createFolder', 'createEntity', 'deleteEntity'}
'createSpanAllRe', 'fetchAllAnnotations', 'preprocessModelData', 'createNewDocument', 'importNewDocument','deleteNewDocument', 'createNewUser', 'cacheModelResults', 'createFolder', 'modifyEntity'}

# Actions that correspond to annotation functionality
ANNOTATION_ACTION = {'createArc', 'deleteArc', 'createSpan', 'deleteSpan', 'splitSpan', 'suggestSpanTypes', 'undo'}
Expand Down
8 changes: 6 additions & 2 deletions server/src/newEntity.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
from projectconfig import __parse_configs, __default_configuration, __read_or_default, SECTION_ALIAS, SEPARATOR_STR
from configManager import *

def create_new_entity(**kwargs):
def modify_entity(**kwargs):
res = dict()
entity = kwargs['entity_name']
collection = kwargs['collection']
type = kwargs['type']
real_dir = real_directory(collection)
config_dir = real_dir + "annotation.conf"
config = global_config_manager.get_collection_anno_config(config_dir)
config.push(AnnotationConfigOption.entities, entity)
if type == "create":
config.push(AnnotationConfigOption.entities, entity)
elif type == "delete":
config.remove(AnnotationConfigOption.entities, entity)
config.set_allow_duplicate(False)
config.archive()

Expand Down

0 comments on commit 176e3d4

Please sign in to comment.