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
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 |
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
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 |
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
# 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 |
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
# load libraries | |
import stanza | |
import pandas as pd | |
# Download English language model and initialize the NLP pipeline. | |
stanza.download('en') | |
nlp = stanza.Pipeline('en') |
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
using System; | |
namespace abs_fac_1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
MonumentHandler greekMonumentHandler = | |
new MonumentHandler(new GreekMonumentFactory(), "Athena", "Pericles"); |
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
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) |
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
class NumberAnalyzer | |
attr_accessor :numbers | |
def initialize(numbers) | |
@numbers = numbers | |
end | |
def print_factorials | |
numbers.each do |num| | |
puts "#{num}! = #{factorial(num)}" |
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
(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 |
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
(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], |
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
using System; | |
namespace isp_3 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var basicStudent = new BasicMathStudent(new BasicCalculator()); |