only_ever_generator 0.3.3 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@ function isEmpty(obj) {
5
5
  return Object.keys(obj).length === 0;
6
6
  }
7
7
  function gapFilling(typologyResponse, cardgenResponse) {
8
- var _a, _b, _c, _d;
8
+ var _a, _b, _c, _d, _e;
9
9
  let allConcepts = [];
10
10
  let allFacts = [];
11
11
  let generatedConceptsList = [];
@@ -20,7 +20,7 @@ function gapFilling(typologyResponse, cardgenResponse) {
20
20
  allConcepts.push(...((_c = cardgenResponse.missing_concepts) !== null && _c !== void 0 ? _c : []));
21
21
  allFacts.push(...((_d = cardgenResponse.missing_facts) !== null && _d !== void 0 ? _d : []));
22
22
  }
23
- if (cardgenResponse.cards_data !== undefined && cardgenResponse.cards_data.length != 0) {
23
+ if (cardgenResponse.cards_data !== undefined && ((_e = cardgenResponse.cards_data) === null || _e === void 0 ? void 0 : _e.length) != 0) {
24
24
  for (let card of cardgenResponse.cards_data) {
25
25
  if (card.concepts.length != 0) {
26
26
  generatedConceptsList.push(...card.concepts);
package/dist/index.js CHANGED
@@ -45,7 +45,7 @@ Object.defineProperty(exports, "OnlyEverGenerator", { enumerable: true, get: fun
45
45
  // // summary_prompt: "",
46
46
  // // }
47
47
  // // )
48
- // let typologyRequest = await oeGen.generate(false, true);
48
+ // let typologyRequest = await oeGen.generate(true, true);
49
49
  // res.send(typologyRequest);
50
50
  // }
51
51
  // });
@@ -4,6 +4,7 @@ exports.ParseSourceContent = void 0;
4
4
  class ParseSourceContent {
5
5
  constructor(sourceContent) {
6
6
  this.titles_to_remove = ['See also', 'References', 'Further reading', 'External links', 'Notes and references', 'Bibliography', 'Notes', 'Cited sources'];
7
+ this.block_types_toremove = ['table', 'empty_line'];
7
8
  this.content = sourceContent;
8
9
  }
9
10
  parseData() {
@@ -17,16 +18,6 @@ class ParseSourceContent {
17
18
  headings: this.content.headings,
18
19
  taxonomy: this.content.taxonomy,
19
20
  };
20
- // } else if(this.content.type == 'cards'){
21
- // return {
22
- // type :'card',
23
- // title: this.content.title,
24
- // content: afterSanitized,
25
- // headings: this.content.headings
26
- // taxonomy: this.content.taxonomy,
27
- // };
28
- // }
29
- // return JSON.stringify(afterSanitized);
30
21
  }
31
22
  removeSectionsByTitle(data) {
32
23
  let dataAfterRemoving = [];
@@ -34,6 +25,10 @@ class ParseSourceContent {
34
25
  if (elem.block_type == 'heading' && this.titles_to_remove.includes(elem.content)) {
35
26
  continue;
36
27
  }
28
+ /// remove unwanted blcok types , for now `table` and `empty_line`
29
+ if (this.block_types_toremove.includes(elem.block_type)) {
30
+ continue;
31
+ }
37
32
  if (elem.children) {
38
33
  elem.children = this.removeSectionsByTitle(elem.children);
39
34
  }
@@ -57,6 +52,7 @@ class ParseSourceContent {
57
52
  }
58
53
  sanitizeBlocks(blocks) {
59
54
  let sanitizedBlocks = [];
55
+ blocks = blocks.filter((item) => item.block_type != 'table');
60
56
  blocks.forEach(block => {
61
57
  let sanitizedBlock = {};
62
58
  for (let key in block) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "only_ever_generator",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "start": "npm run build && nodemon dist/index.js",
@@ -21,8 +21,8 @@ export class OnlyEverGenerator {
21
21
  expectedFields: Array<string>;
22
22
 
23
23
 
24
- typologyResponse: any = {};
25
- cardgenResponse: any = {};
24
+ typologyResponse: any = undefined;
25
+ cardgenResponse: any = undefined;
26
26
  summarizeResponse = {};
27
27
  gapFillResponse: any = {};
28
28
 
@@ -92,7 +92,7 @@ export class OnlyEverGenerator {
92
92
 
93
93
  shouldTheCardBeGeneratedAfterTypologyResponse(){
94
94
  if(this.typologyResponse){
95
- return this.typologyResponse.generate_cards.state == true;
95
+ return this.typologyResponse?.generate_cards?.state == true;
96
96
  }else{
97
97
  return false;
98
98
  }