Adding a tag to an entity in spaCy's displaCy named entity visualizer - spacy

Is there a way to use spaCy's displaCy Named Entity Visualizer and add an additional term after the entity's type? Our application tries to link each entity mention to a Wikidata item. We'd like to include a Wikidata QID after the type if one is found.

No, the Named Entity Visualizer doesn't support that.
It's a pretty recent feature but I believe the span visualizer can do what you want. You should save your WikiData IDs using the kb_id property on spans, similar to how the Entity Linker works, and then you can add links directly.

Related

Hibernate Search 5.2+ programmatic configuration of facet field

Before Hibernate Search 5.2 there was no need to explicitly use a #Facet annotation. In 5.2 it became necessary in order to use Lucene’s native faceting API.
I'm using Hibernate Search on external classes that cannot be annotated. Is there a way to define this "facet" programmatically?
For the mapping configuration, there is no issue because the SearchMapping provides a complete programmatic alternative to the #Entity, #Indexed, and #Field annotations. But within this API, and in particular in the EntityMapping class, there is no way to define that a field will be used in a facet query; there is no other alternative rather than annotating the field with #Facet.
2018 update:
I've updated to Hibernate Search 5.6.4 and it is working with this kind of mappings:
.property("businessProcess", ElementType.METHOD)
.field()
.analyze(Analyze.NO)
.store(Store.YES)
.facet()
.name("businessProcess")
.encoding(FacetEncodingType.STRING)
The workaround you referenced does not configure faceting in Hibernate Search at all (no #Facet annotation nor programmatic equivalent). In recent versions of Hibernate Search, this will not work, because we had to require this metadata in order to fix other bugs.
Using custom facet formatting is very much uncharted territory, and admittedly much harder than it should be. The main reason is that facets were originally, for a reason I cannot fathom, designed to work directly on the entity property instead of the field value. Thus, facets ignore the field bridge. We're working on cleaning up the faceting support in Search 6, but this one of many works in progress and will take some time.
In the meantime, your easiest option will probably be to just use the built-in formatting.
EDIT: Also, for dates you might want to use numeric facet formatting, so as to perform range faceting (from the first of May to the 30th of may). In that case, the name of facets is defined at query time, so built-in formatting should not matter.
And there's actually one easy solution to customize formatting in your string-encoded facets, but I didn't mention it since you are using programmatic mapping and probably do not want to change your model: you could add read-only properties returning the exact value you want in your facet (getYear, getMonth, ...), and add fields with faceting on those properties.

Can the ASP.NET Entity Framework automatically generate data annotations?

My team is writing a large scale business website in ASP.NET MVC 4 using the database-first approach. Does anyone know if it's possible to have data annotations automatically generated based on the database schema? It seems redundant to have to manually write the "buddy" metadata classes containing the data annotations when the framework should be aware of a database column's properties and make these part of the POCO classes it generates. Any suggestions would be greatly appreciated!
Take a look at LINQ to SQL.
You can use it to create a .dbml file in a graphical editor by dragging the tables from the server explorer.
Here's the MSDN How to: Create LINQ to SQL Classes in a Web Project
1) The framework does a good job of extrapolating data annotation based on table structure, but they won't be perfect.
2) Sadly, when you reach a point when you want to customize more than the framework, you are stuck with Buddy classes. They're a bit tedious but so far the best method I've found for customizing data annotation.
3) All too often, I find myself gravitating toward custom classes and away from generated POCO's. The reason is usually the differences between storing and displaying. In entry screens
I will often break up phone #'s into 3 textboxes.
Lookups for foreign keys require select lists (often added to model).
Often I'll pass other values that may be relevant to my View functionality but not specific to the storage table (display fields, navigation / bread crumbs)
Use the Database First approach with the Entity Framework.
You can generate the entity model from an existing database using the entity data model wizard.
See http://msdn.microsoft.com/en-us/data/jj206878
#Kerezo covers pretty much exactly what you want to do here: Add Data Annotation To Entity Framework(Or Linq to SQL) generated class
It is not possible to auto generate the data annotations automatically.

Customize core data model at runtime?

