Skip to content

Instantly share code, notes, and snippets.

View billmetangmo's full-sized avatar

Bill Metangmo billmetangmo

  • France
View GitHub Profile
import githubAppJwt from 'universal-github-app-jwt';
import { request } from "@octokit/request";
const APPID = "XXXXXX"
// Replace with the path to your GitHub App's private key file
const PRIVATE_KEY = `YYYYYYYYYYYYYYY`;
try {
@billmetangmo
billmetangmo / format_aws_transcript_file.py
Last active July 5, 2023 12:00
Format AWS Transcript file
import json
def transform_transcribe_output(json_output):
transcriptions = []
output = json.loads(json_output)
current_speaker_label = None
for result in output['results']['items']:
if 'speaker_label' in result:
speaker_label = result['speaker_label']
@billmetangmo
billmetangmo / scrape-email.py
Created June 10, 2023 16:19
scrape email from websites
# katana -list urls.txt -fs dn -j -o pages.json -silent
import json
import re
import csv
from concurrent.futures import ThreadPoolExecutor
def find_email_in_json_line(json_line):
# Parse the JSON line
data = json.loads(json_line)
@billmetangmo
billmetangmo / sagemaker.sh
Last active July 6, 2023 21:55
cmds to deploy to use aws + hugging face
# https://github.com/huggingface/notebooks/blob/main/sagemaker/11_deploy_model_from_hf_hub/deploy_transformer_model_from_hf_hub.ipynb
pip install "sagemaker>=2.48.0" --upgrade
data "aws_iam_policy_document" "override" {
statement {
sid = "PublicReadForGetBucketObjects"
principals {
identifiers = ["*"]
type = "AWS"
}
actions = ["s3:GetObject"]
resources = [(terraform.workspace == "default") ? "arn:aws:s3:::${var.WEBSITE_BUCKET_NAME}/*" : "arn:aws:s3:::${terraform.workspace}-${var.WEBSITE_BUCKET_NAME}/*"
@billmetangmo
billmetangmo / client.py
Created July 6, 2023 21:51
openrefine_external_call
import urllib.request
import json
# Define the URL of the Flask service
service_url = "https://5000-mongulucm-mtchounmouh-h28ndlzaxu8.ws-eu99.gitpod.io/extract_text"
# Define the URL to be scraped
scrape_url = "https://www.compta-online.com/oubli-de-facturation-facture-faite-posteriori-t72224#NULL"
# Combine these into the full request URL
import urllib2
from bs4 import BeautifulSoup
url = "https://www.compta-online.com/oubli-de-facturation-facture-faite-posteriori-t72224#NULL"
response = urllib2.urlopen(url)
html = response.read()
soup = BeautifulSoup(html, 'html.parser')
# Find the input element with the name 'text'
@billmetangmo
billmetangmo / guess_encoding.py
Created July 21, 2023 20:51
Guess encoding (python)
import chardet
def guess_encoding(file):
with open(file, 'rb') as f:
result = chardet.detect(f.read())
return result['encoding']
encoding = guess_encoding(csv_file)
df = pd.read_csv(csv_file, encoding=encoding)
@billmetangmo
billmetangmo / ocr_pdf_scanneds.md
Created July 31, 2023 15:11
ocr_pdf_scanneds

Comment détecter les tableaux sur les pages de pdf scannés ?

Détecter les tableaux dans des pages de PDF scannés est un problème qui implique plusieurs étapes, car vous travaillez avec des images numérisées plutôt qu'avec du texte numérique. Voici une approche générale:

  1. OCR (Reconnaissance optique de caractères) : La première étape consiste à utiliser une technologie OCR pour transformer les images numérisées en texte lisible par une machine. Il existe plusieurs outils qui peuvent faire cela, y compris Google's Vision API, Tesseract, Adobe's Acrobat, et d'autres. Notez que la qualité de la numérisation et la netteté de l'image peuvent affecter la précision de l'OCR.

  2. Détection des tableaux : Une fois que vous avez du texte lisible par une machine, vous pouvez commencer à détecter les tableaux. Il s'agit souvent d'une tâche difficile, car les tableaux peuvent avoir des formats très différents. Vous pourriez envisager d'utiliser des expressions régulières pour détecter des motifs qui res

@billmetangmo
billmetangmo / argilla.py
Created August 4, 2023 23:30
Label output LLM
import argilla as rg
from argilla.client.feedback.schemas.records import ResponseSchema, SuggestionSchema, ValueSchema
rg.init(
api_url="http://localhost:6900",
api_key="admin.apikey"
)
dataset = rg.FeedbackDataset(
guidelines="Add some guidelines for the annotation team here.",