Skip to content

Instantly share code, notes, and snippets.

View sevperez's full-sized avatar

Severin Perez sevperez

View GitHub Profile
def print_sentence_info(sentence):
print(f"Text: {sentence.text}")
print(f"Num tokens:\t{len(sentence.tokens)}")
print(f"Num words:\t{len(sentence.words)}")
print(f"Num entities:\t{len(sentence.entities)}")
print_sentence_info(moby_p1.sentences[0])
# Text: Call me Ishmael.
# Num tokens: 4
def print_doc_info(doc):
print(f"Num sentences:\t{len(doc.sentences)}")
print(f"Num tokens:\t{doc.num_tokens}")
print(f"Num words:\t{doc.num_words}")
print(f"Num entities:\t{len(doc.entities)}")
print_doc_info(moby_p1)
# Num sentences: 8
# Num tokens: 222
# Use default pipleline to create a Document object
moby_dick_para1 = "Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation. Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people’s hats off—then, I account it high time to get to sea as soon as I can. This is my substitute for pistol and ball. With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship. There is nothing sur
# load libraries
import stanza
import pandas as pd
# Download English language model and initialize the NLP pipeline.
stanza.download('en')
nlp = stanza.Pipeline('en')
using System;
namespace abs_fac_1
{
class Program
{
static void Main(string[] args)
{
MonumentHandler greekMonumentHandler =
new MonumentHandler(new GreekMonumentFactory(), "Athena", "Pericles");
class AuctionHouse
attr_accessor :items, :total_sales
def initialize(items)
@items = items
@total_sales = 0
end
def run_auction(bid_list)
handle_bid_list(bid_list)
class NumberAnalyzer
attr_accessor :numbers
def initialize(numbers)
@numbers = numbers
end
def print_factorials
numbers.each do |num|
puts "#{num}! = #{factorial(num)}"
(ns number-analyzer.core)
(declare print-factorials)
(defn -main [& args]
(print-factorials [0 1 2 3 4 5 10]))
; Prints:
; 0! = 1
; 1! = 1
; 2! = 2
(ns clojure-auction-house.core
(:require [clojure.string :as s :only :join]))
(declare announce-status run-auction)
(defn -main [& args]
(let [auction {:items { "Night Watch" nil "American Gothic" nil "Tower of Babel" nil
"Friend In Need" nil "Potato Eaters" nil "Red Balloon" nil }
:total-sales 0}
bids [["Night Watch" 550000] ["Night Watch" 700000] ["American Gothic" 145000],
using System;
namespace isp_3
{
class Program
{
static void Main(string[] args)
{
var basicStudent = new BasicMathStudent(new BasicCalculator());