Skip to content

Instantly share code, notes, and snippets.

View bleroy's full-sized avatar

Bertrand Le Roy bleroy

View GitHub Profile
Weave(new[] { 1, 2, 3 }, new[] { 4, 5, 6 }) -> [1, 4, 2, 5, 3, 6]
IEnumerable<T> Weave<T>(IEnumerable<T> first, IEnumerable<T> second)
=> first
.Zip(second, (a, b) => (a, b))
.SelectMany(pair => new[] { pair.a, pair.b });
(U, T) Swap<T, U>((T x, U y) pair) => (pair.y, pair.x);
javascript: {
Object.defineProperty(Object.prototype, undefined, {
set: function(v) {
debugger;
}
})
};
void(0);
@bleroy
bleroy / bugFarm.js
Last active December 24, 2018 22:57
let someProperty, someOtherProperty;
function setProperty(target, propertyName, value) {
target[propertyName] = value;
}
function getProperty(target, propertyName) {
return target[propertyName];
}
'use strict';
const a = {foo: 'bar'};
let b, c;
a[b] = 42;
console.log(a[c]); // outputs: 42
function setProperty(target, propertyName, value) {
target[propertyName] = value;
}
function getProperty(target, propertyName) {
return target[propertyName];
}
The second word of the sentence 'add your text here!' is your
The third lemma of the sentence 'add your text here!' is text
The parse of the sentence 'add your text here!' is (ROOT (S (VP (VB add) (NP (PRP$ your) (NN text)) (ADVP (RB here))) (. !)))
The second word of the sentence 'It can contain multiple sentences.' is can
The third lemma of the sentence 'It can contain multiple sentences.' is contain
The parse of the sentence 'It can contain multiple sentences.' is (ROOT (S (NP (PRP It)) (VP (MD can) (VP (VB contain) (NP (JJ multiple) (NNS sentences)))) (. .)))
open edu.stanford.nlp.simple
// Create a document. No computation is done yet.
let doc : Document = new Document("add your text here! It can contain multiple sentences.");
let sentences = doc.sentences().toArray()
for sentObj in sentences do // Will iterate over two sentences
let sent : Sentence = sentObj :?> Sentence
// We're only asking for words -- no need to load any models yet
Console.WriteLine("The second word of the sentence '{0}' is {1}", sent, sent.word(1));
// When we ask for the lemma, it will load and run the part of speech tagger
@bleroy
bleroy / WeekIn.NET.20170516.md
Created May 9, 2017 05:14
Tips for the Week in .NET

Please comment below...