Skip to content

Commit

Permalink
* MS claim-gen importer reads the "reference_urls" field, and creates…
Browse files Browse the repository at this point in the history
… a "References" attachment with each url having its own source-chain.
  • Loading branch information
Venryx committed Feb 6, 2024
1 parent f21c746 commit c2ba178
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import {Attachment, AttachmentType, SourceChain, SourceType} from "dm_common";

export abstract class CG_Node {
id: string;
narrative?: string;
reference_urls?: string[];

//abstract GetTitle(): string;
/** Get the regular, "standalone" text of the claim. (stored in debate-map as text_base) */
Expand All @@ -15,6 +18,21 @@ export abstract class CG_Node {
const result = (node.narrative ?? "").trim(); // fsr, some json files contain line-breaks at start or end, so clean this up
return result.length ? result : null;
}
static GetReferenceURLsAsAttachments(node: CG_Node) {
const referenceURLs = node.reference_urls ?? [];
if (referenceURLs.length == 0) return [];
return [
new Attachment({
references: {
sourceChains: referenceURLs.map(url=>{
return new SourceChain([
{type: SourceType.webpage, link: url},
]);
}),
},
}),
];
}
}

export class CG_Debate extends CG_Node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const NewNodeResource = CreateAccessor((context: ImportContext, data: CG_
//createdAt: Date.now(),
//creator: systemUserID,
displayDetails: undefined,
attachments: [],
attachments: IsString(data) ? [] : CG_Node.GetReferenceURLsAsAttachments(data),
node: node.id,
phrasing: CullNodePhrasingToBeEmbedded(new NodePhrasing({
id: GenerateUUID(),
Expand Down

0 comments on commit c2ba178

Please sign in to comment.