<commit_before>package main

import (
  "fmt"
  "github.com/jonathankoren/gown"
)

func main() {
  wn, err := gown.LoadWordNet("./wn-dict")
  if err != nil {
    fmt.Printf("can't load WordNet: %v\n", err)
    return
  }

  // We'll load the word "live" which can be used as verb, adjective, or adverb
  fmt.Printf("live\n")
  for resultId, senseIndexEntry := range wn.Lookup("live") {
    printSenseIndexEntry(wn, resultId, senseIndexEntry)
    fmt.Printf("\n")
  }

  fmt.Printf("\n===================\n\n")

  // now let's lookup a word with a known part of speech
  dataIndexEntry := wn.LookupWithPartOfSpeech("computer", gown.POS_NOUN)
  if dataIndexEntry == nil {
      fmt.Printf("Can't found a computer as a noun!\n")
  } else {
      fmt.Printf("computer (noun)\n")
      fmt.Printf("%v\n", *dataIndexEntry)
      for _, synsetOffset := range dataIndexEntry.SynsetOffsets {
          printSynsetPtr(wn, wn.GetSynset(gown.POS_NOUN, synsetOffset))
          fmt.Printf("\n")
      }
  }

}

func printSenseIndexEntry(wn *gown.WN, resultId int, senseIndexEntry *gown.SenseIndexEntry) {
  fmt.Printf("\tresultId: %2d POS: (%d) %s TagCount: %d synsetOffset: %d\n",
    resultId,
    senseIndexEntry.PartOfSpeech,
    gown.PART_OF_SPEECH_ID_TO_STRING[senseIndexEntry.PartOfSpeech],
    senseIndexEntry.TagCount,
    senseIndexEntry.SynsetOffset,
  )
  synsetPtr := wn.GetSynset(senseIndexEntry.PartOfSpeech, senseIndexEntry.SynsetOffset)
  printSynsetPtr(wn, synsetPtr)
}

func printSynsetPtr(wn *gown.WN, synsetPtr *gown.Synset) {
    if synsetPtr == nil {
      fmt.Printf("\tNO SYNSET!\n")
    } else {
      //fmt.Printf("\t%v\n", *synsetPtr)
      fmt.Printf("\tGloss: %s\n", synsetPtr.Gloss)
      fmt.Printf("\tLexFile: %s POS: %s\n",
        gown.LEXOGRAPHER_FILE_NUM_TO_NAME[synsetPtr.LexographerFilenum],
        gown.PART_OF_SPEECH_ID_TO_STRING[synsetPtr.PartOfSpeech])

      fmt.Printf("\twords:")
      for i, word := range synsetPtr.Words {
        fmt.Printf(" %s (%d)", word, synsetPtr.LexIds[i])
      }
      fmt.Printf("\n")

      fmt.Printf("\trelations:\n")
      for i, relation := range synsetPtr.Relationships {
          printRelationship(wn, i, relation, synsetPtr.Words)
      }
    }
}

func printRelationship(wn *gown.WN, i int, relation gown.RelationshipEdge, srcWords []string) {
    //fmt.Printf("\t\t%v\n", relation)
    fmt.Printf("\t\t%d: %s (%d) >> ", i, gown.RELATIONSHIP_ID_TO_STRING[relation.RelationshipType], relation.RelationshipType)
    targetPtr := wn.GetSynset(relation.PartOfSpeech, relation.SynsetOffset)
    if targetPtr != nil {
        srcWordNumber := relation.SourceWordNumber
        if srcWordNumber > 0 {
            srcWordNumber-- // make it zero based
        }
        targetWordNumber := relation.TargetWordNumber<commit_msg>removed comments from example<commit_after>package main

import (
  "fmt"
  "github.com/jonathankoren/gown"
)

func main() {
  wn, err := gown.LoadWordNet("./wn-dict")
  if err != nil {
    fmt.Printf("can't load WordNet: %v\n", err)
    return
  }

  // We'll load the word "live" which can be used as verb, adjective, or adverb
  fmt.Printf("live\n")
  for resultId, senseIndexEntry := range wn.Lookup("live") {
    printSenseIndexEntry(wn, resultId, senseIndexEntry)
    fmt.Printf("\n")
  }

  fmt.Printf("\n===================\n\n")

  // now let's lookup a word with a known part of speech
  dataIndexEntry := wn.LookupWithPartOfSpeech("computer", gown.POS_NOUN)
  if dataIndexEntry == nil {
      fmt.Printf("Can't found a computer as a noun!\n")
  } else {
      fmt.Printf("computer (noun)\n")
      fmt.Printf("%v\n", *dataIndexEntry)
      for _, synsetOffset := range dataIndexEntry.SynsetOffsets {
          printSynsetPtr(wn, wn.GetSynset(gown.POS_NOUN, synsetOffset))
          fmt.Printf("\n")
      }
  }

}

func printSenseIndexEntry(wn *gown.WN, resultId int, senseIndexEntry *gown.SenseIndexEntry) {
  fmt.Printf("\tresultId: %2d POS: (%d) %s TagCount: %d synsetOffset: %d\n",
    resultId,
    senseIndexEntry.PartOfSpeech,
    gown.PART_OF_SPEECH_ID_TO_STRING[senseIndexEntry.PartOfSpeech],
    senseIndexEntry.TagCount,
    senseIndexEntry.SynsetOffset,
  )
  synsetPtr := wn.GetSynset(senseIndexEntry.PartOfSpeech, senseIndexEntry.SynsetOffset)
  printSynsetPtr(wn, synsetPtr)
}

func printSynsetPtr(wn *gown.WN, synsetPtr *gown.Synset) {
    if synsetPtr == nil {
      fmt.Printf("\tNO SYNSET!\n")
    } else {
      fmt.Printf("\tGloss: %s\n", synsetPtr.Gloss)
      fmt.Printf("\tLexFile: %s POS: %s\n",
        gown.LEXOGRAPHER_FILE_NUM_TO_NAME[synsetPtr.LexographerFilenum],
        gown.PART_OF_SPEECH_ID_TO_STRING[synsetPtr.PartOfSpeech])

      fmt.Printf("\twords:")
      for i, word := range synsetPtr.Words {
        fmt.Printf(" %s (%d)", word, synsetPtr.LexIds[i])
      }
      fmt.Printf("\n")

      fmt.Printf("\trelations:\n")
      for i, relation := range synsetPtr.Relationships {
          printRelationship(wn, i, relation, synsetPtr.Words)
      }
    }
}

func printRelationship(wn *gown.WN, i int, relation gown.RelationshipEdge, srcWords []string) {
    fmt.Printf("\t\t%d: %s (%d) >> ", i, gown.RELATIONSHIP_ID_TO_STRING[relation.RelationshipType], relation.RelationshipType)
    targetPtr := wn.GetSynset(relation.PartOfSpeech, relation.SynsetOffset)
    if targetPtr != nil {
        srcWordNumber := relation.SourceWordNumber
        if srcWordNumber > 0 {
            srcWordNumber-- // make it zero based
        }
        targetWordNumber := relation.TargetWordNumber
{'fraction_non_alphanumeric': 0.14280536426241391, 'fraction_numerical': 0.0007249003262051468, 'mean_word_length': 3.328627450980392, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4288692', 'n_tokens_mistral': 1991, 'n_tokens_neox': 1951, 'n_words': 370}