### Install Dependencies (Bash) Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/sanskritshala.github.io/src/docs/start.html Demonstrates the usage of `bower install` and `npm install` for dependency management. This is a common step in project setup to ensure all required libraries are present. ```bash bower install ``` ```bash npm install ``` -------------------------------- ### Install Word Embeddings Benchmarks package with setup.py Source: https://github.com/jivnesh/sanskritshala/blob/master/EvalSan/evaluations/Intrinsic/word_embeddings_benchmarks/README.rst Run these commands to install the package and its dependencies. You can install system‑wide, for a single user, or in development mode. The commands assume you have Python and pip available. ```bash python setup.py install pip install -r requirements.txt python setup.py install --user python setup.py build sudo python setup.py install python setup.py develop ``` -------------------------------- ### Install isarray using component (Bash) Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/bl/node_modules/isarray/README.md Instructions for installing the 'isarray' package using the component package manager. This command-line operation downloads and installs the package, allowing it to be included in projects managed by component. ```bash $ component install juliangruber/isarray ``` -------------------------------- ### HTML Code Example Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/sanskritshala.github.io/src/docs/start.html Provides a basic HTML code example showcasing the structure of a webpage with a jumbotron and a learn more button. ```html ...

Hello, world!

...

Learn more

Hello, world!

...

Learn more

... ``` -------------------------------- ### PHP Code Example Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/sanskritshala.github.io/src/docs/start.html Provides a basic PHP example that displays variables. ```php "; echo $x; echo "
"; echo $y; ?> ``` -------------------------------- ### Execute Setup Script in Bash Source: https://github.com/jivnesh/sanskritshala/blob/master/Neural_Modules/TransLIST/README.md This snippet runs the setup script after downloading required files from Google Drive and placing them in the root directory. It configures the environment post-installation. No specific inputs or dependencies beyond the environment are mentioned, and it assumes files are already downloaded. ```bash bash setup.sh ``` -------------------------------- ### Install LevelUP and LevelDOWN via npm Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/levelup/README.md Install LevelUP along with LevelDOWN as a backend. Alternatively, install the 'level' package which includes both. This is required for using LevelUP with LevelDB. ```shell npm install levelup leveldown ``` ```shell npm install level ``` -------------------------------- ### Install isarray using npm (Bash) Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/bl/node_modules/isarray/README.md Instructions for installing the 'isarray' package using the Node Package Manager (npm). This command-line operation downloads and installs the package into your project's node_modules directory, making it available for use in your JavaScript code. ```bash $ npm install isarray ``` -------------------------------- ### Install Node-Clone using npm or Ender Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/clone/README.md Instructions on how to install the node-clone library using either npm or Ender build tools. This is a prerequisite for using the library in your projects. ```bash npm install clone ``` ```bash ender build clone ``` -------------------------------- ### Install Ekko Lightbox via Bower Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/POS-tagging/static/plugins/lightbox/examples/bs3.html Command to install the Ekko Lightbox plugin using Bower package manager. Purpose is to add the JS and CSS files to the project. Depends on Bower being installed; inputs project directory, outputs plugin files in bower_components. Limitation: Requires Bower; alternative methods like CDN or direct download available. ```bash bower install ekko-lightbox --save ``` -------------------------------- ### LESS Code Example Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/sanskritshala.github.io/src/docs/start.html Provides an example of LESS variables and functions for customizing design elements, such as width, color, and background color. ```less @base: #f04615; @width: 0.5; .class { width: percentage(@width); // returns `50%` color: saturate(@base, 5%); background-color: spin(lighten(@base, 25%), 8); } ``` -------------------------------- ### CSS Code Example Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/sanskritshala.github.io/src/docs/start.html Shows a basic CSS example with body styling including font family, color, and font size. ```css /* ======= Base Styling ======= */ body { font-family: 'Open Sans', arial, sans-serif; color: #333; font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } ``` -------------------------------- ### Install level-hooks on a levelup database Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/level-hooks/README.md This snippet demonstrates the basic setup for integrating level-hooks with a levelup database instance. It initializes a levelup database and then attaches the hooks functionality to it. ```javascript var Hooks = require('level-hooks') Hooks(db) //previously: Hooks()(db) ``` -------------------------------- ### Handlebars Code Example Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/sanskritshala.github.io/src/docs/start.html Demonstrates how to create a list using Handlebars helper function. ```handlebars Handlebars.registerHelper('list', function(items, options) { var out = ""; }); ``` -------------------------------- ### Example: Implementing pre and post hooks for leveldb operations Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/level-hooks/README.md This example shows how to install and use both pre and post hooks with a levelup database. A pre hook is added to log all put operations and add a timestamped log entry. A post hook is also defined to react to completed operations. ```javascript var levelup = require('levelup') var timestamp = require('monotonic-timestamp') var hooks = require('level-hooks') levelup(file, {createIfMissing: true}, function (err, db) { //install hooks onto db. hooks(db) db.hooks.pre({start: '', end: '~'}, function (change, add) { //change is same pattern as the an element in the batch array. //add a log to record every put operation. add({type: 'put', key: '~log-'+timestamp()+'-'+change.type, value: change.key}) }) //add a hook that responds after an operation has completed. db.hooks.post(function (ch) { //{type: 'put'|'del', key: ..., value: ...} }) }) ``` -------------------------------- ### Install Stickyfill via Yarn Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/sanskritshala.github.io/src/docs/assets/plugins/stickyfill/README.md Install the Stickyfill package using Yarn as an alternative to NPM. This command adds the package to your project dependencies. ```bash yarn add stickyfilljs ``` -------------------------------- ### Setup Conda Environment for TransLIST using Bash and Python Source: https://github.com/jivnesh/sanskritshala/blob/master/Neural_Modules/TransLIST/README.md This snippet creates and activates a Conda environment for the TransLIST project using the provided tlat0.yml file. It requires Python 3.7.3, Pytorch 1.5.0, and CUDA 9.2. Users must specify the path to their Conda environments when running the requirements script. Outputs include an activated environment ready for further setup. ```bash conda env create -f tlat0.yml conda activate tlat0 bash requirements.sh [PATH to your conda environments] (e.g. ~/anaconda3/envs) ``` -------------------------------- ### Ekko Lightbox NavigationTo Example Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/sanskritshala.github.io/src/docs/assets/plugins/lightbox/index.html An example of using the 'navigateTo' functionality within Ekko Lightbox. This specific implementation allows navigation to a particular item (index 2 in this case) within the lightbox after it's shown, triggered by clicking a footer link. ```javascript $(document).on('click', '[data-toggle="lightbox"][data-gallery="navigateTo"]', function(event) { event.preventDefault(); return $(this).ekkoLightbox({ onShown: function() { this.modal().on('click', '.modal-footer a', function(e) { e.preventDefault(); this.navigateTo(2); }.bind(this)); } }); }); ``` -------------------------------- ### Basic Sublevel Database Setup and Usage Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/level-sublevel/README.md Demonstrates how to initialize a levelup database with sublevel support and create/access a specific sublevel section. It shows putting key-value pairs into both the main database and a sublevel. ```javascript var LevelUp = require('levelup') var Sublevel = require('level-sublevel') var db = Sublevel(LevelUp('/tmp/sublevel-example')) var sub = db.sublevel('stuff') //put a key into the main levelup db.put(key, value, function () { }) //put a key into the sub-section! sub.put(key2, value, function () { }) ``` -------------------------------- ### Python Code Example Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/sanskritshala.github.io/src/docs/start.html Demonstrates python program to identify numbers and print them. ```python >>> x = int(input("\n Please enter an integer: ")) Please enter an integer: 42 >>> if x < 0: ... x = 0 ... print('Negative changed to zero') ... elif x == 0: ... print('Zero') ... elif x == 1: ... print('Single') ... else: ... print('More') ... More ``` -------------------------------- ### Configure Ekko Lightbox with Options Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Compound_classifier/static/plugins/lightbox/index.html This JavaScript example shows how to initialize Ekko Lightbox with custom options. It demonstrates setting specific behaviors like `alwaysShowClose` and logging messages via the `onShown` and `onNavigate` callback functions. This allows for fine-grained control over the lightbox's behavior and interaction. ```javascript $(this).ekkoLightbox({ alwaysShowClose: true, onShown: function() { console.log('Checking our the events huh?'); }, onNavigate: function(direction, itemIndex) { console.log('Navigating ' + direction + '. Current item: ' + itemIndex); } // ... other options }); ``` -------------------------------- ### Install Stickyfill via NPM Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/sanskritshala.github.io/src/docs/assets/plugins/stickyfill/README.md Install the Stickyfill package using NPM for use in modern JavaScript projects. This method is ideal for projects using module bundlers like Webpack or Browserify. ```bash npm install stickyfilljs --save ``` -------------------------------- ### Install jQuery.scrollTo via Package Managers Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/sanskritshala.github.io/src/docs/assets/plugins/jquery-scrollTo/README.md Instructions for installing the jQuery.scrollTo plugin using bower, npm, and composer. These package managers facilitate dependency management and deployment of the library. ```bash bower install jquery.scrollTo ``` ```bash npm install jquery.scrollto ``` ```php php composer.phar require --prefer-dist flesler/jquery.scrollTo "*" ``` -------------------------------- ### Install browserify-fs Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/browserify-fs/README.md Installs the browserify-fs package using npm, which provides browser-compatible file system operations. This package bridges Node.js fs API to browser environments. ```bash npm install browserify-fs ``` -------------------------------- ### Initialize Ekko Lightbox with Callbacks Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/POS-tagging/static/plugins/lightbox/index.html This JavaScript code initializes the Ekko Lightbox plugin for elements with the 'data-toggle="lightbox"' attribute. It includes example callbacks for 'onShown' and 'onNavigate' events, which can be used for custom logic during lightbox display and navigation. ```javascript $(document).ready(function ($) { $(document).on('click', '[data-toggle="lightbox"]:not([data-gallery="navigateTo"]):not([data-gallery="example-gallery-11"])', function(event) { event.preventDefault(); return $(this).ekkoLightbox({ onShown: function() { if (window.console) { return console.log('Checking our the events huh?'); } }, onNavigate: function(direction, itemIndex) { if (window.console) { return console.log('Navigating '+direction+'. Current item: '+itemIndex); } } }); }); }); ``` -------------------------------- ### Ekko Lightbox Gallery HTML Example Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Compound_classifier/static/plugins/lightbox/examples/bs3.html This HTML example demonstrates how to group multiple links to form an image gallery within Ekko Lightbox. By adding the `data-gallery` attribute with a common value to anchor tags, users can navigate between images in the lightbox. The `data-type` attribute can be used to explicitly define the content type. ```html ``` -------------------------------- ### Run level.js tests Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/level-js/README.md These shell commands outline the process for setting up and running the tests for the level.js project. It involves cloning the repository, installing dependencies, executing the test suite, and opening a local development server in a browser. ```sh git clone git@github.com:maxogden/level.js.git cd level.js npm install npm test open localhost:9966 ``` -------------------------------- ### JavaScript Code Example Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/sanskritshala.github.io/src/docs/start.html Demonstrates javascript function to multiply two numbers. ```javascript ``` -------------------------------- ### JavaScript Example Usage of object-keys Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/object-keys/README.md Demonstrates how to use the 'object-keys' shim in a Node.js environment. It requires the module, creates an object, and asserts that the returned keys match the expected array. Dependencies include 'object-keys' and 'assert'. ```javascript var keys = require('object-keys'); var assert = require('assert'); var obj = { a: true, b: true, c: true }; assert.equal(keys(obj), ['a', 'b', 'c']); ``` -------------------------------- ### Configure Bootstrap Lightbox Options with jQuery Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/sanskritshala.github.io/src/docs/assets/plugins/lightbox/index.html This example shows how to programmatically configure Bootstrap Lightbox options when initializing it. It passes an options object to the ekkoLightbox() function, demonstrating custom settings like 'alwaysShowClose' and event handlers 'onShown' and 'onNavigate'. ```javascript $(this).ekkoLightbox({ alwaysShowClose: true, onShown: function() { console.log('Checking our the events huh?'); }, onNavigate: function(direction, itemIndex) { console.log('Navigating ' + direction + '. Current item: ' + itemIndex); } }); ``` -------------------------------- ### Ekko Lightbox NavigationTo Example Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Compound_classifier/static/plugins/lightbox/index.html This JavaScript snippet shows how to use the 'navigateTo' functionality within Ekko Lightbox. It allows for direct navigation to a specific item within the lightbox gallery after it's shown, by clicking a link in the modal footer. This provides a way to control the user's navigation flow within the gallery. ```javascript $(document).on('click', '[data-toggle="lightbox"] [data-gallery="navigateTo"]', function(event) { event.preventDefault(); return $(this).ekkoLightbox({ onShown: function() { this.modal().on('click', '.modal-footer a', function(e) { e.preventDefault(); this.navigateTo(2); }.bind(this)); } }); }); ``` -------------------------------- ### ltgt API Usage Example Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/ltgt/README.md Demonstrates the core functions of the ltgt module for interacting with database ranges. It shows how to get the start, end, bounds, and check containment within a range. ```javascript var ltgt = require('ltgt') ltgt.start(range) //the start of the range ltgt.end(range) //the end of the range //returns the lower/upper bound, whether it's inclusive or not. ltgt.lowerBound(range) ltgt.upperBound(range) ltgt.lt(range) ltgt.gt(range) ltgt.lte(range) ltgt.gte(range) //return wether this is a reversed order //(this is significant for start/end ranges ltgt.reverse(range) var filter = ltgt.filter(range) filter(key) == true //if key contained in range. ltgt.contains(range, key) ``` -------------------------------- ### HTML Anchor with Data Attributes for Lightbox Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/sanskritshala.github.io/src/docs/assets/plugins/lightbox/examples/bs3.html This HTML example demonstrates advanced usage of Lightbox by specifying options directly on the anchor tag using `data-*` attributes. It includes `data-remote` for specifying a URL that is loaded into the lightbox, `data-gallery` for grouping, and `data-type` to force the lightbox into a specific mode (e.g., 'image', 'youtube', 'vimeo'). ```html ``` -------------------------------- ### LevelDB range query examples Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/level-fix-range/README.md Shows the problem with manual reverse range handling in LevelDB where start and end parameters must be swapped. This approach is error-prone and confusing. ```javascript db.createReadStream({start: 'a', end: 'z'}) db.createReadStream({start: 'z', end: 'a', reverse: true}) ``` -------------------------------- ### Destroy LevelDB Database Directory in JavaScript Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/levelup/README.md This example shows how to completely remove a LevelDB database directory using the destroy function from LevelDOWN, which targets only LevelDB-related files. It takes a location path and a callback that receives an optional error argument upon completion. Requires separate installation of 'leveldown'; non-LevelDB files in the directory are preserved if present. ```javascript require('leveldown').destroy('./huge.db', function (err) { console.log('done!') }) ``` -------------------------------- ### Initialize filesystem with leveldb instance Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/level-filesystem/README.md Creates a filesystem instance using a leveldb database. This is the main entry point to use level-filesystem. Requires a levelup database instance as parameter. Returns a filesystem object with all fs module methods available. ```javascript var filesystem = require('level-filesystem'); var fs = filesystem(db); // where db is a levelup instance ``` -------------------------------- ### Programmatic Lightbox Initialization (jQuery) Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/POS-tagging/static/plugins/lightbox/examples/bs3.html Demonstrates how to programmatically open an image or YouTube video using the ekkoLightbox plugin with jQuery. This requires the ekkoLightbox plugin and jQuery to be included in the project. ```javascript $('#open-image').click(function (e) { e.preventDefault(); $(this).ekkoLightbox(); }); $('#open-youtube').click(function (e) { e.preventDefault(); $(this).ekkoLightbox(); }); ``` -------------------------------- ### Import Libraries and Fetch Data - Python Source: https://github.com/jivnesh/sanskritshala/blob/master/EvalSan/evaluations/Intrinsic/word_embeddings_benchmarks/examples/solve_analogy.ipynb Imports necessary libraries for logging and data fetching, then loads Google News-trained skip-gram embeddings and the Google Analogy dataset. Handles potential file download status messages. ```python import logging from web.datasets.analogy import fetch_google_analogy from web.embeddings import fetch_SG_GoogleNews # Configure logging logging.basicConfig(format='%(asctime)s %(levelname)s:%(message)s', level=logging.DEBUG, datefmt='%I:%M:%S') # Fetch skip-gram trained on GoogleNews corpus and clean it slightly w = fetch_SG_GoogleNews(lower=True, clean_words=True) # Fetch analogy dataset data = fetch_google_analogy() ``` -------------------------------- ### Install typedarray-to-buffer Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/typedarray-to-buffer/README.md Install the 'typedarray-to-buffer' package using npm. This is the primary dependency for using the library. ```bash npm install typedarray-to-buffer ``` -------------------------------- ### Initialize LevelUP with callback Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/levelup/README.md Demonstrates initializing a LevelUP database instance with a location and callback function. The callback handles potential errors and provides the opened database instance for subsequent operations. ```javascript var levelup = require('levelup') levelup('path/to/db', function (err, db) { if (err) throw err db.get('foo', function (err, value) { if (err) return console.log('foo does not exist') console.log('got foo =', value) }) }) ``` -------------------------------- ### Install jQuery.scrollTo via Packagist (PHP) Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/POS-tagging/static/plugins/jquery-scrollTo/README.md Shows how to install the plugin using Composer, a dependency manager for PHP. This approach is appropriate for PHP-based projects. ```php php composer.phar require --prefer-dist flesler/jquery.scrollTo \*\ ``` -------------------------------- ### Install isbuffer via npm Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/isbuffer/README.md Command to install the 'isbuffer' package using npm. This package is required to use the isBuffer functionality in your project. ```Bash $ npm install isbuffer ``` -------------------------------- ### Install jQuery.scrollTo via NPM Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/POS-tagging/static/plugins/jquery-scrollTo/README.md Illustrates installing jQuery.scrollTo using npm, a popular Node.js package manager. This is a common approach for JavaScript projects managed with npm. ```bash npm install jquery.scrollto ``` -------------------------------- ### Show Links in '#example_1' Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/annotatorapp/templates/annotatorapp/presentdata.html Loads and sets links data into the secondary flowchart from a JSON source. Merges links into existing data. Inputs are JSON links; outputs updated flowchart connections. Assumes valid link structure. ```javascript $flowchart.siblings('.show2').click(function() { var links = JSON.parse('{{links}}'.replace(/(")/g,"\"")); var data1 = $('#example_1').flowchart('getData'); data1['links'] = links; $('#example_1').flowchart('setData',data1); }); ``` -------------------------------- ### Install jQuery.scrollTo via Bower Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/POS-tagging/static/plugins/jquery-scrollTo/README.md Demonstrates how to install the jQuery.scrollTo plugin using Bower package manager. This method is suitable for projects that utilize Bower for dependency management. ```bash bower install jquery.scrollTo ``` -------------------------------- ### Install safe-buffer Package Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/safe-buffer/README.md This snippet shows how to install the safe-buffer package using npm, the Node Package Manager. It's a prerequisite for using the package in your Node.js project. ```bash npm install safe-buffer ``` -------------------------------- ### Install level-js using npm Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/level-js/README.md This command installs the level-js library using the Node Package Manager (npm). It is a prerequisite for using level-js in a Node.js or browserify environment. ```sh npm install level-js ``` -------------------------------- ### Initialize LevelUP with MemDOWN Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/levelup/README.md Illustrates initializing LevelUP with an in-memory database backend (MemDOWN) using an options object. This is useful for temporary or testing scenarios. ```javascript var levelup = require('levelup') var memdown = require('memdown') var db = levelup({ db: memdown }) ``` -------------------------------- ### Initialize LevelUP with MemDOWN factory Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/levelup/README.md Demonstrates initializing LevelUP with MemDOWN by passing the MemDOWN factory function directly to levelup. This is an alternative way to use backends that do not require a location. ```javascript var levelup = require('levelup') var memdown = require('memdown') var db = levelup(memdown) ``` -------------------------------- ### JavaScript File System Operations Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/browserify-fs/README.md Demonstrates basic file system operations using browserify-fs: creating directories, writing files, and reading files. Shows the async API pattern matching Node.js fs module behavior. Requires callback handling for all operations. ```javascript var fs = require('browserify-fs'); fs.mkdir('/home', function() { fs.writeFile('/home/hello-world.txt', 'Hello world!\n', function() { fs.readFile('/home/hello-world.txt', 'utf-8', function(err, data) { console.log(data); }); }); }); ``` -------------------------------- ### Get Approximate Size of a Key Range in Node.js Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/levelup/README.md Shows how to use the approximateSize method to get an estimate of the disk space used by a range of keys in a LevelDB database. This operation is dependent on LevelDOWN. ```javascript var db = require('level')('./huge.db') db.db.approximateSize('a', 'c', function (err, size) { if (err) return console.error('Ooops!', err) console.log('Approximate size of range is %d', size) }) ``` -------------------------------- ### Create an Image Gallery (HTML) Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/sanskritshala.github.io/src/docs/assets/plugins/lightbox/examples/bs3.html Demonstrates how to create an image gallery using Ekko Lightbox by adding the `data-gallery` attribute to anchor tags. Clicking any image in the group will open it in the lightbox, with navigation arrows to cycle through the rest of the gallery. This relies on standard HTML linking with specific attributes. ```html "" "" "" ``` -------------------------------- ### Install TypedArray Polyfill via npm Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/typedarray/readme.markdown Provides the command to install the 'typedarray' polyfill package using npm, the Node Package Manager. This is the standard method for incorporating the library into Node.js projects or for use with bundlers like browserify. ```bash npm install typedarray ``` -------------------------------- ### Initialize LevelUP without callback Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/levelup/README.md Shows initializing a LevelUP database instance with a location without providing an immediate callback. Operations are queued internally until the database is opened. Errors during opening will be thrown. ```javascript var levelup = require('levelup') var db = levelup('path/to/db') // will throw if an error occurs db.get('foo', function (err, value) { if (err) return console.log('foo does not exist') console.log('got foo =', value) }) ``` -------------------------------- ### Setting Up and Testing SHR Models with Constrained Inference in Python Source: https://github.com/jivnesh/sanskritshala/blob/master/Neural_Modules/TransLIST/README.md This sets up environments for SHR models and tests them on SIGHUM or Hackathon datasets, followed by constrained inference to refine predictions. Inputs include conda path and dataset specification; outputs are model predictions and final segmented text. It depends on pretrained models and is applicable only to SHR settings, with CI run from the root directory. ```bash set_sighum_shr.sh [PATH to your conda environments] ``` ```python python flat_main_bigram.py --status test --test_model best_sighum_shr2 ``` ```python python constrained_inference.py --dataset sighum ``` ```bash set_hack_shr.sh [PATH to your conda environments] ``` ```python python flat_main_bigram.py --status test --test_model best_hack_shr2 ``` ```python python constrained_inference.py --dataset hackathon ``` -------------------------------- ### Initialize Sanskrit Library view with JavaScript Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/annotatorapp/management/commands/data.txt The inline script runs when the document is ready, calling the sl.view.initSL function to set up the Sanskrit Library interface. It depends on jQuery and the sl.js library loaded earlier in the page. No parameters are passed besides an empty path string. ```JavaScript $(function() { sl.view.initSL({path:""}); }); ``` -------------------------------- ### Bootstrap Lightbox jQuery with Custom Options and Events Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/standalone_dp/static/plugins/lightbox/index.html jQuery code to initialize lightbox with specific options like alwaysShowClose and event callbacks for onShown and onNavigate. Extends the basic handler with custom behaviors. Depends on Ekko Lightbox and Bootstrap. Inputs: Options object and event directions/items. Outputs: Enhanced lightbox with console logging and custom settings. Note: Original text has a syntax error (missing comma), corrected here. ```javascript $(this).ekkoLightbox({ alwaysShowClose: true, onShown: function() { console.log('Checking our the events huh?'); }, onNavigate: function(direction, itemIndex) { console.log('Navigating '+direction+'. Current item: '+itemIndex); } }); ``` -------------------------------- ### HTML for Ekko Lightbox Image Link Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Compound_classifier/static/plugins/lightbox/examples/bs3.html This HTML snippet shows how to create a link that will trigger the Ekko Lightbox when clicked. The `href` attribute points to the full-size image, and `data-toggle="lightbox"` is the key attribute that enables the lightbox functionality. The `` tag displays a thumbnail version of the image. ```html ``` -------------------------------- ### Train Sanskrit NLP Models via Command Line Source: https://context7.com/jivnesh/sanskritshala/llms.txt This script enables training of NLP models for Sanskrit datasets directly from the command line. It supports various experiment types with customizable epochs, batch sizes, and training modes. Requires Python 3 and the main.py script with necessary dependencies and dataset files. Outputs trained models saved to the specified path, but may have limitations based on hardware resources. ```Bash # Train SaCTI model on base coarse-grained dataset python3 main.py \ --model_path='./save_models' \ --experiment='saCTI-base coarse' \ --epochs=70 \ --batch_size=50 \ --training='True' # Train on fine-grained dataset python3 main.py \ --model_path='./save_models' \ --experiment='saCTI-large fine' \ --epochs=80 \ --batch_size=55 \ --training='True' # Test mode (inference only) python3 main.py \ --model_path='./save_models' \ --experiment='saCTI-base coarse' \ --training='False' # Available experiment choices: # - 'saCTI-large coarse': Large Sanskrit dataset, coarse labels # - 'saCTI-large fine': Large Sanskrit dataset, fine-grained labels # - 'saCTI-base coarse': Base Sanskrit dataset, coarse labels # - 'saCTI-base fine': Base Sanskrit dataset, fine-grained labels # - 'marathi': Marathi dataset # - 'english': English dataset ``` -------------------------------- ### SCSS Code Example Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/sanskritshala.github.io/src/docs/start.html Demonstrates SCSS mixins for transforming elements, including rotate animation. ```scss @mixin transform($property) { -webkit-transform: $property; -ms-transform: $property; transform: $property; } .box { @include transform(rotate(30deg)); } ``` -------------------------------- ### GET Property from LevelDB Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/levelup/README.md Retrieves internal details from LevelDB based on the specified property string. This method is synchronous and returns a readable string. ```APIDOC ## GET /db/property ### Description Retrieves internal details from LevelDB based on the specified property string. This method is synchronous and returns a readable string. ### Method GET ### Endpoint /db/property ### Parameters #### Query Parameters - **property** (string) - Required - The property string to retrieve. Valid properties include 'leveldb.num-files-at-levelN', 'leveldb.stats', and 'leveldb.sstables'. ### Response #### Success Response (200) - **value** (string) - The readable string containing the requested property details. #### Response Example "243" ``` -------------------------------- ### Deep Clone Example with Node-Clone Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/clone/README.md Demonstrates how to perform a deep clone of a JavaScript object using the node-clone library. It shows how changes to the original object do not affect the cloned object. ```javascript var clone = require('clone'); var a, b; a = { foo: { bar: 'baz' } }; // initial value of a b = clone(a); // clone a -> b a.foo.bar = 'foo'; // change a console.log(a); // show a console.log(b); // show b ``` -------------------------------- ### Create Buffers using buffer-from in JavaScript Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/buffer-from/readme.md Demonstrates how to import the buffer-from ponyfill and generate Buffer instances from arrays, TypedArray buffers, and strings. Shows the resulting Buffer outputs and illustrates optional parameters like offset and length. No external dependencies beyond the buffer-from package are required. ```JavaScript const bufferFrom = require('buffer-from') console.log(bufferFrom([1, 2, 3, 4])) //=> const arr = new Uint8Array([1, 2, 3, 4]) console.log(bufferFrom(arr.buffer, 1, 2)) //=> console.log(bufferFrom('test', 'utf8')) //=> const buf = bufferFrom('test') console.log(bufferFrom(buf)) //=> ``` -------------------------------- ### Get Object Keys in JavaScript Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/level-sublevel/node_modules/object-keys/README.md This snippet demonstrates how to retrieve the keys of a JavaScript object using the Object.keys function. It asserts that the resulting array of keys matches the expected keys of the object. ```javascript var keys = require('object-keys'); var assert = require('assert'); var obj = { a: true, b: true, c: true }; assert.equal(keys(obj), ['a', 'b', 'c']); ``` -------------------------------- ### Initialize Secondary Flowchart '#example_1' Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/annotatorapp/templates/annotatorapp/presentdata.html Sets up a secondary flowchart instance with empty data and similar link event handlers. Depends on jQuery and flowchart plugin. Takes link IDs as input to update UI with modal and text. Outputs are modal displays; assumes specific DOM elements exist. ```javascript $('#example_1').flowchart({ data: {}, multipleLinksOnOutput: true, onLinkSelect: function(linkId) { $linkProperties1.show(); var data = $('#example_1').flowchart('getData'); var rname = 'link'; if (typeof data.links[linkId].relationame != 'undefined') rname = data.links[linkId].relationame; $linkname1.val(rname); $("#myModal").modal(); $('#linkrel').text(rname); return true; }, onLinkUnselect: function() { $linkProperties1.hide(); return true; } }); ``` -------------------------------- ### Building Stickyfill with Grunt Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Compound_classifier/static/plugins/stickyfill/README.md The project uses Grunt for building. Running `grunt` in the repository folder will compile the source code from `/src/stickyfill.js` to `/dist` and set up a file watcher for automatic rebuilds on changes. ```bash grunt ``` -------------------------------- ### Level-fix-range Handling of Single Start/End with Reverse Source: https://github.com/jivnesh/sanskritshala/blob/master/SanShala-Web/templates/Segmentation/mysite/node_modules/level-sublevel/node_modules/level-fix-range/README.md Illustrates how level-fix-range maintains consistent data retrieval regardless of the 'reverse' flag when only 'start' or 'end' is specified. The order of results will change, but the dataset remains the same. ```javascript {start: X, end: null} //from X to end of database {start: null, end: X} //from start of database to X ```