knowledge enum

This commit is contained in:
Robert Janetzko 2022-04-30 07:04:33 +00:00
parent 255ee03aee
commit 25ce6c179b
7 changed files with 1562 additions and 17 deletions

View file

@ -8,13 +8,22 @@ import (
)
func main() {
a := flag.String("a", "", "analyze a file")
f := flag.String("a", "", "analyze files")
l := flag.Bool("l", false, "load previous analyze data")
g := flag.Bool("g", false, "generate model")
e := flag.Bool("e", false, "regenerate events")
flag.Parse()
if len(*a) > 0 {
df.AnalyzeStructure(*a)
if len(*f) > 0 {
var a *df.AnalyzeData
var err error
if *l {
a, err = df.LoadAnalyzeData()
if err != nil {
log.Fatal(err)
}
}
df.AnalyzeStructure(*f, a)
}
if *g {

View file

@ -9847,8 +9847,259 @@
"Multiple": false,
"Base": true,
"Plus": false,
"Values": {},
"Enum": false
"Values": {
"astronomy:dates of lunar and solar eclipses": true,
"astronomy:daylight variation with solar year": true,
"astronomy:geocentric model": true,
"astronomy:height of tides vs moon and sun": true,
"astronomy:heliocentric model": true,
"astronomy:method empirical observation": true,
"astronomy:path of the moon": true,
"astronomy:phases of the moon": true,
"astronomy:relationship between lunar solar year": true,
"astronomy:star catalogues 100": true,
"astronomy:star catalogues 1000": true,
"astronomy:star charts": true,
"astronomy:star color classification": true,
"astronomy:star magnitude classification": true,
"astronomy:summer winter moon": true,
"astronomy:summer winter sun": true,
"astronomy:tides and the moon": true,
"chemistry:chemicals:adhesives": true,
"chemistry:chemicals:nitric acid": true,
"chemistry:chemicals:sulfuric acid": true,
"chemistry:classification:alkali and acids": true,
"chemistry:classification:combustibles": true,
"chemistry:classification:elemental theory": true,
"chemistry:classification:ores": true,
"chemistry:classification:scratch test": true,
"chemistry:laboratory:alembic": true,
"chemistry:laboratory:blast furnace": true,
"chemistry:laboratory:crucible": true,
"chemistry:laboratory:glass ampoule": true,
"chemistry:laboratory:glass beaker": true,
"chemistry:laboratory:glass flask": true,
"chemistry:laboratory:glass funnel": true,
"chemistry:laboratory:glass retort": true,
"chemistry:laboratory:glass vial": true,
"chemistry:laboratory:lab ovens": true,
"chemistry:laboratory:systematic experiments": true,
"chemistry:laboratory:theory of distillation": true,
"chemistry:laboratory:theory of evaporation": true,
"chemistry:laboratory:theory of liquid-liquid extraction": true,
"chemistry:metallurgy:alloys": true,
"engineering:astronomy:armillary sphere": true,
"engineering:astronomy:astrolabe": true,
"engineering:astronomy:dioptra": true,
"engineering:construction:wood lamination": true,
"engineering:design:models and templates": true,
"engineering:fluid:archimedes principle": true,
"engineering:fluid:force pump": true,
"engineering:fluid:theory of siphon": true,
"engineering:fluid:valves": true,
"engineering:horology:conical water clock": true,
"engineering:horology:hourglass": true,
"engineering:horology:shadow clock": true,
"engineering:horology:water clock": true,
"engineering:horology:water clock reservoir": true,
"engineering:machine:balance wheel": true,
"engineering:machine:bellows": true,
"engineering:machine:camshaft": true,
"engineering:machine:chain drive": true,
"engineering:machine:chariot odometer": true,
"engineering:machine:crank": true,
"engineering:machine:crankshaft": true,
"engineering:machine:differential gear": true,
"engineering:machine:double-acting piston bellows": true,
"engineering:machine:lever": true,
"engineering:machine:mechanical compass": true,
"engineering:machine:padlock": true,
"engineering:machine:piston": true,
"engineering:machine:pulley": true,
"engineering:machine:screw": true,
"engineering:machine:straight-beam balance": true,
"engineering:machine:theory of gears": true,
"engineering:machine:theory of lever": true,
"engineering:machine:theory of pulley": true,
"engineering:machine:theory of screw": true,
"engineering:machine:theory of wedge": true,
"engineering:machine:theory of wheel-and-axle": true,
"engineering:machine:trip hammer": true,
"engineering:machine:tumbler lock": true,
"engineering:machine:verge escapement": true,
"engineering:machine:warded lock": true,
"engineering:machine:water wheel": true,
"engineering:machine:water-powered sawmill": true,
"engineering:machine:windlass": true,
"engineering:optics:camera obscura": true,
"engineering:optics:crystal lens": true,
"engineering:optics:glass lens": true,
"engineering:optics:theory of color": true,
"engineering:optics:water-filled spheres": true,
"geography:cartography:basic": true,
"geography:cartography:economic": true,
"geography:cartography:geological": true,
"geography:form:atlas": true,
"geography:method:economic data collection": true,
"geography:surveying:basic": true,
"geography:surveying:staff": true,
"geography:theory:delta formation": true,
"geography:theory:origin of rainfall from evap condense": true,
"geography:theory:water cycle": true,
"geography:theory:wind patterns": true,
"history:form:alternate history": true,
"history:form:autobiographical adventure": true,
"history:form:biographical dictionaries": true,
"history:form:biography": true,
"history:form:comparative biography": true,
"history:form:cultural comparison": true,
"history:form:cultural history": true,
"history:form:encyclopedia": true,
"history:form:genealogy": true,
"history:form:treatise on tech evolution": true,
"history:sourcing:basic archaeology": true,
"history:sourcing:basic reliability": true,
"history:sourcing:personal interviews": true,
"history:sourcing:role of cultural differences": true,
"history:sourcing:role of state bias and propaganda": true,
"history:theory:historical causation": true,
"history:theory:historical cycles": true,
"history:theory:social cohesion": true,
"history:theory:social conflict": true,
"mathematics:algebra:balancing and completion": true,
"mathematics:algebra:divergence of harmonic series": true,
"mathematics:algebra:finite summation formulas": true,
"mathematics:algebra:pascal's triangle": true,
"mathematics:algebra:quadratic by completing square": true,
"mathematics:algebra:quadratic formula": true,
"mathematics:algebra:solving higher order polynomials": true,
"mathematics:algebra:solving linear systems": true,
"mathematics:geometry:area of triangle from side lengths": true,
"mathematics:geometry:basic objects": true,
"mathematics:geometry:existence of incommensurable ratios": true,
"mathematics:geometry:geometric mean theorem": true,
"mathematics:geometry:inscribed triangle on diameter is right": true,
"mathematics:geometry:isosceles base angles equal": true,
"mathematics:geometry:pi to 4 digits": true,
"mathematics:geometry:properties of chords": true,
"mathematics:geometry:pythagorean theorem": true,
"mathematics:geometry:pythagorean triples small": true,
"mathematics:geometry:similar and congruent triangles": true,
"mathematics:geometry:volume of pyramid": true,
"mathematics:method:axiomatic reasoning": true,
"mathematics:method:exhaustion": true,
"mathematics:method:proof by contradiction": true,
"mathematics:notation:large numbers": true,
"mathematics:notation:negative numbers": true,
"mathematics:notation:positional": true,
"mathematics:notation:syncopated algebra": true,
"mathematics:notation:zero": true,
"mathematics:numbers:algorithm for computing gcd": true,
"mathematics:numbers:chinese remainder algorithm": true,
"mathematics:numbers:division algorithm": true,
"mathematics:numbers:infinite primes": true,
"mathematics:numbers:root 2 to 5 digits": true,
"mathematics:numbers:sieve algorithm for primes": true,
"mathematics:numbers:unique prime factorization": true,
"medicine:method:anesthesia": true,
"medicine:method:autopsy": true,
"medicine:method:cauterization": true,
"medicine:method:fracture immobilization": true,
"medicine:method:fracture treatment": true,
"medicine:method:hernia surgery": true,
"medicine:method:physical examination": true,
"medicine:method:surgery draining": true,
"medicine:method:surgery excision": true,
"medicine:method:surgery incision": true,
"medicine:method:surgery ligature": true,
"medicine:method:surgery probing": true,
"medicine:method:surgery scraping": true,
"medicine:method:surgery suturing": true,
"medicine:method:tracheotomy surgery": true,
"medicine:method:treatment of traumatic injuries": true,
"medicine:theory:anatomical studies": true,
"medicine:theory:blood vessels": true,
"medicine:theory:classification of bodily fluids": true,
"medicine:theory:classification of muscles": true,
"medicine:theory:comparative anatomy": true,
"medicine:theory:convalescence": true,
"medicine:theory:disease and fouled water": true,
"medicine:theory:disease classification": true,
"medicine:theory:endemic disease": true,
"medicine:theory:epidemic disease": true,
"medicine:theory:exacerbation": true,
"medicine:theory:eye anatomy": true,
"medicine:theory:fracture classification": true,
"medicine:theory:motor vs sensory nerves": true,
"medicine:theory:paroxysm": true,
"medicine:theory:prognosis": true,
"medicine:theory:pulmonary medicine": true,
"medicine:theory:specialized surgical instruments": true,
"medicine:theory:surgical models": true,
"medicine:theory:the voice": true,
"medicine:theory:toxicology": true,
"medicine:tool:animal remedies": true,
"medicine:tool:animals as surgical models": true,
"medicine:tool:bandages": true,
"medicine:tool:dedicated hospitals": true,
"medicine:tool:herbal remedies": true,
"medicine:tool:mineral remedies": true,
"medicine:tool:mud bags as surgical models": true,
"medicine:tool:plants as surgical models": true,
"medicine:tool:scalpel": true,
"medicine:tool:surgical needles": true,
"medicine:tool:surgical scissors": true,
"naturalist:method:dissection": true,
"naturalist:observation:anatomy": true,
"naturalist:observation:diseases": true,
"naturalist:observation:embriological development": true,
"naturalist:observation:foraging behavior and diet": true,
"naturalist:observation:migration patterns": true,
"naturalist:observation:reproductive behavior": true,
"naturalist:observation:social behavior": true,
"naturalist:theory:classification by physical features": true,
"naturalist:theory:climatic adaptation": true,
"naturalist:theory:comparative anatomy": true,
"naturalist:theory:food chain": true,
"naturalist:theory:struggle for existence": true,
"philosophy:aesthetics:nature of beauty": true,
"philosophy:aesthetics:value of art": true,
"philosophy:epistemology:belief": true,
"philosophy:epistemology:justification": true,
"philosophy:epistemology:perception": true,
"philosophy:epistemology:truth": true,
"philosophy:ethics:applied interpersonal conduct": true,
"philosophy:ethics:applied medical": true,
"philosophy:ethics:applied military": true,
"philosophy:ethics:individual value": true,
"philosophy:ethics:state consequentialism": true,
"philosophy:logic:analogical inference": true,
"philosophy:logic:deductive reasoning": true,
"philosophy:logic:dialectic reasoning": true,
"philosophy:logic:direct inference": true,
"philosophy:logic:formal reasoning": true,
"philosophy:logic:hypothetical syllogisms": true,
"philosophy:logic:inductive reasoning": true,
"philosophy:logic:syllogistic logic": true,
"philosophy:metaphysics:causation": true,
"philosophy:metaphysics:events": true,
"philosophy:metaphysics:existence": true,
"philosophy:metaphysics:mind body": true,
"philosophy:metaphysics:objects and properties": true,
"philosophy:metaphysics:processes": true,
"philosophy:metaphysics:time": true,
"philosophy:metaphysics:wholes and parts": true,
"philosophy:specialized:education": true,
"philosophy:specialized:language dictionary": true,
"philosophy:specialized:language etymology": true,
"philosophy:specialized:language grammar": true,
"philosophy:specialized:law": true,
"philosophy:specialized:politics diplomacy": true,
"philosophy:specialized:politics economic policy": true,
"philosophy:specialized:politics government forms": true,
"philosophy:specialized:politics social welfare": true
},
"Enum": true
},
"df_world|historical_events|historical_event+MasterpieceArchConstructed|building_custom": {
"IsString": false,

View file

@ -16,7 +16,9 @@ import (
"github.com/robertjanetzko/LegendsBrowser2/backend/util"
)
func enumValue(s string) string { return strcase.ToCamel(strings.ReplaceAll(s, "2", " two")) }
func enumValue(s string) string {
return strcase.ToCamel(strings.ReplaceAll(strings.ReplaceAll(s, "2", " two"), ":", "_"))
}
func enumString(s string) string { return strcase.ToDelimited(s, ' ') }
var backendTemplate = template.Must(template.New("").Funcs(template.FuncMap{

View file

@ -16,7 +16,7 @@ import (
"github.com/robertjanetzko/LegendsBrowser2/backend/util"
)
func AnalyzeStructure(filex string) error {
func AnalyzeStructure(filex string, a *AnalyzeData) error {
fmt.Println("Search...", filex)
files, err := filepath.Glob(filex + "/*-legends.xml")
if err != nil {
@ -24,7 +24,9 @@ func AnalyzeStructure(filex string) error {
}
fmt.Println(files)
a := NewAnalyzeData()
if a == nil {
a = NewAnalyzeData()
}
for _, file := range files {
analyze(file, a)
@ -53,7 +55,7 @@ func NewFieldData() *FieldData {
type AnalyzeData struct {
Fields map[string]*FieldData
SubTypes map[string]*map[string]*Subtype
Overwrites *Overwrites
Overwrites *Overwrites `json:"-"`
}
func NewAnalyzeData() *AnalyzeData {
@ -316,11 +318,17 @@ Loop:
s := strings.TrimSpace(string(data))
if _, err := strconv.Atoi(s); err != nil {
f := a.GetField(strings.Join(path, PATH_SEPARATOR))
force := ctx.overwrites.ForceEnum[strings.Join(path, PATH_SEPARATOR)]
if force {
f.Enum = true
}
f.IsString = true
if s != "" && f.Enum {
f.Values[s] = true
}
force := ctx.overwrites.ForceEnum[strings.Join(path, PATH_SEPARATOR)]
if len(f.Values) > 30 && !force {
f.Values = make(map[string]bool)
f.Enum = false

View file

@ -1,7 +1,8 @@
{
"ForceEnum": {
"df_world|historical_events|historical_event+HfDied|cause": true,
"df_world|historical_events|historical_event+HfDied|death_cause": true
"df_world|historical_events|historical_event+HfDied|death_cause": true,
"df_world|historical_events|historical_event+KnowledgeDiscovered|knowledge": true
},
"AdditionalFields": {
"Structure": [

View file

@ -1261,7 +1261,7 @@ func (x *HistoricalEventItemStolen) Html(c *Context) string {
}
func (x *HistoricalEventKnowledgeDiscovered) Html(c *Context) string {
return c.hf(x.Hfid) + util.If(x.First, " was the very first to discover ", " independently discovered ") + x.Knowledge
return c.hf(x.Hfid) + util.If(x.First, " was the very first to discover ", " independently discovered ") + x.Knowledge.String()
}
func (x *HistoricalEventMasterpieceArchConstructed) Html(c *Context) string {

File diff suppressed because it is too large Load diff