Skip to content

Commit

Permalink
hacked together resolvers -probably bad
Browse files Browse the repository at this point in the history
  • Loading branch information
100ideas committed Jan 14, 2021
1 parent 52d7728 commit 6daea59
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 12 deletions.
5 changes: 4 additions & 1 deletion src/client/components/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ class Dashboard extends React.Component {

return (
<StyledTranscriptAreaWrapper>
<LiveTranscript sentences={data.sentences} />
<LiveTranscript
sentences={data.sentences}
activeEntity={activeEntity}
/>
</StyledTranscriptAreaWrapper>
)
}}
Expand Down
9 changes: 7 additions & 2 deletions src/server/models/namedEntity.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ module.exports = (sequelize, DataTypes) => {
createdAt: {
allowNull: false,
type: DataTypes.DATE,
field: 'created_at',
field: 'created_at'
},
updatedAt: {
allowNull: false,
type: DataTypes.DATE,
field: 'updated_at',
field: 'updated_at'
},
sentenceId: {
allowNull: true,
type: DataTypes.INTEGER,
field: 'sentence_id'
},
}, {
tableName: 'named_entities',
Expand Down
11 changes: 8 additions & 3 deletions src/server/schema/namedEntities/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ export async function getNamedEntities(parentValue, args) {
as: 'NamedEntities',
model: models.NamedEntity,
required: true,
where: {
entity: args.relatedTo,
},
// where: {
// entity: args.relatedTo,
// },
where: [{
entity: {
[Sequelize.Op.eq]: args.relatedTo,
},
}],
}],
})
}
Expand Down
30 changes: 24 additions & 6 deletions src/server/workers/openedCaptions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,37 @@ function getSentences(words) {
async function processSentence(content) {
const sentence = await getTruecase(content)
const ents = await getEntities(sentence)
console.log("================================\n\ngot sentance:")
console.log("\t" + sentence)
console.log(`\ngot ents[${ents.length}]:`)
ents.map(e => console.log("\t" + JSON.stringify(e)))
console.log("\n")

// Save the sentence
const storedSentence = await models.Sentence.create({
content: cleanContent(sentence),
})
console.log(`\n\nstored sentance <${storedSentence.id}>:`)
console.log("\t" + JSON.stringify(storedSentence))

// Save the entities
ents.map(ent => models.NamedEntity.create({
entity: sentence.substring(ent.start, ent.end),
type: ent.label,
sentence_id: storedSentence.id,
model: 'en_core_web_lg',
}))
// let _ents = ents.map(ent =>
// models.NamedEntity.create({
// entity: sentence.substring(ent.start, ent.end),
// type: ent.label,
// sentence_id: storedSentence.id,
// model: 'en_core_web_lg'
// })
// )

console.log(`\n\nstored ents[${ents.length}]:`)
ents.forEach(ent => models.NamedEntity.create({
entity: sentence.substring(ent.start, ent.end),
type: ent.label,
sentence_id: storedSentence.id,
model: 'en_core_web_lg'
}).then(succ => console.log("\n" + JSON.stringify(succ,null,2)))
);
}

function newWord(word) {
Expand Down

0 comments on commit 6daea59

Please sign in to comment.