-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scripts for color_universe, begin reading natural languages
- Loading branch information
Showing
7 changed files
with
48 additions
and
18 deletions.
There are no files selected for viewing
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
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,4 @@ | ||
import pandas as pd | ||
import pickle | ||
|
||
from ultk.language.semantics import Universe | ||
|
||
|
||
def munsell_cielab_universe(filename: str) -> Universe: | ||
""" | ||
Load a Universe from a Munsell CIELAB file. | ||
Note: the tuple Universe.referents will be ordered by the Munsell Chip Number, as used in the WCS data. | ||
""" | ||
referents = pd.read_csv(filename, delimiter="\t") | ||
referents.sort_values(by="#cnum", inplace=True) | ||
# add a name column, as required by ULTK | ||
referents["name"] = referents["#cnum"] | ||
return Universe.from_dataframe(referents) | ||
|
||
|
||
color_universe = munsell_cielab_universe("data/cnum-vhcm-lab-new.txt") | ||
with open("colors/outputs/color_universe.pkl", "rb") as f: | ||
color_universe = pickle.load(f) |
Binary file not shown.
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import pandas as pd | ||
import pickle | ||
|
||
from ultk.language.semantics import Universe | ||
|
||
|
||
if __name__ == "__main__": | ||
referents = pd.read_csv("colors/data/cnum-vhcm-lab-new.txt", delimiter="\t") | ||
referents.sort_values(by="#cnum", inplace=True) | ||
# add a name column, as required by ULTK | ||
referents["name"] = referents["#cnum"] | ||
color_universe = Universe.from_dataframe(referents) | ||
|
||
with open("colors/outputs/color_universe.pkl", "wb") as f: | ||
pickle.dump(color_universe, f) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import pandas as pd | ||
|
||
from ultk.language.language import Expression, Language | ||
from ..meaning import color_universe | ||
|
||
if __name__ == "__main__": | ||
|
||
term_table = pd.read_csv( | ||
"data/term.txt", delimiter="\t", names=("lang", "spkr", "cnum", "term") | ||
) | ||
print(term_table) | ||
|
||
lang_term_chip_counts = term_table.groupby(["lang", "term", "cnum"]).count() | ||
print(lang_term_chip_counts) | ||
print(lang_term_chip_counts.index) | ||
|
||
for lang, lang_df in lang_term_chip_counts.groupby("lang"): | ||
print(lang) | ||
for term, term_df in lang_df.groupby("term"): | ||
print(term) | ||
print(term_df) |