This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Header = All | None | |
type Includer = Incl | Excl | |
type RuleSet = | |
| BeginWith of Header | |
| Rule of Includer*(string -> bool) | |
| Combine of RuleSet * RuleSet | |
let inline (+?) x y = Combine(x, Rule(Incl,y)) | |
let inline (-?) x y = Combine(x, Rule(Excl,y)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[<EntryPoint>] | |
let main argv = | |
let text = "awesome great this text is so exciting! this is disgusting sentence number two."; | |
let modelsDir = @"C:\tmp\stanford-corenlp-full-2014-06-16\models"; | |
let analyzer = makeSentimentAnalyzer modelsDir | |
printfn "%A" (analyzer text) | |
0 // return an integer exit code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.IO | |
open edu.stanford.nlp.ling | |
open edu.stanford.nlp.neural.rnn | |
open edu.stanford.nlp.sentiment | |
open edu.stanford.nlp.trees | |
open edu.stanford.nlp.util | |
open java.util | |
open edu.stanford.nlp.pipeline |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let getFunctionName f = | |
let type' = f.GetType() | |
let method' = type'.GetMethods() |> Array.find (fun m -> m.Name="Invoke") | |
let il = method'.GetMethodBody().GetILAsByteArray() | |
let methodCodes = [byte OpCodes.Call.Value;byte OpCodes.Callvirt.Value] | |
let position = il |> Array.findIndex(fun x -> methodCodes |> List.exists ((=)x)) | |
let metadataToken = BitConverter.ToInt32(il, position+1) | |
let actualMethod = type'.Module.ResolveMethod metadataToken |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IContainer ConfigureContainer() | |
{ | |
var builder = new ContainerBuilder(); | |
builder.RegisterType<Worker>(); | |
builder.RegisterModule(new TypedLoggersInjector(new LogFactory())); | |
return builder.Build(); | |
} | |
public static void TestInjection() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TypedLoggersInjector : Module | |
{ | |
private readonly LogFactory logFactory_; | |
public TypedLoggersInjector(LogFactory logFactory) | |
{ | |
logFactory_ = logFactory; | |
} | |
protected override void AttachToComponentRegistration(IComponentRegistry componentRegistry, IComponentRegistration registration) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] | |
public class TypedLoggerAttribute : Attribute | |
{ | |
} | |
[TypedLogger] | |
public class Worker | |
{ | |
private readonly Logger logger_; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static SyntaxNode GetListCollectionInitializerElements(ElementAccessExpressionSyntax node) | |
{ | |
return null; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static List<ExpressionSyntax> GetListCollectionInitializerElements(ElementAccessExpressionSyntax node) | |
{ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let myList = [1;2;3] |
NewerOlder