Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix double quotes for single #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ There are three files in this repository — each file works on its own:
## Example
This example shows the classifier displaying the independent probabilistic assumptions on whether given text aligns with keywords of *two* different animals: *cat* or *dog*.

$ ("meow purr hiss bad animal" 0) ("bark grr howl good animal" 1) b "I am an animal and I hiss"
$ ('meow purr hiss bad animal' 0) ('bark grr howl good animal' 1) b 'I am an animal and I hiss'
0.9999999995 4.999999994999999e¯10

[Try out this example using ngn/apl's online interpreter.](http://ngn.github.io/apl/web/index.html#code=b%u2190%7B%u2206%u2190%u237A%u22C4a%u2190%7B%u2375%u2282%u2368%7E%u2375%u220A%27%20%27%7D%u22C4b%u2190%7B%u2375%2Cq%u2190%27%20%27%7D%u22C4%u03B7%u2190%7B%27%27%2Ca%u220Ab%A8%28%u2375%3D1%u2283%A8%u2206%29/0%u2283%A8%u2206%7D%u22C4d%u2190%7Bo%u2190%28%7B+/%28a%u220Ab%A80%u2283%A8%u2206%29%u220A%u2375%20%22%22%7D%A8a%u2375%29%u22C4%28%28%u2374%u03B7%u237A%29%F7%28%28%u2374%u03B7%200%29+%28%u2374%u03B7%201%29%29%29%D7%D7/%281E%AF10+%28%28%u237A%7B+/%A8%28%u237A%7B%28%u03B7%u237A%29%u220A%u2375%20%27%27%7D%A8%28a%u2375%29%29%7D%u2375%29%F7%28%u2374%u03B7%u237A%29%29%D7o%29%F7%281+o%29%7D%u22C4%280d%u2375%29%281d%u2375%29%F7%28%280d%u2375%29+%281d%u2375%29%29%7D%0A%28%22meow%20purr%20hiss%20bad%20animal%22%200%29%20%28%22bark%20grr%20howl%20good%20animal%22%201%29%20b%20%22I%20am%20an%20animal%20and%20I%20hiss%22)
Expand Down
4 changes: 2 additions & 2 deletions bayes.apl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
⍝ http://www.opensource.org/licenses/mit-license
⍝ Format:
⍝ ("training text" 0) ("training text" 1) b "text to be classified"
⍝ ('training text' 0) ('training text' 1) b 'text to be classified'
⍝ Output:
⍝ The indexes correspond to the group assignment during training.
Expand All @@ -17,7 +17,7 @@ b ← {
η ← {'',a∊b¨(⍵=1⊃¨∆)/0⊃¨∆} ⍝ find all words in a group (⍵) of the training data
d ← { ⍝ scoring
e← (⍴η⍺)÷((⍴η 0)+(⍴η 1)) ⍝ percent of group in total training data
o←({+/(a∊b¨0⊃¨∆)∊⍵ ""}¨a⍵) ⍝ sum of members of testing data in training data
o←({+/(a∊b¨0⊃¨∆)∊⍵ ''}¨a⍵) ⍝ sum of members of testing data in training data
e××/(1E¯10+((⍺{+/¨(⍺{(η⍺)∊⍵ ''}¨(a⍵))}⍵)÷(⍴η⍺))×o)÷(1+o) ⍝ (assumed + (percent of specific group ÷ total words in group) × total) ÷ (weight+total)
}
(0d⍵)(1d⍵)÷((0d⍵)+(1d⍵))
Expand Down
4 changes: 2 additions & 2 deletions bayes.full.apl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
⍝ http://www.opensource.org/licenses/mit-license
⍝ Format:
⍝ ("training text" 0) ("training text" 1) b "text to be classified"
⍝ ('training text' 0) ('training text' 1) b 'text to be classified'
⍝ Output:
⍝ The indexes correspond to the group assignment during training.
Expand Down Expand Up @@ -33,7 +33,7 @@ b ← {
space_sep ← {⍵⊂⍨~⍵∊' '} ⍝ Separates words from a string vector into a string array
all_words ← 0⊃¨training_data ⍝ Finds all the words in the training data.
add_space ← {⍵,q←' '} ⍝ Adds after space after the argument
+/(space_sep ∊ add_space ¨ all_words)∊⍵ "" ⍝ Return: Sum of instances a word of as member of the training data.
+/(space_sep ∊ add_space ¨ all_words)∊⍵ '' ⍝ Return: Sum of instances a word of as member of the training data.
}

⍝ Finds the total sum of instances of membership of each word in a group of the training data.
Expand Down
2 changes: 1 addition & 1 deletion bayes.min.apl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b←{∆←⍺⋄a←{⍵⊂⍨~⍵∊' '}⋄b←{⍵,q←' '}⋄η←{'',a∊b¨(⍵=1⊃¨∆)/0⊃¨∆}⋄d←{o←({+/(a∊b¨0⊃¨∆)∊⍵ ""}¨a⍵)⋄((⍴η⍺)÷((⍴η 0)+(⍴η 1)))××/(1E¯10+((⍺{+/¨(⍺{(η⍺)∊⍵ ''}¨(a⍵))}⍵)÷(⍴η⍺))×o)÷(1+o)}⋄(0d⍵)(1d⍵)÷((0d⍵)+(1d⍵))}
b←{∆←⍺⋄a←{⍵⊂⍨~⍵∊' '}⋄b←{⍵,q←' '}⋄η←{'',a∊b¨(⍵=1⊃¨∆)/0⊃¨∆}⋄d←{o←({+/(a∊b¨0⊃¨∆)∊⍵ ''}¨a⍵)⋄((⍴η⍺)÷((⍴η 0)+(⍴η 1)))××/(1E¯10+((⍺{+/¨(⍺{(η⍺)∊⍵ ''}¨(a⍵))}⍵)÷(⍴η⍺))×o)÷(1+o)}⋄(0d⍵)(1d⍵)÷((0d⍵)+(1d⍵))}