showing syntacticprops

master
Malar Kannan 2017-07-21 08:03:58 +05:30
parent 9d39bab8ca
commit 951015c543
6 changed files with 44 additions and 10539 deletions

1
.gitignore vendored
View File

@ -19,6 +19,7 @@
npm-debug.log* npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
package-lock.json*
public/png public/png
*.xml *.xml

4852
package-lock.json generated

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -48,7 +48,6 @@ function simpleAttrAccessor(attrPred: any) {
function listAttrAccessor(attrPred: any) { function listAttrAccessor(attrPred: any) {
let { attribKey, pred, lens } = attrPred; let { attribKey, pred, lens } = attrPred;
// let def = (value: any) => ({ _: value, $: { [attribKey]: attribVal } });
return { return {
get: (li: any) => { get: (li: any) => {
let def: any = []; let def: any = [];
@ -57,86 +56,33 @@ function listAttrAccessor(attrPred: any) {
return pred(m); return pred(m);
}); });
let mEs = morphExps.map((me) => { let mEs = morphExps.map((me) => {
let value = _.get<any>(me, '_', ''); let value = _.get<any>(me, '_', me);
let key = _.get<any>(me, '$.' + attribKey, ''); let key = _.get<any>(me, '$.' + attribKey, '');
return { value, key }; return { value, key };
}); });
return mEs; return mEs;
}, },
// set: (li: any, value: string) => { set: (li: any, value: any) => {
// let lexItem = _.cloneDeep(li); let lexItem = _.cloneDeep(li);
// let allProps = _.get<any>(lexItem, lens, []); let allProps = _.get<any>(lexItem, lens, []);
// if (allProps.length > 0) { if (allProps.length > 0) {
// let prop = _.filter<any>(allProps, (m) => { let prop = _.filter<any>(allProps, (m) => {
// return pred(m); return pred(m);
// }); });
// _.set(prop, '[0]._', value); _.set(prop, '[0]._', value);
// } else { } else {
// _.set(lexItem, lens, def(value)); _.set(lexItem, lens, value);
// } }
// return lexItem; return lexItem;
// } }
}; };
} }
// function attribListAccessor(lens: string, attrib: string, pred: any) {
// let def = (value: any) => ({ _: value, $: { form: attrib } });
// return {
// get: (li: any) => {
// // let def = [{ _: '', $: { form: attrib } }];
// let allProps = _.get<any>(li, lens, def(''));
// let prop = _.filter<any>(allProps, (m) => {
// return pred(m);
// });
// let mcls = _.get<any>(prop, '[0]._', '');
// return mcls;
// },
// set: (li: any, value: string) => {
// let lexItem = _.cloneDeep(li);
// let allProps = _.get<any>(lexItem, lens, []);
// if (allProps.length > 0) {
// let prop = _.filter<any>(allProps, (m) => {
// return pred(m);
// });
// if (prop.length > 0) {
// _.set(prop[0], '_', value);
// } else {
// allProps.push(def(value));
// }
// } else {
// _.set(lexItem, lens, def(value));
// }
// return lexItem;
// }
// };
// }
const attrPredGen = (lens: string, key: string, val: string, comp: any) => { const attrPredGen = (lens: string, key: string, val: string, comp: any) => {
const pred = (m: any) => comp(_.get<any>(m, '$.' + key, ''), val); const pred = (m: any) => comp(_.get<any>(m, '$.' + key, ''), val);
return { lens, attribKey: key, attribVal: val, pred }; return { lens, attribKey: key, attribVal: val, pred };
}; };
const mcParams = attrPredGen(
'lexprops[0].morphology[0].morph',
'form',
'morphclass',
_.isEqual
);
const meParams = attrPredGen(
'lexprops[0].morphology[0].morph',
'form',
'morphclass',
_.negate(_.isEqual)
);
const frParams = attrPredGen(
'syntacticprops[0].property',
'id',
'frame',
_.isEqual
);
const fieldMetaMap = { const fieldMetaMap = {
label: { label: {
type: 'text', type: 'text',
@ -150,35 +96,45 @@ const fieldMetaMap = {
relations: { type: 'text', ...simpleAccessor('relations[0]'), }, relations: { type: 'text', ...simpleAccessor('relations[0]'), },
frame: { frame: {
type: 'select', type: 'select',
...simpleAttrAccessor(frParams), ...simpleAttrAccessor(attrPredGen(
'syntacticprops[0].property',
'id',
'frame',
_.isEqual
)),
}, },
morphclass: { morphclass: {
type: 'select', type: 'select',
...simpleAttrAccessor(mcParams) ...simpleAttrAccessor(attrPredGen(
'lexprops[0].morphology[0].morph',
'form',
'morphclass',
_.isEqual
))
}, },
morphexceptions: { morphexceptions: {
type: 'list', type: 'list',
...listAttrAccessor(meParams) ...listAttrAccessor(attrPredGen(
// get: (li: any) => { 'lexprops[0].morphology[0].morph',
// let lens = 'lexprops[0].morphology[0].morph'; 'form',
// let def: any = []; 'morphclass',
// let morphProps = _.get<any>(li, lens, def); _.negate(_.isEqual)
// let morphExps = _.filter<any>(morphProps, (m) => { ))
// return _.get<any>(m, '$.form', '') !== 'morphclass';
// });
// let mEs = morphExps.map((me) => {
// let value = _.get<any>(me, '_', '');
// let key = _.get<any>(me, '$.form', '');
// return { value, key };
// });
// return mEs;
// }
}, },
stats: { type: 'text', ...simpleAccessor('stats[0].property[0]._'), }, stats: { type: 'text', ...simpleAccessor('stats[0].property[0]._'), },
lang: { lang: {
type: 'select', type: 'select',
options: ['en', 'es'], ...simpleAccessor('$.id', 'en'), options: ['en', 'es'], ...simpleAccessor('$.id', 'en'),
}, },
syntacticprops: {
type: 'list',
...listAttrAccessor(attrPredGen(
'syntacticprops[0].property',
'id',
'frame',
_.negate(_.isEqual)
))
},
}; };
const xmlToEntries = (xmlData: any) => { const xmlToEntries = (xmlData: any) => {

View File

@ -114,7 +114,7 @@ export function listInput(params: any) {
let { oldIndex, newIndex } = idxs; let { oldIndex, newIndex } = idxs;
arrayMove(value, oldIndex, newIndex); arrayMove(value, oldIndex, newIndex);
}; };
console.log('value: ', value); console.log('field: ', field, 'value: ', value);
return ( return (
<LexSingleInput key={field} label={changedLabel(changed, field)}> <LexSingleInput key={field} label={changedLabel(changed, field)}>
<SortableList <SortableList

View File

@ -1,7 +1,7 @@
from flask import Flask,send_from_directory,request from flask import Flask,send_from_directory,request
app = Flask(__name__,static_url_path='',static_folder='build') app = Flask(__name__,static_url_path='',static_folder='build')
# from freespeech_walle.get_morph_rule import get_morph # from freespeech_walle.get_morph_rule import get_morph
from freespeech_walle.wizard_helpers import get_morph_rule,get_frequency # from freespeech_walle.wizard_helpers import get_morph_rule,get_frequency
import json import json
# from flask_cors import CORS, cross_origin # from flask_cors import CORS, cross_origin