Skip to content

Commit

Permalink
Merge unstable into master
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkfranz committed Sep 11, 2017
2 parents a760377 + 4841471 commit 6cf86f0
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"body-parser": "^1.15.1",
"clipboard": "^1.7.1",
"cookie-parser": "^1.4.3",
"cytoscape": "^3.2.1",
"cytoscape": "^3.2.3",
"cytoscape-automove": "^1.3.1",
"cytoscape-cose-bilkent": "^1.6.10",
"cytoscape-cxtmenu": "^2.10.3",
Expand Down
4 changes: 3 additions & 1 deletion src/client/components/document-filler.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ class DocumentFiller extends React.Component {

let toJson = res => res.json();

let animateResult = () => { return;
let animateResult = () => {
let linkout = ReactDom.findDOMNode(this).querySelector('.document-filler-linkout');

linkout.style.opacity = 0;

if( linkout ){
anime({ targets: linkout, opacity: [0, 1], duration: 2000, easing: 'linear' });
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/routes/api/document/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ let runLayout = doc => {
let cy = new Cytoscape({
elements: makeCyEles( doc.elements() ),
layout: { name: 'grid' },
// styleEnabled: true // TODO cy 3.2 bug if style enabled
styleEnabled: true
});

let runLayout = () => {
Expand Down
59 changes: 51 additions & 8 deletions src/server/routes/api/document/reach.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ const FormData = require('form-data');
const Organism = require('../../../../model/organism');

const REACH_URL = 'http://agathon.sista.arizona.edu:8080/odinweb/api/text';
const MERGE_ENTS_WITH_SAME_GROUND = true;
const ALLOW_IMPLICIT_ORG_SPEC = false;
const REMOVE_DISCONNECTED_ENTS = true;

module.exports = {
get: function( text ){
Expand All @@ -25,6 +28,7 @@ module.exports = {
let elements = [];
let elementsMap = new Map();
let elementsReachMap = new Map();
let groundReachMap = new Map();
let organisms = [];

let enableOrg = org => {
Expand All @@ -35,8 +39,6 @@ module.exports = {
}
};

let allowImplicitOrgSpec = false;

let entFrames = _.get( res, ['entities', 'frames'] ) || [];
let evtFrames = _.get( res, ['events', 'frames'] ) || [];
let senFrames = _.get( res, ['sentences', 'frames'] ) || [];
Expand All @@ -49,6 +51,8 @@ module.exports = {
let frameIsEntity = frame => frame['frame-type'] === 'entity-mention';
let frameIsEvent = frame => frame['frame-type'] === 'event-mention';
let getArgId = arg => arg.arg;
let groundIsSame = (g1, g2) => g1.namespace === g2.namespace && g1.id === g2.id;
let elIsIntn = el => el.entries != null;

let getSentenceText = id => {
let f = getFrame(id);
Expand All @@ -60,10 +64,35 @@ module.exports = {
}
};

let addElement = (el, frame) => {
elements.push( el );
elementsMap.set( el.id, el );
elementsReachMap.set( getReachId( frame ), el );
let addElement = (el, frame, ground) => {
let foundMerge = false;

if( MERGE_ENTS_WITH_SAME_GROUND && ground != null ){
let prevGround, prevReachId;

groundReachMap.forEach( ( gnd, rid ) => {
if( groundIsSame( gnd, ground ) ){
foundMerge = true;
prevGround = gnd;
prevReachId = rid;
}
} );

if( foundMerge ){
el = elementsReachMap.get( prevReachId );
ground = prevGround;
}
}

let reachId = getReachId( frame );

if( !foundMerge ){
elements.push( el );
elementsMap.set( el.id, el );
}

elementsReachMap.set( reachId, el );
groundReachMap.set( reachId, ground );
};

entFrames.forEach( addFrame );
Expand All @@ -88,13 +117,13 @@ module.exports = {
let orgIsSupported = org != null && org !== Organism.OTHER;

// implicit mention of org
if( orgIsSupported && allowImplicitOrgSpec ){
if( orgIsSupported && ALLOW_IMPLICIT_ORG_SPEC ){
enableOrg( org );
}

ent.name = frame.text;

addElement( ent, frame );
addElement( ent, frame, ground );
} );

// add explicit organisms
Expand Down Expand Up @@ -154,6 +183,20 @@ module.exports = {
}
} );

if( REMOVE_DISCONNECTED_ENTS ){
let interactions = elements.filter( elIsIntn );
let pptIds = ( () => {
let set = new Set();

interactions.forEach( intn => intn.entries.forEach( en => set.add( en.id ) ) );

return set;
} )();
let elIsInSomeIntn = el => pptIds.has( el.id );

elements = elements.filter( el => elIsIntn(el) || elIsInSomeIntn(el) );
}

return {
elements,
organisms
Expand Down

0 comments on commit 6cf86f0

Please sign in to comment.