I want a model which could be customized by the user.
Is it possible with core data or are there better solutions?
Thanks matchi
Ps: it is an application for mac os!
This is explained under "Creating the Managed Object Model" of Apple's Core Data Utility Tutorial. In general, once you have a reference to a managed object model, you can use the NSEntityDescription and NSAttributeDescription classes to customize the entities and their attributes in the managed object model.
Note, however, that in most cases once you modify a managed object model it will no longer be compatible with existing persistent data stores, meaning that you will then have to migrate data from your old persistent store to your new one. This is definitely not an endeavor to be taken lightly.
Of course, as mentioned in the comments, Core Data can also migrate data automatically, a process known as lightweight migration. In general, though, to do so
Core Data needs to be able to find the
source and destination managed object
models itself at runtime. (Core Data
searches the bundles returned by
NSBundle’s allBundles and
allFrameworks methods.) It must then
analyze the schema changes to
persistent entities and properties and
generate an inferred mapping model.
For Core Data to be able to do this,
the changes must fit an obvious
migration pattern, for example:
Simple addition of a new attribute
A non-optional attribute becoming optional
An optional attribute becoming non-optional, and defining a default value
Does this fit your use case, or do you want to allow your users to change the managed object model in ways that would make lightweight migration impossible?
In any case, I highly recommend that you read through the following documents before you try to allow your users to modify Core Data models.
Core Data Programming Guide
Core Data Model Versioning and Data Migration Programming Guide
Core Data Utility Tutorial
NSPersistentDocument Core Data Tutorial
See the NSManagedObjectModel reference page...
Managed object models are editable
until they are used by an object graph
manager...However, once a model is
being used, it must not be changed...
I'd say this is definitely an advanced Core Data topic (and Core Data itself is already a pretty advanced topic), not to be undertaken lightly. I'm not sure that any data already stored in a data store would be useful (or even useable) if you let the user modify the model.

XML Schema Binding / Object Model Framework in Cocoa

New to XSD here.
Has anyone found or written a framework for validating XML with an XML schema in Cocoa/Obj-C?
What I really need is the ability to define permitted types of modifications to an NSXMLDocument, as described in an XSD file. This includes defining sequences of child elements, list of attributes and their permitted values, etc etc. I need to expose these modification rules in my UI. For example:
I want to constrain the names of the new child elements added to an existing NSXMLElement node in my NSOutlineView
If the XSD says that Node A has required child elements (Nodes Aa and Ab) then when the user adds Node A to the XML tree, I want to automatically create Nodes Aa & Ab and add them to the just-created Node A.
etc etc
It seems to me that a good solution would be a Cocoa counterpart of JAXB. XSOM (which doesn't create schema-derived classes, but rather gives an query-able object model of the XSD) would work too.
My question is similar to this one, but I don't want to limit myself to JAXB-like solution. I'm interested in finding out other solutions that people have come up to this problem.
Cheers!!
You can create a DTD and validate against it, or create a recursive parser based on your XSD, such as existing ones for RSS or Atom based on the spec.

Same business entity for identical tables?

I got a legacy database which have about 10 identical tables (only name differs).
Is it possible to be able to use the same business entity for all tables without having to create several classes/mapping files?
You can use the entity-name feature if you are using NHibernate v2.1 or higher. It is poorly documented but I am actively using the feature. It has gotten hard to find the documentation on it but look here:
Section 5.3 in
http://docs.jboss.org/hibernate/core/3.2/reference/en/html/mapping.html#mapping-entityname
A couple of things to be aware of. You must now use entity-name instead of class name to refer to the objects. In general it is not an entirely transparent change moving from class names to entity names.
Session actions now require two parameters, for example:
_session.Save("MyEntity", myobject)
The entity-name controls what table the data goes into.
Some HQL queries do not work right anymore, sometimes you must use Criteria instead.
If you need a set of sample code I may be able post some, but far too busy at the moment. I suggest you look at the limited info you can find and set it up for a very simple object and multiple tables to learn how it all works. It does work.
You can create a base class with all the properties, but you still need to map them all.
For that, you can either use copy&paste, XML entities (see examle at http://nhibernate.info/doc/nh/en/index.html#inheritance-tableperconcreate-polymorphism), or a code-based mapping method (Fluent or ConfORM). They usually make reuse easier.