<commit_before>const FileSystemBuffer = require('./FileSystemBuffer')
const path = require('path')
const fs = require('fs')
const rimraf = require('rimraf')
const FileSystemStorer = require('./FileSystemStorer')
const { 
  uuid, 
  DocumentHTMLConverter, 
  DocumentMarkdownConverter
} = require('stencila')

// Available converters
const CONVERTERS = [
  DocumentHTMLConverter,
  DocumentMarkdownConverter
]

/**
 * A backend for the local file system
 */
class FileSystemBackend {

  constructor (userLibraryDir) {
    this.userLibraryDir = userLibraryDir
  }

  /*
    Reads a file from the file system (e.g. HTML or Markdown) converts it into
    a Stencila buffer and adds it to the library.

    NOTE: We hard-code the FileSystemStorer for now
  */
  importFile(filePath) {
    let storageArchivePath = path.dirname(filePath)
    let mainFileName = path.basename(filePath)
    let storer = new FileSystemStorer(storageArchivePath, mainFileName, 'external')
    let converter = this._getConverter(mainFileName)
    let documentId = uuid()
    let documentPath = path.join(this.userLibraryDir, documentId)
    let buffer = new FileSystemBuffer(documentPath)<commit_msg>Add Jupyter and Rmarkdown converters<commit_after>const FileSystemBuffer = require('./FileSystemBuffer')
const path = require('path')
const fs = require('fs')
const rimraf = require('rimraf')
const FileSystemStorer = require('./FileSystemStorer')
const { 
  uuid, 
  DocumentHTMLConverter, 
  DocumentMarkdownConverter,
  DocumentJupyterConverter,
  DocumentRMarkdownConverter
} = require('stencila')

// Available converters
const CONVERTERS = [
  DocumentHTMLConverter,
  DocumentMarkdownConverter,
  DocumentJupyterConverter,
  DocumentRMarkdownConverter
]

/**
 * A backend for the local file system
 */
class FileSystemBackend {

  constructor (userLibraryDir) {
    this.userLibraryDir = userLibraryDir
  }

  /*
    Reads a file from the file system (e.g. HTML or Markdown) converts it into
    a Stencila buffer and adds it to the library.

    NOTE: We hard-code the FileSystemStorer for now
  */
  importFile(filePath) {
    let storageArchivePath = path.dirname(filePath)
    let mainFileName = path.basename(filePath)
    let storer = new FileSystemStorer(storageArchivePath, mainFileName, 'external')
    let converter = this._getConverter(mainFileName)
    let documentId = uuid()
    let documentPath = path.join(this.userLibraryDir, documentId)
    let buffer = new FileSystemBuffer(documentPath)
{'fraction_non_alphanumeric': 0.08611670020120725, 'fraction_numerical': 0.0, 'mean_word_length': 4.487858719646799, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1189208', 'n_tokens_mistral': 721, 'n_tokens_neox': 702, 'n_words': 199}