This file contains 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
# records a type classification | |
class classification: | |
def __init__(self, start_token, end_token, type): | |
self.start_token = start_token | |
self.end_token = end_token | |
self.type = type | |
def __repr__(self): | |
return '{' + 's:' + str(self.start_token) + ', e:' + str(self.end_token) + ', t:' + self.type + '}' |
This file contains 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
import re | |
import random | |
def tokenise(s): | |
return ' '.join([t for t in re.split(r'([a-zA-Zñ][a-zA-Zñ\-]*|\d+\.\d+|[½⅓⅔¼¾⅕⅖⅗⅘⅙⅚⅛⅜⅝⅞\d]+|[^\w ])', s) if t.strip() != '']) | |
# replacement rule | |
class rule: | |
def __init__(self, pattern, substitution): |
This file contains 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
import json | |
import csv | |
import re | |
# Input recipe, ingredient per line, ignore blanks | |
recipe = ''' | |
2 courgettes (zucchini) | |
1 carrot | |
1 avocado | |
1 bunch basil |
This file contains 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
import csv | |
import re | |
forbidden = [ | |
'milk', | |
'cheese', | |
'egg', | |
'yoghurt', | |
'meat', | |
'beef', |
This file contains 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
import json | |
import csv | |
import re | |
# Input recipe, ingredient per line, ignore blanks | |
recipe = ''' | |
2 courgettes (zucchini) | |
1 carrot | |
1 avocado | |
1 bunch basil |
This file contains 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
import {Component, h, State} from '@stencil/core'; | |
interface IFoodNutrient { | |
name: string; | |
unitName: string; | |
amount: number; | |
} | |
interface IFood { | |
fdc_id: string; |
This file contains 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
.rda-progress { | |
position: relative; | |
display: block; | |
height: 25px; | |
background: rgb(241,241,252); | |
background: linear-gradient(90deg, rgba(251,251,252,1) 0%, rgba(218,221,236,1) 100%); | |
overflow: hidden; | |
} | |
.nutrient-container { |
This file contains 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
import random | |
# You have a fox, a chicken and a sack of grain. You must cross a river with only one of them at a time. If you leave the fox with the chicken he will eat it; if you leave the chicken with the grain he will eat it. How can you get all three across safely? | |
problem_spec = { | |
'start_state': { | |
'near bank': { | |
'you', | |
'fox', | |
'chicken', |
This file contains 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
<script src="https://cdn.jsdelivr.net/npm/ipfs@0.61.0/index.min.js"></script> | |
<script src="https://cdn.jsdelivr.net/npm/orbit-db@0.28.1/dist/orbitdb.min.js"></script> |
This file contains 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 Database { | |
ipfs: any; | |
async init() { | |
// Create IPFS instance | |
this.ipfs = window['ipfs']; | |
if (!this.ipfs) { | |
const Ipfs = window['Ipfs']; | |
this.ipfs = await Ipfs.create({ | |
preload: { enabled: false }, |
OlderNewer