@Override protected void doInitialize(UimaContext context) throws ResourceInitializationException { coll = mongo.getDB().getCollection(collection); getNewIds(); }
@Override public void doInitialize(UimaContext aContext) throws ResourceInitializationException { super.doInitialize(aContext); MongoDatabase db = mongoResource.getDB(); recordsCollection = db.getCollection(recordsCollectionName); objectMapper = new ObjectMapper(); objectMapper.setSerializationInclusion(Include.NON_NULL); }
@Override public void afterResourcesInitialized() throws ResourceInitializationException { // Our initialisation needs to wait for Mongo to be initialised and then injected collection = mongo.getDB().getCollection(collectionName); collection.createIndex(new Document("docId", 1)); }
@Override protected void initialiseForDocuments() throws ResourceInitializationException { final MongoDatabase db = mongoResource.getDB(); documentCollection = db.getCollection(documentCollectionName); documentCollection.createIndex(new Document(EXTERNAL_ID, 1)); documentCollection.createIndex(new Document("content", TEXT)); }
@Override public void doInitialize(final UimaContext aContext) throws ResourceInitializationException { super.doInitialize(aContext); dbCollection = mongo.getDB().getCollection(collection); // Delete the whole database if (clear) { dbCollection.deleteMany(new Document()); } }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); MongoDatabase db = mongo.getDB(); documentsCollection = db.getCollection(documentCollectionName); stopwords = stopwordResource.getStopwords(stoplist); }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); MongoDatabase db = mongo.getDB(); documentsCollection = db.getCollection(documentCollectionName); stopwords = stopwordResource.getStopwords(stoplist); }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); MongoDatabase db = mongo.getDB(); documentsCollection = db.getCollection(documentCollectionName); stopwords = stopwordResource.getStopwords(stoplist); }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); MongoDatabase db = mongo.getDB(); documentsCollection = db.getCollection(documentCollectionName); stopwords = stopwordResource.getStopwords(stoplist); }
@Override protected void initialiseForRelations() throws ResourceInitializationException { final MongoDatabase db = mongoResource.getDB(); relationCollection = db.getCollection(relationCollectionName); relationCollection.createIndex(new Document(EXTERNAL_ID, 1)); relationCollection.createIndex(new Document(DOC_ID, 1)); relationCollection.createIndex(new Document(TYPE, 1)); relationCollection.createIndex(new Document("subType", 1)); // The value (being a whole sentence) is too large for index see: // https://stackoverflow.com/questions/27792706/cannot-create-index-in-mongodb-key-too-large-to-index relationCollection.createIndex(new Document(VALUE, TEXT)); }
@Override protected void initialiseForMentions() throws ResourceInitializationException { final MongoDatabase db = mongoResource.getDB(); mentionCollection = db.getCollection(mentionCollectionName); mentionCollection.createIndex(new Document(EXTERNAL_ID, 1)); mentionCollection.createIndex(new Document(DOC_ID, 1)); mentionCollection.createIndex(new Document(TYPE, 1)); mentionCollection.createIndex(new Document(VALUE, TEXT)); mentionCollection.createIndex(new Document("properties.geoJson", SPHERE)); mentionCollection.createIndex(new Document("properties.poi", SPHERE)); }
@Override protected void initialiseForEntities() throws ResourceInitializationException { final MongoDatabase db = mongoResource.getDB(); entityCollection = db.getCollection(entityCollectionName); entityCollection.createIndex(new Document(EXTERNAL_ID, 1)); entityCollection.createIndex(new Document(DOC_ID, 1)); entityCollection.createIndex(new Document(TYPE, 1)); entityCollection.createIndex(new Document(VALUE, TEXT)); entityCollection.createIndex(new Document("properties.geoJson", SPHERE)); entityCollection.createIndex(new Document("properties.poi", SPHERE)); }
/** Get the mongo db, collection and create some indexes */ @Override public void doInitialize(UimaContext aContext) throws ResourceInitializationException { MongoDatabase db = mongoResource.getDB(); relationsCollection = db.getCollection(relationsCollectionName); relationsCollection.createIndex(new Document(fields.getExternalId(), 1)); relationsCollection.createIndex(new Document(FIELD_SOURCE_VALUE, 1)); relationsCollection.createIndex(new Document(FIELD_VALUE, 1)); relationsCollection.createIndex(new Document(FIELD_TARGET_VALUE, 1)); relationsCollection.createIndex( new Document(ImmutableMap.of(FIELD_SOURCE_VALUE, 1, FIELD_TARGET_VALUE, 1))); relationsCollection.createIndex(new Document(FIELD_DOCUMENT_ID, 1)); }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); MongoDatabase db = mongo.getDB(); documentsCollection = db.getCollection(documentCollectionName); labelsAndFeatures = readLabelsAndFeaturesFromFile(labelsFile); stopwords = stopwordResource.getStopwords(stoplist); }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); MongoDatabase db = mongo.getDB(); documentsCollection = db.getCollection(documentCollectionName); labelsAndFeatures = readLabelsAndFeaturesFromFile(labelsFile); stopwords = stopwordResource.getStopwords(stoplist); }
/** Get the mongo db, collection and create some indexes */ @Override public void doInitialize(UimaContext aContext) throws ResourceInitializationException { MongoDatabase db = mongoResource.getDB(); eventsCollection = db.getCollection(eventsCollectionName); eventsCollection.createIndex(new Document(fields.getExternalId(), 1)); eventsCollection.createIndex(new Document(FIELD_DOCUMENT_ID, 1)); eventsCollection.createIndex(new Document(FIELD_TYPE, 1)); eventsCollection.createIndex(new Document(FIELD_TYPES, 1)); eventsCollection.createIndex(new Document(FIELD_TOKENS, 1)); Set<String> stopFeatures = new HashSet<>(); stopFeatures.add("uima.cas.AnnotationBase:sofa"); stopFeatures.add("uk.gov.dstl.baleen.types.BaleenAnnotation:internalId"); textClass = getTextClass(); }
@Override protected void doInitialize(UimaContext context) throws ResourceInitializationException { try { extractor = getContentExtractor(contentExtractor); } catch (InvalidParameterException ipe) { throw new ResourceInitializationException(ipe); } extractor.initialize(context, getConfigParameters(context)); coll = mongo.getDB().getCollection(collection); getNewIds(); }
/** Get the mongo db, collection and create some indexes */ @Override public void doInitialize(UimaContext aContext) throws ResourceInitializationException { MongoDatabase db = mongoResource.getDB(); entitiesCollection = db.getCollection(entitiesCollectionName); relationsCollection = db.getCollection(relationsCollectionName); documentsCollection = db.getCollection(documentsCollectionName); documentsCollection.createIndex(new Document(fields.getExternalId(), 1)); entitiesCollection.createIndex(new Document(fields.getExternalId(), 1)); relationsCollection.createIndex(new Document(fields.getExternalId(), 1)); relationsCollection.createIndex(new Document(FIELD_DOCUMENT_ID, 1)); entitiesCollection.createIndex(new Document(FIELD_DOCUMENT_ID, 1)); stopFeatures = new HashSet<>(); stopFeatures.add("uima.cas.AnnotationBase:sofa"); stopFeatures.add("uk.gov.dstl.baleen.types.BaleenAnnotation:internalId"); }
@Override protected void execute(JobSettings settings) throws AnalysisEngineProcessException { try (MongoInteractionWriter writer = new MongoInteractionWriter(mongo.getDB(), relationTypesCollection, interactionCollection)) { if (clearCollection) { getMonitor().info("Clearing previous interacton collection"); writer.clear(); } final CsvInteractionReader reader = new CsvInteractionReader(inputFilename); reader.read(writer::write); } catch (final IOException e) { throw new AnalysisEngineProcessException(e); } getMonitor().info("Finished uploading interactions to Mongo"); } }
@Override protected void execute(JobSettings settings) throws AnalysisEngineProcessException { try (MongoInteractionWriter writer = new MongoInteractionWriter(mongo.getDB(), relationTypesCollection, interactionCollection)) { if (clearCollection) { getMonitor().info("Clearing previous interacton collection"); writer.clear(); } final CsvInteractionReader reader = new CsvInteractionReader(inputFilename); reader.read(writer::write); } catch (final IOException e) { throw new AnalysisEngineProcessException(e); } getMonitor().info("Finished uploading interactions to Mongo"); } }