Skip to content

Instantly share code, notes, and snippets.

View datancoffee's full-sized avatar

Serhii Sokolenko datancoffee

View GitHub Profile
@datancoffee
datancoffee / res_properties.xml
Created April 23, 2017 19:34
Sirocco WordNet Properties
<?xml version="1.0" encoding="UTF-8"?>
<jwnl_properties language="en">
<version publisher="Princeton" number="3.1" language="en"/>
<dictionary class="net.sf.extjwnl.dictionary.FileBackedDictionary">
<param name="morphological_processor" value="net.sf.extjwnl.dictionary.morph.DefaultMorphologicalProcessor">
<param name="operations">
<param value="net.sf.extjwnl.dictionary.morph.LookupExceptionsOperation"/>
<param value="net.sf.extjwnl.dictionary.morph.DetachSuffixesOperation">
<param name="noun" value="|s=|ses=s|xes=x|zes=z|ches=ch|shes=sh|men=man|ies=y|"/>
<param name="verb" value="|s=|ies=y|es=e|es=|ed=e|ed=|ing=e|ing=|"/>
@datancoffee
datancoffee / Opinion-Analysis-query-before.txt
Created July 9, 2017 01:15
Opinion Analysis query before
INSERT INTO opinions.stattopic (SnapshotDateId, Topic, Tags, TagCount, cntOrigPublishers, cntRepostWRs,
cntPositives, cntNegatives, cntAmbiguous, cntGeneral, SentimentHashes, OrigWebResourceHashes, RepostWebResourceHashes )
WITH
p AS (
SELECT 20170630 AS SnapshotDateId
),
CalcStatSentiments AS (
SELECT p.SnapshotDateId, t.Tag, t.GoodAsTopic, d.DocumentHash AS DocumentHash, s.SentimentHash,
wrOrig.WebResourceHash AS OrigWebResourceHash, wrOrig.Domain AS OrigDomain, wrRepost.WebResourceHash AS RepostWebResourceHash,
s.DominantValence AS Valence, d.PublicationTime AS PublicationTime
@datancoffee
datancoffee / Opinion-Analysis-query-after.txt
Created July 9, 2017 01:17
Opinion Analysis query after
INSERT INTO opinions.stattopic (SnapshotDateId, Topic, Tags, TagCount, cntOrigPublishers, cntRepostWRs,
cntPositives, cntNegatives, cntAmbiguous, cntGeneral, SentimentHashes, OrigWebResourceHashes, RepostWebResourceHashes )
WITH
p AS (
SELECT 20170630 AS SnapshotDateId
),
SentimentTags AS (
SELECT p.SnapshotDateId, s.SentimentHash, t.Tag, t.GoodAsTopic, s.Tags AS Tags
FROM p, opinions.sentiment s, UNNEST(s.Tags) AS t
WHERE
from core.inference.huggingface import InferWithHuggingface
from core.readers.github import ReadGithubIssue
from core.inference.llama3instruct import InferWithLlama3Instruct
from core.transforms.github import GithubIssueToChat
from core.writers.dlt import WriteFile
import os
# Get the Huggingface token
HF_TOKEN = os.getenv("HF_TOKEN")
@datancoffee
datancoffee / huggingface.py
Last active April 23, 2024 10:46
Place this into core.inference
from transformers import pipeline as hf_pipeline
from typing import Any
from core.actions import Action
class InferWithHuggingface(Action):
def __init__(
self,
actionname: str = None,
@datancoffee
datancoffee / llama3instruct.py
Created April 23, 2024 10:45
Place this file into core.inference
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
from typing import Any
from core.actions import Action
class InferWithLlama3Instruct(Action):
def __init__(
self,
hf_token: str,
import dlt
from dlt.common.typing import TDataItems
from dlt.common.schema import TTableSchema
from dlt.common.destination import Destination
from typing import Any
from core.actions import Action
class Read(Action):
def __init__(self, actionname: str = None):
from core.readers.dlt import Read
import dlt
from dlt.sources.helpers import requests
from typing import Any, Dict, Optional, List
class ReadGithub(Read):
def __init__(self, actionname:str = None):
super().__init__(actionname)
from typing import Any, List
from core.actions import Action
class GithubIssueToChat(Action):
def __init__(self, actionname: str = None):
super().__init__(actionname)
def do(self, issues:List, comments:List, *args:Any, **kwargs: Any) -> List:
import dlt
from typing import Any
from dlt.extract import DltResource
from dlt.destinations import filesystem
from core.actions import Action
class WriteFile(Action):