Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
Major Project Handcrafted
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
jonathan.poalses
Major Project Handcrafted
Commits
dc4e0da8
Commit
dc4e0da8
authored
May 01, 2023
by
Jonathan Poalses
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added more testing stuff.
parent
4c476d0a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
5 deletions
+37
-5
dialect_nlp.clj
src/poalses/jonathan/dialect/dialect_nlp.clj
+37
-5
No files found.
src/poalses/jonathan/dialect/dialect_nlp.clj
View file @
dc4e0da8
...
@@ -44,11 +44,13 @@
...
@@ -44,11 +44,13 @@
;; Take a sentence and figure out its dialect
;; Take a sentence and figure out its dialect
(
defn
detect-sentence-dialect
[
sentence
]
(
def
bad-words
#
{
"why"
"cause"
})
(
if
(
some
#
(
=
"why"
%
)
(
dl/text
(
dl/tokens
sentence
)))
:bad
:good
))
(
defn
detect-sentence-dialect
[
sentence
]
(
if
(
some
bad-words
(
dl/text
(
dl/tokens
sentence
)))
:bad
:good
))
(
some
bad-words
'
(
"why"
"not-why"
))
;; Take a text sample and separate it into it
'
s sentences, then for each sentence find its dialect, and return the most common dialect
;; Take a text sample and separate it into its sentences, then for each sentence find its dialect, and return the most common dialect
(
defn
detect-sample-dialect
[
sample
]
(
defn
detect-sample-dialect
[
sample
]
(
first
(
last
(
sort-by
val
(
frequencies
(
map
detect-sentence-dialect
(
dl/sentences
(
nlp
sample
))))))))
(
first
(
last
(
sort-by
val
(
frequencies
(
map
detect-sentence-dialect
(
dl/sentences
(
nlp
sample
))))))))
...
@@ -142,6 +144,32 @@
...
@@ -142,6 +144,32 @@
;; This identifies "like" in this instance as being an interjection (filler word)
;; This identifies "like" in this instance as being an interjection (filler word)
(
.tag
(
.getTarget
(
nth
(
nth
(
vals
(
datafy
(
dl/dependency-graph
(
nth
sentences-five
1
))))
3
)
2
)))
(
.tag
(
.getTarget
(
nth
(
nth
(
vals
(
datafy
(
dl/dependency-graph
(
nth
sentences-five
1
))))
3
)
2
)))
(
.word
(
.getTarget
(
nth
(
nth
(
vals
(
datafy
(
dl/dependency-graph
(
nth
sentences-five
1
))))
3
)
2
)))
(
.word
(
.getTarget
(
nth
(
nth
(
vals
(
datafy
(
dl/dependency-graph
(
nth
sentences-five
1
))))
3
)
2
)))
(
.getLongName
(
.getRelation
(
nth
(
nth
(
vals
(
datafy
(
dl/dependency-graph
(
nth
sentences-five
1
))))
3
)
2
)))
(
.getShortName
(
.getRelation
(
nth
(
nth
(
vals
(
datafy
(
dl/dependency-graph
(
nth
sentences-five
1
))))
3
)
2
)))
(
defn
extract-relation
[
word
sentences
]
(
for
[
sentence
sentences
]
(
let
[
data-edges
(
vals
(
datafy
(
dl/dependency-graph
sentence
)))]
(
for
[
edge
data-edges
]
(
let
[
edge-bean
(
bean
edge
)]
edge-bean
)))))
(
extract-relation
"like"
sentences-six
)
(
for
[
sentence
sentences-six
]
(
let
[
data-edges
(
vals
(
datafy
(
dl/dependency-graph
sentence
)))]
(
for
[
edge
data-edges
]
(
let
[
edge-bean
(
bean
edge
)]
edge-bean
))))
(
datafy
(
dl/dependency-graph
(
nth
sentences-six
2
)))
(
datafy
(
first
(
keys
(
datafy
(
dl/dependency-graph
(
nth
sentences-six
2
))))))
(
nav
(
datafy
(
dl/dependency-graph
(
nth
sentences-six
2
))))
(
datafy
(
:governor
(
first
(
map
datafy
(
nth
(
vals
(
datafy
(
dl/dependency-graph
(
nth
sentences-six
0
))))
0
)))))
(
.word
(
.getSource
(
nth
(
nth
(
vals
(
datafy
(
dl/dependency-graph
(
nth
sentences-five
1
))))
3
)
2
)))
(
.word
(
.getSource
(
nth
(
nth
(
vals
(
datafy
(
dl/dependency-graph
(
nth
sentences-five
1
))))
3
)
2
)))
...
@@ -189,8 +217,12 @@
...
@@ -189,8 +217,12 @@
(
detect-sentence-dialect
@
sentences-two
)
(
detect-sentence-dialect
@
sentences-two
)
(
detect-sample-dialect
sentences-one
)
(
detect-sample-dialect
test-sentence-one
)
(
detect-sample-dialect
@
sentences-two
)
(
detect-sample-dialect
test-sentence-two
)
(
detect-sample-dialect
sentences-two
)
(
detect-sample-dialect
sentences-three
)
(
detect-sample-dialect
sentences-three
)
(
detect-sample-dialect
sentences-four
)
(
detect-sample-dialect
sentences-four
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment